# pyxb.utils package

## Submodules

## pyxb.utils.activestate module

`pyxb.utils.activestate.``detectXMLEncoding`(fp)

  Attempts to detect the character encoding of the xml file given by a file object fp. fp must not be a codec wrapped file object!

  The return value can be:
    - if detection of the BOM succeeds, the codec name of the

    corresponding unicode charset is returned

    - if BOM detection fails, the xml declaration is searched for

    the encoding attribute and its value returned. the “<” character has to be the very first in the file then (it’s xml standard after all).

    - if BOM and xml declaration fail, None is returned. According

    to xml 1.0 it should be utf_8 then, but it wasn’t detected by the means offered here. at least one can be pretty sure that a character coding including most of ASCII is used :-/

## pyxb.utils.domutils module

Functions that support activities related to the Document Object Model.

class `pyxb.utils.domutils.``BindingDOMSupport`(implementation=None, default_namespace=None, require_xsi_type=False, namespace_prefix_map=None)

  Bases: `object`

  This holds DOM-related information used when generating a DOM tree from a binding instance.

  classmethod `DeclareNamespace`(namespace, prefix=None)

    Declare a namespace that will made available to each created instance.

  classmethod `DefaultNamespace`()

    The global default namespace (used on instance creation if not overridden)

  classmethod `Reset`()

    Reset the global defaults for default/prefix/namespace information.

  classmethod `SetDefaultNamespace`(default_namespace)
  `_BindingDOMSupport__NamespaceContext` = <pyxb.namespace.resolution.NamespaceContext object>
  `_BindingDOMSupport__document` = None
  `_BindingDOMSupport__implementation` = None
  `_BindingDOMSupport__namespaceContext` = None
  `_BindingDOMSupport__referencedNamespacePrefixes` = None
  `_BindingDOMSupport__requireXSIType` = None
  `_deepClone`(node, docnode)
  `_makeURINodeNamePair`(node)

    Convert namespace information from a DOM node to text for new DOM node.

    The namespaceURI and nodeName are extracted and parsed. The namespace (if any) is registered within the document, along with any prefix from the node name. A pair is returned where the first element is the namespace URI or C{None}, and the second is a QName to be used for the expanded name within this document.

    @param node: An xml.dom.Node instance, presumably from a wildcard match. @rtype: C{( str, str )}

  `addAttribute`(element, expanded_name, value)

    Add an attribute to the given element.

    @param element: The element to which the attribute should be added @type element: C{xml.dom.Element} @param expanded_name: The name of the attribute. This may be a local name if the attribute is not in a namespace. @type expanded_name: L{pyxb.namespace.Namespace} or C{str} or C{unicode} @param value: The value of the attribute @type value: C{str} or C{unicode}

  `addXMLNSDeclaration`(element, namespace, prefix=None)

    Manually add an XMLNS declaration to the document element.

    @param namespace: a L{pyxb.namespace.Namespace} instance

    @param prefix: the prefix by which the namespace is known. If C{None}, the default prefix as previously declared will be used; if C{‘’} (empty string) a declaration for C{namespace} as the default namespace will be generated.

    @return: C{prefix} as used in the added declaration.

  `appendChild`(child, parent)

    Add the child to the parent.

    @note: If the child and the parent use different DOM implementations, this operation will clone the child into a new instance, and give that to the parent.

    @param child: The value to be appended @type child: C{xml.dom.Node} @param parent: The new parent of the child @type parent: C{xml.dom.Node} @rtype: C{xml.dom.Node}

  `appendTextChild`(text, parent)

    Add the text to the parent as a text node.

  `cloneIntoImplementation`(node)

    Create a deep copy of the node in the target implementation.

    Used when converting a DOM instance from one implementation (e.g., L{pyxb.utils.saxdom}) into another (e.g., L{xml.dom.minidom}).

  `createChildElement`(expanded_name, parent=None)

    Create a new element node in the tree.

    @param expanded_name: The name of the element. A plain string indicates a name in no namespace. @type expanded_name: L{pyxb.namespace.ExpandedName} or C{str} or C{unicode}

    @keyword parent: The node in the tree that will serve as the child’s parent. If C{None}, the document element is used. (If there is no document element, then this call creates it as a side-effect.)

    @return: A newly created DOM element @rtype: C{xml.dom.Element}

  `declareNamespace`(namespace, prefix=None)

    Declare a namespace within this instance only.

  `defaultNamespace`()

    The default namespace for this instance

  `document`()

    Return the document generated using this instance.

  `finalize`()

    Do the final cleanup after generating the tree. This makes sure that the document element includes XML Namespace declarations for all namespaces referenced in the tree.

    @return: The document that has been created. @rtype: C{xml.dom.Document}

  `implementation`()

    The DOMImplementation object to be used.

    Defaults to L{pyxb.utils.domutils.GetDOMImplementation()}, but can be overridden in the constructor call using the C{implementation} keyword.

  `namespacePrefix`(namespace, enable_default_namespace=True)

    Return the prefix to be used for the given namespace.

    This will L{declare <declareNamespace>} the namespace if it has not yet been observed. It will also ensure the mapping from the returned prefix to C{namespace} is recorded for addition as an xmlns directive in the final document.

    @param namespace: The namespace for which a prefix is needed. If the provided namespace is C{None} or an absent namespace, the C{None} value will be returned as the corresponding prefix.

    @keyword enable_default_namespace: Normally if the namespace is the default namespace C{None} is returned to indicate this. If this keyword is C{False} then we need a namespace prefix even if this is the default.

  `qnameAsText`(qname, enable_default_namespace=True)
  `requireXSIType`()

    Indicates whether {xsi:type<http://www.w3.org/TR/xmlschema-1/#xsi_type>} should be added to all elements.

    Certain WSDL styles and encodings seem to require explicit notation of the type of each element, even if it was specified in the schema.

    This value can only be set in the constructor.

  `reset`()

    Reset this instance to the state it was when created.

    This creates a new root document with no content, resets the namespace-prefix map to its as-constructed content, and clears the set of referenced namespace prefixes. The defaultNamespace and requireXSIType are not modified.

  `setDefaultNamespace`(default_namespace)
  `valueAsText`(value, enable_default_namespace=True)

    Represent a simple type value as XML text.

    This is essentially what C{value.xsdLiteral()} does, but this one handles any special cases such as QName values where the lexical representation cannot be done in isolation of external information such as namespace declarations.

`pyxb.utils.domutils.``ExtractTextContent`(node)

  Walk all the children, extracting all text content and catenating it into the return value.

  Returns C{None} if no text content (including whitespace) is found.

  This is mainly used to strip comments out of the content of complex elements with simple types.

  @rtype: C{unicode} or C{str}

`pyxb.utils.domutils.``GetDOMImplementation`()

  Return the DOMImplementation object used for pyxb operations.

  This is primarily used as the default implementation when generating DOM trees from a binding instance. It defaults to whatever xml.dom.getDOMImplementation() returns in your installation (often xml.dom.minidom). It can be overridden with SetDOMImplementation().

`pyxb.utils.domutils.``HasNonAnnotationChild`(node)

  Return True iff C{node} has an ELEMENT_NODE child that is not an XMLSchema annotation node.

  @rtype: C{bool}

`pyxb.utils.domutils.``LocateFirstChildElement`(node, absent_ok=True, require_unique=False, ignore_annotations=True)

  Locate the first element child of the node.

  @param node: An a xml.dom.Node ELEMENT_NODE instance. @keyword absent_ok: If C{True} (default), C{None} is returned if no match can be found. If C{False}, an exception is raised if no match can be found. @keyword require_unique: If C{False} (default), it is acceptable for there to be multiple child elements. If C{True}, presence of multiple child elements raises an exception. @keyword ignore_annotations: If C{True} (default), annotations are skipped wheen looking for the first child element. If C{False}, an annotation counts as an element. @rtype: C{xml.dom.Node}

  @raise SchemaValidationError: C{absent_ok} is C{False} and no child element was identified. @raise SchemaValidationError: C{require_unique} is C{True} and multiple child elements were identified

`pyxb.utils.domutils.``LocateMatchingChildren`(node, tag, namespace=<pyxb.namespace.builtin._XMLSchema object>)

  Locate all children of the DOM node that have a particular tag.

  This function returns a list of children of node which are ELEMENT_NODE instances and have a tag consistent with the given tag.

  @param node: An a xml.dom.Node ELEMENT_NODE instance. @param tag: the NCName of an element in the namespace, which defaults to the XMLSchema namespace. @keyword namespace: The namespace to which the child element belongs. Default is the XMLSchema namespace.

  @rtype: C{list(xml.dom.Node)}

`pyxb.utils.domutils.``LocateUniqueChild`(node, tag, absent_ok=True, namespace=<pyxb.namespace.builtin._XMLSchema object>)

  Locate a unique child of the DOM node.

  This function returns the sole child of node which is an ELEMENT_NODE instance and has a tag consistent with the given tag. If multiple nodes with a matching C{tag} are found, or C{absent_ok} is C{False} and no matching tag is found, an exception is raised.

  @param node: An a xml.dom.Node ELEMENT_NODE instance @param tag: the NCName of an element in the namespace @keyword absent_ok: If C{True} (default), C{None} is returned if no match can be found. If C{False}, an exception is raised if no match can be found. @keyword namespace: The namespace to which the child element belongs. Default is the XMLSchema namespace. @rtype: C{xml.dom.Node}

  @raise pyxb.SchemaValidationError: multiple elements are identified @raise pyxb.SchemaValidationError: C{absent_ok} is C{False} and no element is identified.

`pyxb.utils.domutils.``NodeAttribute`(node, attribute_ncname, attribute_ns=None)

  Namespace-aware search for an optional attribute in a node.

  @param attribute_ncname: The local name of the attribute. @type attribute_ncname: C{str} or C{unicode}

  @keyword attribute_ns: The namespace of the attribute. Defaults to None since most attributes are not in a namespace. Can be provided as either a L{pyxb.namespace.Namespace} instance, or a string URI. @type attribute_ns: C{None} or C{str} or C{unicode} or L{pyxb.namespace.Namespace}

  @return: The value of the attribute, or C{None} if the attribute is not present. (Unless C{None}, the value will always be a (unicode) string.)

`pyxb.utils.domutils.``NodeAttributeQName`(node, attribute_ncname, attribute_ns=None)

  Like L{NodeAttribute} but where the content is a QName that must be resolved in the context of the node.

  @param attribute_ncname: as in L{NodeAttribute} @keyword attribute_ns: as in L{NodeAttribute}

  @return: The expanded name to which the value of the attribute resolves given current namespaces, or C{None} if the attribute is not present @rtype: L{pyxb.namespace.ExpandedName}

`pyxb.utils.domutils.``SetDOMImplementation`(dom_implementation)

  Override the default DOMImplementation object.

`pyxb.utils.domutils.``StringToDOM`(xml_text, **kw)

  Convert string to a DOM instance.

  @see: L{pyxb._SetXMLStyle}.

## pyxb.utils.fac module

This module provides Finite Automata with Counters.

FACs are type of state machine where a transition may include a constraint and a modification to a set of counters. They are used to implement regular expressions with numerical constraints, as are found in POSIX regexp, Perl, and XML schema.

The implementation here derives from U{Regular Expressions with Numerical Constraints and Automata with Counters <https://bora.uib.no/bitstream/1956/3628/3/Hovland_LNCS%205684.pdf>}, Dag Hovland, Lecture Notes in Computer Science, 2009, Volume 5684, Theoretical Aspects of Computing - ICTAC 2009, Pages 231-245. In what follows, this reference will be denoted B{HOV09}.

A regular expression is directly translated into a term tree, where nodes are operators such as sequence, choice, and counter restrictions, and the leaf nodes denote symbols in the language of the regular expression.

In the case of XML content models, the symbols include L{element declarations <pyxb.xmlschema.structures.ElementDeclaration>} and L{wildcard elements <pyxb.xmlschema.structures.Wildcard>}. A numerical constraint node corresponds to an L{XML particle <pyxb.xmlschema.structures.Particle>}, and choice and sequence nodes derive from L{model groups <pyxb.xmlschema.structures.ModelGroup>} of types B{choice} and B{sequence}. As suggested in U{The Membership Problem for Regular Expressions with Unordered Concatenation and Numerical Constraints <http://www.ii.uib.no/~dagh/presLATA2012.pdf>} the B{all} content model can be translated into state machine using choice and sequence at the cost of a quadratic size explosion. Since some XML content models might have a hundred terms in an unordered catenation, this is not acceptable, and the implementation here optimizes this construct by creating a leaf node in the automaton which in turn contains sub-automata for each term, and permits an exit transition only when all the terms that are required have been completed.

@note: In XSD 1.1 the restriction that terms in an B{all} model group occur at most once has been removed. Since the current implementation removes a completed term from the set of available terms, this will not work: instead the subconfiguration with its counter values must be retained between matches.

class `pyxb.utils.fac.``All`(*terms, **kw)

  Bases: `pyxb.utils.fac.MultiTermNode`, `pyxb.utils.fac.LeafNode`

  A term that is an unordered sequence of terms.

  Note that the inheritance structure for this node is unusual. It has multiple children when it is treated as a term tree, but is considered a leaf node when constructing an automaton.

  classmethod `CreateTermTree`(*terms)

    Create a term tree that implements unordered catenation of the terms.

    This expansion results in a standard choice/sequence term tree, at the cost of quadratic state expansion because terms are L{cloned<Node.clone>} as required to satisfy the tree requirements of the term tree.

    @param terms: The tuple of terms that are elements of an accepted sequence.

    @return: A term tree comprising a choice between sequences that connect each term to the unordered catenation of the remaining terms.

  `_Precedence` = 0
  `_nullable`()

class `pyxb.utils.fac.``Automaton`(states, counter_conditions, nullable, containing_state=None)

  Bases: `object`

  Representation of a Finite Automaton with Counters.

  This has all the standard FAC elements, plus links to other states/automata as required to support the nested automata construct used for matching unordered catenation terms.

  `_Automaton__containingState` = None
  `_Automaton__counterConditions` = None
  `_Automaton__finalStates` = None
  `_Automaton__get_containingState`()

    The L{State} instance for which this is a sub-automaton.

    C{None} if this is not a sub-automaton.

  `_Automaton__get_counterConditions`()

    The set of L{CounterCondition}s in the automaton.

    These are marked positions in the regular expression, or L{particles<pyxb.xmlschema.structures.Particle>} in an XML schema, paired with their occurrence constraints.

  `_Automaton__get_finalStates`()

    The set of L{State} members which can terminate a match.

  `_Automaton__get_initialTransitions`()

    The set of transitions that may be made to enter the automaton.

    These are full transitions, including chains into subautomata if an initial state represents a node with sub-automata.

    @note: As with L{State.transitionSet}, the set is represented as a list to preserve priority when resolving non-deterministic matches.

  `_Automaton__get_nullable`()

    C{True} iff the automaton accepts the empty string.

  `_Automaton__get_states`()

    The set of L{State}s in the automaton.

    These correspond essentially to marked symbols in the original regular expression, or L{element declarations<pyxb.xmlschema.structures.ElementDeclaration>} in an XML schema.

    @note: These are conceptually a set and are stored that way. When an L{Automaton} is constructed the incoming states should be passed as a list so the calculated initial transitions are executed in a deterministic order.

  `_Automaton__initialTransitions` = None
  `_Automaton__nullable` = None
  `_Automaton__states` = None
  `containingState`

    The L{State} instance for which this is a sub-automaton.

    C{None} if this is not a sub-automaton.

  `counterConditions`

    The set of L{CounterCondition}s in the automaton.

    These are marked positions in the regular expression, or L{particles<pyxb.xmlschema.structures.Particle>} in an XML schema, paired with their occurrence constraints.

  `finalStates`

    The set of L{State} members which can terminate a match.

  `initialTransitions`

    The set of transitions that may be made to enter the automaton.

    These are full transitions, including chains into subautomata if an initial state represents a node with sub-automata.

    @note: As with L{State.transitionSet}, the set is represented as a list to preserve priority when resolving non-deterministic matches.

  `newConfiguration`()

    Return a new L{Configuration} instance for this automaton.

  `nullable`

    C{True} iff the automaton accepts the empty string.

  `states`

    The set of L{State}s in the automaton.

    These correspond essentially to marked symbols in the original regular expression, or L{element declarations<pyxb.xmlschema.structures.ElementDeclaration>} in an XML schema.

    @note: These are conceptually a set and are stored that way. When an L{Automaton} is constructed the incoming states should be passed as a list so the calculated initial transitions are executed in a deterministic order.

exception `pyxb.utils.fac.``AutomatonStepError`(*args)

  Bases: `Exception`

  Symbol rejected by L{Configuration_ABC.step}.

  The exception indicates that the proposed symbol either failed to produce a transition (L{UnrecognizedSymbolError}) or produced multiple equally valid transitions (L{NondeterministicSymbolError}).

  `_AutomatonStepError__get_acceptable`()

    A list of symbols that the configuration would accept in its current state.

  `acceptable`

    A list of symbols that the configuration would accept in its current state.

  `configuration` = None

    The instance of L{Configuration_ABC} that raised the exception. From L{Configuration_ABC.acceptableSymbols} you can determine what alternatives might be present.

  `symbol` = None

    The symbol that was not accepted.

class `pyxb.utils.fac.``Choice`(*terms, **kw)

  Bases: `pyxb.utils.fac.MultiTermNode`

  A term that may be any one of a set of terms.

  This term matches if any one of its contained terms matches.

  `_Precedence` = -3
  `_first`()
  `_follow`()
  `_last`()
  `_nullable`()

class `pyxb.utils.fac.``Configuration`(automaton, super_configuration=None)

  Bases: `pyxb.utils.fac.Configuration_ABC`

  The state of an L{Automaton} in execution.

  This combines a state node of the automaton with a set of counter values.

  `_Configuration__automaton` = None
  `_Configuration__counterValues` = None
  `_Configuration__get_automaton`()
  `_Configuration__get_state`()

    The state of the configuration.

    This is C{None} to indicate an initial state, or one of the underlying automaton’s states.

  `_Configuration__get_subAutomata`()

    A set of automata that must be satisfied before the current state can complete.

    This is used in unordered catenation. Each sub-automaton represents a term in the catenation. When the configuration enters a state with sub-automata, a set containing references to those automata is assigned to this attribute. Subsequently, until all automata in the state are satisfied, transitions can only occur within an active sub-automaton, out of the active sub-automaton if it is in an accepting state, and into a new sub-automaton if no sub-automaton is active.

  `_Configuration__get_subConfiguration`()

    Reference to configuration being executed in a sub-automaton.

    C{None} if no sub-automaton is active, else a reference to a configuration that is being executed in a sub-automaton.

    Sub-configurations are used to match sub-terms in an L{unordered catenation<All>} term. A configuration may have at most one sub-configuration at a time, and the configuration will be removed and possibly replaced when the term being processed completes.

  `_Configuration__get_superConfiguration`()

    Reference to the configuration for which this is a sub-configuration.

    C{None} if no super-automaton is active, else a reference to a configuration that is being executed in a super-automaton.

    The super-configuration relation persists for the lifetime of the configuration.

  `_Configuration__state` = None
  `_Configuration__subAutomata` = None
  `_Configuration__subConfiguration` = None
  `_Configuration__superConfiguration` = None
  `__counterValues` = None

    The values of the counters.

    This is a map from the CounterCondition instances of the underlying automaton to integer values.

  `_clone`(clone_map, super_configuration)
  `_get_counterValues`()
  `_set_state`(state, is_layer_change)

    Internal state transition interface.

    @param state: the new destination state

    @param is_layer_change: C{True} iff the transition inducing the state change involves a layer change.

  `_set_subAutomata`(automata)
  `acceptableSymbols`()
  `automaton`
  `candidateTransitions`(symbol=None)

    Return list of viable transitions on C{symbol}

    The transitions that are structurally permitted from this state, in order, filtering out those transitions where the update instruction is not satisfied by the configuration counter values and optionally those for which the symbol does not match.

    @param symbol: A symbol through which a transition from this state is intended. A value of C{None} indicates that the set of transitions should ignore the symbol; candidates are still filtered based on the counter state of the configuration.

    @return: A list of L{Transition} instances permitted from the current configuration. If C{symbol} is not C{None}, transitions that would not accept the symbol are excluded. Any transition that would require an unsatisfied counter update is also excluded. Non-deterministic automata may result in a lits with multiple members.

  `clone`(clone_map=None)

    Clone a configuration and its descendents.

    This is used for parallel execution where a configuration has multiple candidate transitions and must follow all of them. It clones the entire chain of configurations through multiple layers.

    @param clone_map: Optional map into which the translation from the original configuration object to the corresponding cloned configuration object can be reconstructed, e.g. when applying a transition that includes automata exits referencing superconfigurations from the original configuration.

  `enterAutomaton`(automaton)

    Execute steps to enter a new automaton.

    The new automaton is removed from the set of remaining automata for the current state, and a new configuration created. No transition is made in that new configuration.

    @param automaton: The automaton to be entered

    @return: The configuration that executes the new automaton as a sub-configuration of C{self}.

  `isAccepting`()

    Return C{True} iff the automaton is in an accepting state.

  `isInitial`()

    Return C{True} iff no transitions have ever been made.

  `leaveAutomaton`(sub_configuration)

    Execute steps to leave a sub-automaton.

    @param sub_configuration: The configuration associated with the automata that has completed.

    @return: C{self}

  `makeLeaveAutomatonTransition`()

    Create a transition back to the containing configuration.

    This is done when a configuration is in an accepting state and there are candidate transitions to other states that must be considered. The transition does not consume a symbol.

  `reset`()
  `satisfies`(transition)
  `state`

    The state of the configuration.

    This is C{None} to indicate an initial state, or one of the underlying automaton’s states.

  `step`(symbol)
  `subAutomata`

    A set of automata that must be satisfied before the current state can complete.

    This is used in unordered catenation. Each sub-automaton represents a term in the catenation. When the configuration enters a state with sub-automata, a set containing references to those automata is assigned to this attribute. Subsequently, until all automata in the state are satisfied, transitions can only occur within an active sub-automaton, out of the active sub-automaton if it is in an accepting state, and into a new sub-automaton if no sub-automaton is active.

  `subConfiguration`

    Reference to configuration being executed in a sub-automaton.

    C{None} if no sub-automaton is active, else a reference to a configuration that is being executed in a sub-automaton.

    Sub-configurations are used to match sub-terms in an L{unordered catenation<All>} term. A configuration may have at most one sub-configuration at a time, and the configuration will be removed and possibly replaced when the term being processed completes.

  `superConfiguration`

    Reference to the configuration for which this is a sub-configuration.

    C{None} if no super-automaton is active, else a reference to a configuration that is being executed in a super-automaton.

    The super-configuration relation persists for the lifetime of the configuration.

class `pyxb.utils.fac.``Configuration_ABC`

  Bases: `object`

  Base class for something that represents an L{Automaton} in execution.

  For deterministic automata, this is generally a L{Configuration} which records the current automaton state along with its counter values.

  For non-deterministic automata, this is a L{MultiConfiguration} which records a set of L{Configuration}s.

  `acceptableSymbols`()

    Return the acceptable L{Symbol}s given the current configuration.

    This method extracts the symbol from all candidate transitions that are permitted based on the current counter values. Because transitions are presented in a preferred order, the symbols are as well.

  `step`(symbol)

    Execute an automaton transition using the given symbol.

    @param symbol: A symbol from the alphabet of the automaton’s language. This is a Python value that should be accepted by the L{SymbolMatch_mixin.match} method of a L{State.symbol}. It is not a L{Symbol} instance.

    @return: The new configuration resulting from the step.

    @raises AutomatonStepError: L{UnrecognizedSymbolError} when no transition compatible with C{symbol} is available, and L{NondeterministicSymbolError} if C{symbol} admits multiple transitions and the subclass does not support non-deterministic steps (see L{MultiConfiguration}).

    @warning: If the step entered or left a sub-automaton the return value will not be the configuration that was used to execute the step. The proper pattern for using this method is:

        cfg = cfg.step(sym)

class `pyxb.utils.fac.``CounterCondition`(min, max, metadata=None)

  Bases: `object`

  A counter condition is a range limit on valid counter values.

  Instances of this class serve as keys for the counters that represent the configuration of a FAC. The instance also maintains a pointer to application-specific L{metadata}.

  `_CounterCondition__get_max`()

    The maximum legal value for the counter.

    This is a positive integer, or C{None} to indicate that the counter is unbounded.

  `_CounterCondition__get_metadata`()

    A pointer to application metadata provided when the condition was created.

  `_CounterCondition__get_min`()

    The minimum legal value for the counter.

    This is a non-negative integer.

  `_CounterCondition__max` = None
  `_CounterCondition__metadata` = None
  `_CounterCondition__min` = None
  `max`

    The maximum legal value for the counter.

    This is a positive integer, or C{None} to indicate that the counter is unbounded.

  `metadata`

    A pointer to application metadata provided when the condition was created.

  `min`

    The minimum legal value for the counter.

    This is a non-negative integer.

exception `pyxb.utils.fac.``FACError`

  Bases: `Exception`

exception `pyxb.utils.fac.``InvalidTermTreeError`(*args)

  Bases: `pyxb.utils.fac.FACError`

  Exception raised when a FAC term tree is not a tree.

  For example, a L{Symbol} node appears multiple times, or a cycle is detected.

  `parent` = None

    The L{MultiTermNode} containing the term that proves invalidity

  `term` = None

    The L{Node} that proves invalidity

class `pyxb.utils.fac.``LeafNode`(**kw)

  Bases: `pyxb.utils.fac.Node`

  Intermediary for nodes that have no child nodes.

  `_first`()
  `_follow`()
  `_last`()
  `_nullable`()
  `_walkTermTree`(position, pre, post, arg)

class `pyxb.utils.fac.``MultiConfiguration`(configuration)

  Bases: `pyxb.utils.fac.Configuration_ABC`

  Support parallel execution of state machine.

  This holds a set of configurations, and executes each transition on each one. Configurations which fail to accept a step are silently dropped; only if this results in no remaining configurations will L{UnrecognizedSymbolError} be raised. If a step admits multiple valid transitions, a configuration is added for each one.

  See L{pyxb.binding.content.AutomatonConfiguration} for an alternative solution which holds actions associated with the transition until the non-determinism is resolved.

  `_MultiConfiguration__configurations` = None
  `acceptableSymbols`()
  `acceptingConfigurations`()

    Return the set of configurations that are in an accepting state.

    Note that some of the configurations may be within a sub-automaton; their presence in the return value is because the root configuration is also accepting.

  `step`(symbol)

class `pyxb.utils.fac.``MultiTermNode`(*terms, **kw)

  Bases: `pyxb.utils.fac.Node`

  Intermediary for nodes that have multiple child nodes.

  `_MultiTermNode__get_terms`()

    The set of subordinate terms of the current node.

  `_MultiTermNode__terms` = None
  `_walkTermTree`(position, pre, post, arg)
  `clone`()
  `terms`

    The set of subordinate terms of the current node.

class `pyxb.utils.fac.``Node`(**kw)

  Bases: `object`

  Abstract class for any node in the term tree.

  In its original form a B{position} (C{pos}) is a tuple of non-negative integers comprising a path from a node in the term tree. It identifies a node in the tree. After the FAC has been constructed, only positions that are leaf nodes in the term tree remain, and the corresponding symbol value (Python instance) is used as the position.

  An B{update instruction} (C{psi}) is a map from positions to either L{Node.RESET} or L{Node.INCREMENT}. It identifies actions to be taken on the counter states corresponding to the positions in its domain.

  A B{transition} is a pair containing a position and an update instruction. It identifies a potential next node in the state and the updates that are to be performed if the transition is taken.

  A B{follow value} is a map from a position to a set of transitions that may originate from the pos. This set is represented as a Python list since update instructions are dicts and cannot be hashed.

  `INCREMENT` = True

    An arbitrary value representing increment of a counter.

  `RESET` = False

    An arbitrary value representing reset of a counter.

  `_Node__counterPositions` = None
  `_Node__first` = None
  `_Node__follow` = None
  `_Node__get_counterPositions`()

    Implement definition 13.1 from B{HOV09}.

    The return value is the set of all positions leading to L{NumericalConstraint} nodes for which either the minimum value is not 1 or the maximum value is not unbounded.

  `_Node__get_first`()

    The I{first} set for the node.

    This is the set of positions leading to symbols that can appear first in a string matched by an execution starting at the node.

  `_Node__get_follow`()

    The I{follow} map for the node.

  `_Node__get_last`()

    The I{last} set for the node.

    This is the set of positions leading to symbols that can appear last in a string matched by an execution starting at the node.

  `_Node__get_metadata`()

    Application-specific metadata provided during construction.

  `_Node__get_nodePosMap`()

    A map from nodes to their position in the term tree.

  `_Node__get_nullable`()

    C{True} iff the empty string is accepted by this node.

  `_Node__get_posNodeMap`()

    A map from positions to nodes in the term tree.

  `_Node__last` = None
  `_Node__metadata` = None
  `_Node__nodePosMap` = None
  `_Node__nullable` = None
  `_Node__posNodeMap` = None
  `_Node__resetAndValidate`(node, pos, visited_nodes)
  classmethod `_PosConcatPosSet`(pos, pos_set)

    Implement definition 11.1 in B{HOV09}.

  classmethod `_PosConcatTransitionSet`(pos, transition_set)

    Implement definition 11.3 in B{HOV09}

  classmethod `_PosConcatUpdateInstruction`(pos, psi)

    Implement definition 11.2 in B{HOV09}

  `_Precedence` = None

    An integral value used for parenthesizing expressions.

    A subterm that has a precedence less than that of its containing term must be enclosed in parentheses when forming a text expression representing the containing term.

  `_facToString`()

    Obtain a description of the FAC in text format.

    This is a diagnostic tool, returning first, last, and follow maps using positions.

  `_first`()

    Abstract method that defines L{first} for the subclass.

    The return value should be an iterable of tuples of integers denoting paths from this node through the term tree to a symbol.

  `_follow`()

    Abstract method that defines L{follow} for the subclass.

    The return value should be a map from tuples of integers (positions) to a list of transitions, where a transition is a position and an update instruction.

  `_last`()

    Abstract method that defines L{last} for the subclass.

    The return value should be an iterable of tuples of integers denoting paths from this node through the term tree to a symbol.

  `_nullable`()

    Abstract method that defines L{nullable} for the subclass.

    The return value should be C{True} or C{False}.

  `_walkTermTree`(position, pre, post, arg)

    Abstract method implementing L{walkTermTree} for the subclass.

  `buildAutomaton`(state_ctor=<class 'pyxb.utils.fac.State'>, ctr_cond_ctor=<class 'pyxb.utils.fac.CounterCondition'>, containing_state=None)
  `clone`(*args, **kw)

    Create a deep copy of the node.

    All term-tree–related attributes and properties are replaced with deep clones. Other attributes are preserved.

    @param args: A tuple of arguments to be passed to the instance constructor.

    @param kw: A dict of keywords to be passed to the instance constructor.

    @note: Subclasses should pre-extend this method to augment the C{args} and C{kw} parameters as necessary to match the expectations of the C{__init__} method of the class being cloned.

  `counterPositions`

    Implement definition 13.1 from B{HOV09}.

    The return value is the set of all positions leading to L{NumericalConstraint} nodes for which either the minimum value is not 1 or the maximum value is not unbounded.

  `counterSubPositions`(pos)

    Implement definition 13.2 from B{HOV09}.

    This is the subset of L{counterPositions} that occur along the path to C{pos}.

  `first`

    The I{first} set for the node.

    This is the set of positions leading to symbols that can appear first in a string matched by an execution starting at the node.

  `follow`

    The I{follow} map for the node.

  `last`

    The I{last} set for the node.

    This is the set of positions leading to symbols that can appear last in a string matched by an execution starting at the node.

  `metadata`

    Application-specific metadata provided during construction.

  `nodePosMap`

    A map from nodes to their position in the term tree.

  `nullable`

    C{True} iff the empty string is accepted by this node.

  `posNodeMap`

    A map from positions to nodes in the term tree.

  `reset`()

    Reset any term-tree state associated with the node.

    Any change to the structure of the term tree in which the node appears invalidates memoized first/follow sets and related information. This method clears all that data so it can be recalculated. It does not clear the L{metadata} link, or any existing structural data.

  `walkTermTree`(pre, post, arg)

    Utility function for term tree processing.

    @param pre: a callable that, unless C{None}, is invoked at each node C{n} with parameters C{n}, C{pos}, and C{arg}, where C{pos} is the tuple of integers identifying the path from the node at on which this method was invoked to the node being processed. The invocation occurs before processing any subordinate nodes.

    @param post: as with C{pre} but invocation occurs after processing any subordinate nodes.

    @param arg: a value passed to invocations of C{pre} and C{post}.

exception `pyxb.utils.fac.``NondeterministicSymbolError`(*args)

  Bases: `pyxb.utils.fac.AutomatonStepError`

  L{Configuration.step} found multiple transitions.

class `pyxb.utils.fac.``NumericalConstraint`(term, min=0, max=1, **kw)

  Bases: `pyxb.utils.fac.Node`

  A term with a numeric range constraint.

  This corresponds to a “particle” in the XML Schema content model.

  `_NumericalConstraint__get_max`()
  `_NumericalConstraint__get_min`()
  `_NumericalConstraint__get_term`()
  `_NumericalConstraint__max` = None
  `_NumericalConstraint__min` = None
  `_NumericalConstraint__term` = None
  `_Precedence` = -1
  `_first`()
  `_follow`()
  `_last`()
  `_nullable`()
  `_walkTermTree`(position, pre, post, arg)
  `clone`()
  `max`
  `min`
  `term`

class `pyxb.utils.fac.``Sequence`(*terms, **kw)

  Bases: `pyxb.utils.fac.MultiTermNode`

  A term that is an ordered sequence of terms.

  `_Precedence` = -2
  `_first`()
  `_follow`()
  `_last`()
  `_nullable`()

class `pyxb.utils.fac.``State`(symbol, is_initial, final_update=None, is_unordered_catenation=False)

  Bases: `object`

  A thin wrapper around an object reference.

  The state of the automaton corresponds to a position, or marked symbol, in the term tree. Because the same symbol may appear at multiple locations in the tree, and the distinction between these positions is critical, a L{State} wrapper is provided to maintain distinct values.

  `_State__automaton` = None
  `_State__automatonEntryTransitions` = None
  `_State__finalUpdate` = None
  `_State__get_automaton`()

    Link to the L{Automaton} to which the state belongs.

  `_State__get_automatonEntryTransitions`()

    Return the set of initial transitions allowing entry to the automata through this state.

    These are structurally-permitted transitions only, and must be filtered based on the symbol that might trigger the transition. The results are not filtered based on counter value, since this value is used to determine how the containing automaton might be entered. Consequently the return value is the empty set unless this is an initial state.

    The returned set is closed under entry to sub-automata, i.e. it is guaranteed that each transition includes a consuming state even if it requires a multi-element chain of transitions into subautomata to reach one.

  `_State__get_finalUpdate`()

    Return the update instructions that must be satisfied for this to be a final state.

  `_State__get_isInitial`()

    C{True} iff this state may be the first state the automaton enters.

  `_State__get_isUnorderedCatenation`()

    Indicate whether the state has subautomata for unordered catenation.

    To reduce state explosion due to non-determinism, such a state executes internal transitions in subautomata until all terms have matched or a failure is discovered.

  `_State__get_subAutomata`()

    A sequence of sub-automata supporting internal state transitions.

    This will return C{None} unless L{isUnorderedCatenation} is C{True}.

  `_State__get_symbol`()

    Application-specific metadata identifying the symbol.

    See also L{match}.

  `_State__get_transitionSet`()

    Definitions of viable transitions from this state.

    The transition set of a state is a set of L{Transition} nodes identifying a state reachable in a single step from this state, and a set of counter updates that must apply if the transition is taken.

    These transitions may not in themselves consume a symbol. For example, if the destination state represents a match of an L{unordered catenation of terms<All>}, then secondary processing must be done to traverse into the automata for those terms and identify transitions that include a symbol consumption.

    @note: Although conceptually the viable transitions are a set, this implementation maintains them in a list so that order is preserved when automata processing becomes non-deterministic. PyXB is careful to build the transition list so that the states are attempted in the order in which they appear in the schema that define the automata.

  `_State__isInitial` = None
  `_State__isUnorderedCatenation` = None
  `_State__subAutomata` = None
  `_State__symbol` = None
  `_State__transitionSet` = None
  `_facText`()
  `_set_automaton`(automaton)

    Method invoked during automaton construction to set state owner.

  `_set_subAutomata`(*automata)
  `_set_transitionSet`(transition_set)

    Method invoked during automaton construction to set the legal transitions from the state.

    The set of transitions cannot be defined until all states that appear in it are available, so the creation of the automaton requires that the association of the transition set be delayed. (Though described as a set, the transitions are a list where order reflects priority.)

    @param transition_set: a list of pairs where the first member is the destination L{State} and the second member is the set of L{UpdateInstruction}s that apply when the automaton transitions to the destination state.

  `automaton`

    Link to the L{Automaton} to which the state belongs.

  `automatonEntryTransitions`

    Return the set of initial transitions allowing entry to the automata through this state.

    These are structurally-permitted transitions only, and must be filtered based on the symbol that might trigger the transition. The results are not filtered based on counter value, since this value is used to determine how the containing automaton might be entered. Consequently the return value is the empty set unless this is an initial state.

    The returned set is closed under entry to sub-automata, i.e. it is guaranteed that each transition includes a consuming state even if it requires a multi-element chain of transitions into subautomata to reach one.

  `finalUpdate`

    Return the update instructions that must be satisfied for this to be a final state.

  `isAccepting`(counter_values)

    C{True} iff this state is an accepting state for the automaton.

    @param counter_values: Counter values that further validate whether the requirements of the automaton have been met.

    @return: C{True} if this is an accepting state and the counter values relevant at it are satisfied.

  `isInitial`

    C{True} iff this state may be the first state the automaton enters.

  `isUnorderedCatenation`

    Indicate whether the state has subautomata for unordered catenation.

    To reduce state explosion due to non-determinism, such a state executes internal transitions in subautomata until all terms have matched or a failure is discovered.

  `match`(symbol)

    Return C{True} iff the symbol matches for this state.

    This may be overridden by subclasses when matching by equivalence does not work. Alternatively, if the symbol stored in this node is a subclass of L{SymbolMatch_mixin}, then its match method will be used. Otherwise C{symbol} matches only if it is equal to the L{symbol} of this state.

    @param symbol: A candidate symbol corresponding to the expression symbol for this state.

    @return: C{True} iff C{symbol} is a match for this state.

  `subAutomata`

    A sequence of sub-automata supporting internal state transitions.

    This will return C{None} unless L{isUnorderedCatenation} is C{True}.

  `subAutomataInitialTransitions`(sub_automata=None)

    Return the set of candidate transitions to enter a sub-automaton of this state.

    @param sub_automata: A subset of the sub-automata of this state which should contribute to the result. If C{None}, all sub-automata are used.

    @return: A pair C{(nullable, transitions)} where C{nullable} is C{True} iff there is at least one sub-automaton that is in an accepting state on entry, and C{transitions} is a list of L{Transition} instances describing how to reach some state in a sub-automaton via a consumed symbol.

  `symbol`

    Application-specific metadata identifying the symbol.

    See also L{match}.

  `transitionSet`

    Definitions of viable transitions from this state.

    The transition set of a state is a set of L{Transition} nodes identifying a state reachable in a single step from this state, and a set of counter updates that must apply if the transition is taken.

    These transitions may not in themselves consume a symbol. For example, if the destination state represents a match of an L{unordered catenation of terms<All>}, then secondary processing must be done to traverse into the automata for those terms and identify transitions that include a symbol consumption.

    @note: Although conceptually the viable transitions are a set, this implementation maintains them in a list so that order is preserved when automata processing becomes non-deterministic. PyXB is careful to build the transition list so that the states are attempted in the order in which they appear in the schema that define the automata.

class `pyxb.utils.fac.``Symbol`(symbol, **kw)

  Bases: `pyxb.utils.fac.LeafNode`

  A leaf term that is a symbol.

  The symbol is represented by the L{metadata} field.

  `_Precedence` = 0
  `clone`()

class `pyxb.utils.fac.``SymbolMatch_mixin`

  Bases: `object`

  Mix-in used by symbols to provide a custom match implementation.

  If a L{State.symbol} value is an instance of this mix-in, then it will be used to validate a candidate symbol for a match.

  `match`(symbol)

class `pyxb.utils.fac.``Transition`(destination, update_instructions, layer_link=None)

  Bases: `object`

  Representation of a FAC state transition.

  `_Transition__destination` = None
  `_Transition__get_destination`()

    The transition destination state.

  `_Transition__get_layerLink`()

    A directive relating to changing automaton layer on transition.

    C{None} indicates this transition is from one state to another within a single automaton.

    An instance of L{Configuration} is a transition on completion of a subautomaton back to the configuration in the parent automaton. The L{destination} is the state in the parent automaton.

    An instance of L{Automaton} requires creation of a sub-configuration and initial entry into the automaton. The L{destination} is the state in the sub-automaton.

  `_Transition__get_nextTransition`()

    The next transition to apply in this chain.

    C{None} if this is the last transition in the chain.

  `_Transition__get_updateInstructions`()

    The set of counter updates that are applied when the transition is taken.

  `_Transition__layerLink` = None
  `_Transition__nextTransition` = None
  `_Transition__updateInstructions` = None
  `apply`(configuration, clone_map=None)

    Apply the transitition to a configuration.

    This updates the configuration counter values based on the update instructions, and sets the new configuration state.

    @note: If the transition involves leaving a sub-automaton or creating a new sub-automaton, the returned configuration structure will be different from the one passed in. You should invoke this as:

        cfg = transition.apply(cfg)

    @param configuration: A L{Configuration} of an executing automaton

    @param clone_map: A map from L{Configuration} to L{Configuration} reflecting the replacements made when the configuration for which the transition was calculated was subsequently cloned into the C{configuration} passed into this method. This is only necessary when the transition includes layer transitions.

    @return: The resulting configuration

  `chainTo`(next_transition)

    Duplicate the state and chain the duplicate to a successor transition.

    This returns a new transition which applies the operation for this transition, then proceeds to apply the next transition in the chain.

    @note: The node that is invoking this must not have successor transitions.

    @param next_transition: A L{Transition} node describing a subsequent transition.

    @return: a clone of this node, augmented with a link to C{next_transition}.

  `consumedSymbol`()

    Return the L{symbol<State.symbol>} of the L{consumingState}.

  `consumingState`()

    Return the state in this transition chain that must match a symbol.

  `destination`

    The transition destination state.

  `layerLink`

    A directive relating to changing automaton layer on transition.

    C{None} indicates this transition is from one state to another within a single automaton.

    An instance of L{Configuration} is a transition on completion of a subautomaton back to the configuration in the parent automaton. The L{destination} is the state in the parent automaton.

    An instance of L{Automaton} requires creation of a sub-configuration and initial entry into the automaton. The L{destination} is the state in the sub-automaton.

  `makeEnterAutomatonTransition`()

    Replicate the transition as a layer link into its automaton.

    This is used on initial transitions into sub-automata where a sub-configuration must be created and recorded.

  `nextTransition`

    The next transition to apply in this chain.

    C{None} if this is the last transition in the chain.

  `satisfiedBy`(configuration)

    Check the transition update instructions against configuration counter values.

    This implementation follows layer changes, updating the configuration used as counter value source as necessary.

    @param configuration: A L{Configuration} instance containing counter data against which update instruction satisfaction is checked.

    @return: C{True} iff all update instructions along the transition chain are satisfied by their relevant configuration.

  `updateInstructions`

    The set of counter updates that are applied when the transition is taken.

exception `pyxb.utils.fac.``UnrecognizedSymbolError`(*args)

  Bases: `pyxb.utils.fac.AutomatonStepError`

  L{Configuration.step} failed to find a valid transition.

exception `pyxb.utils.fac.``UpdateApplicationError`(*args)

  Bases: `pyxb.utils.fac.FACError`

  Exception raised when an unsatisfied update instruction is executed.

  This indicates an internal error in the implementation.

  `update_instruction` = None

    The L{UpdateInstruction} with an unsatisfied L{CounterCondition}

  `values` = None

    The unsatisfying value map from L{CounterCondition} instances to integers

class `pyxb.utils.fac.``UpdateInstruction`(counter_condition, do_increment)

  Bases: `object`

  An update instruction pairs a counter with a mutation of that counter.

  The instruction is executed during a transition from one state to another, and causes the corresponding counter to be incremented or reset. The instruction may only be applied if doing so does not violate the conditions of the counter it affects.

  classmethod `Apply`(update_instructions, counter_values)

    Apply the update instructions to the counter values.

    @param update_instructions: A set of L{UpdateInstruction} instances.

    @param counter_values: A map from L{CounterCondition} instances to non-negative integers. This map is updated in-place by applying each instruction in C{update_instructions}.

  classmethod `Satisfies`(counter_values, update_instructions)

    Return C{True} iff the counter values satisfy the update instructions.

    @param counter_values: A map from L{CounterCondition} to integer counter values

    @param update_instructions: A set of L{UpdateInstruction} instances

    @return: C{True} iff all instructions are satisfied by the values and limits.

  `_UpdateInstruction__counterCondition` = None
  `_UpdateInstruction__doIncrement` = None
  `_UpdateInstruction__get_counterCondition`()

    A reference to the L{CounterCondition} identifying the counter to be updated.

    The counter condition instance is used as a key to the dictionary maintaining current counter values.

  `_UpdateInstruction__get_doIncrement`()

    C{True} if the counter is to be incremented; C{False} if it is to be reset.

  `_UpdateInstruction__max` = None
  `_UpdateInstruction__min` = None
  `apply`(counter_values)

    Apply the update instruction to the provided counter values.

    @param counter_values: A map from L{CounterCondition} to integer counter values. This map is updated in-place.

  `counterCondition`

    A reference to the L{CounterCondition} identifying the counter to be updated.

    The counter condition instance is used as a key to the dictionary maintaining current counter values.

  `doIncrement`

    C{True} if the counter is to be incremented; C{False} if it is to be reset.

  `satisfiedBy`(counter_values)

    Implement a component of definition 5 from B{HOV09}.

    The update instruction is satisfied by the counter values if its action may be legitimately applied to the value of its associated counter.

    @param counter_values: A map from L{CounterCondition}s to non-negative integers

    @return: C{True} or C{False}

## pyxb.utils.saxdom module

This module contains support for a DOM tree representation from an XML document using a SAX parser.

This functionality exists because we need a DOM interface to generate the binding classses, but the Python C{xml.dom.minidom} package does not support location information. The SAX interface does, so we have a SAX content handler which converts the SAX events into a DOM tree.

This is not a general-purpose DOM capability; only a small subset of the DOM interface is supported, and only for storing the XML information, not for converting it back into document format.

class `pyxb.utils.saxdom.``Attr`(**kw)

  Bases: `pyxb.utils.saxdom.Node`

  Add the nodeName and nodeValue interface.

  `name`
  `nodeName`
  `nodeValue`

class `pyxb.utils.saxdom.``Comment`(text, **kw)

  Bases: `pyxb.utils.saxdom._CharacterData`

class `pyxb.utils.saxdom.``Document`(**kw)

  Bases: `pyxb.utils.saxdom.Node`

  Add the documentElement interface.

  `documentElement`

class `pyxb.utils.saxdom.``Element`(**kw)

  Bases: `pyxb.utils.saxdom.Node`

  `nodeName`
  `tagName`

class `pyxb.utils.saxdom.``NamedNodeMap`

  Bases: `object`

  Implement that portion of NamedNodeMap required to satisfy PyXB’s needs.

  `_NamedNodeMap__memberMap` = None
  `_NamedNodeMap__members` = None
  `_addItem`(attr)
  `_getAttr`(name)
  `item`(index)
  `length`

class `pyxb.utils.saxdom.``Node`(node_type, **kw)

  Bases: `xml.dom.Node`, `pyxb.utils.utility.Locatable_mixin`

  Base for the minimal DOM interface required by PyXB.

  `_Node__attributes` = None
  `_Node__childIfPresent`(index)
  `_Node__expandedName` = None
  `_Node__localName` = None
  `_Node__namespaceURI` = None
  `_Node__prefix` = ''
  `_Node__tagName` = ''
  `_Node__value` = None
  `_expandedName`
  `_indexInParent`()
  `_setAttributes`(attributes)
  `_setParentNode`(parent_node, index_in_parent)
  `appendChild`(new_child)
  `attributes`
  `childNodes`
  `firstChild`
  `getAttributeNS`(ns_uri, local_name)
  `getAttributeNodeNS`(ns_uri, local_name)
  `hasAttributeNS`(ns_uri, local_name)
  `localName`
  `location`
  `namespaceURI`
  `nextSibling`
  `nodeType`
  `parentNode`
  `prefix`
  `tagName`
  `value`

class `pyxb.utils.saxdom.``Text`(text, **kw)

  Bases: `pyxb.utils.saxdom._CharacterData`

class `pyxb.utils.saxdom.``_CharacterData`(node_type, **kw)

  Bases: `pyxb.utils.saxdom.Node`

  Abstract base for anything holding text data.

  `data`

class `pyxb.utils.saxdom.``_DOMSAXHandler`(**kw)

  Bases: `pyxb.utils.saxutils.BaseSAXHandler`

  SAX handler class that transforms events into a DOM tree.

  `_DOMSAXHandler__document` = None
  `document`()

    The document that is the root of the generated tree.

  `endDocument`()
  `endElementNS`(name, qname)
  `startDocument`()
  `startElementNS`(name, qname, attrs)

`pyxb.utils.saxdom.``_DumpDOM`(n, depth=0)

  Utility function to print a DOM tree.

`pyxb.utils.saxdom.``parse`(stream, **kw)

  Parse a stream containing an XML document and return the DOM tree representing its contents.

  Keywords not described here are passed to L{pyxb.utils.saxutils.make_parser}.

  @param stream: An object presenting the standard file C{read} interface from which the document can be read. The content should be data, not text.

  @keyword content_handler_constructor: Input is overridden to assign this a value of L{_DOMSAXHandler}.

  @rtype: C{xml.dom.Document}

`pyxb.utils.saxdom.``parseString`(xml_text, **kw)

  Parse a string holding an XML document and return the corresponding DOM tree.

  @param xml_text: the XML content to be parsed, in a text representation.

## pyxb.utils.saxutils module

This module contains support for processing XML using a SAX parser.

In particular, it provides a L{base content handler class<BaseSAXHandler>} that maintains namespace context and element state in a stack; and a L{base element state class <SAXElementState>} which records the location of the element in the stream. These classes are extended for specific parsing needs (e.g., L{pyxb.binding.saxer}).

class `pyxb.utils.saxutils.``BaseSAXHandler`(**kw)

  Bases: `xml.sax.handler.ContentHandler`, `object`

  A SAX handler class that maintains a stack of enclosing elements and manages namespace declarations.

  This is the base for L{pyxb.utils.saxdom._DOMSAXHandler} and L{pyxb.binding.saxer.PyXBSAXHandler}.

  `_BaseSAXHandler__elementState` = None
  `_BaseSAXHandler__elementStateConstructor` = None
  `_BaseSAXHandler__elementStateStack` = []
  `_BaseSAXHandler__fallbackNamespace` = None
  `_BaseSAXHandler__flushPendingText`()
  `_BaseSAXHandler__getOrCreateNextNamespaceContext`()
  `_BaseSAXHandler__includingContext` = None
  `_BaseSAXHandler__locationTemplate` = None
  `_BaseSAXHandler__locator` = None
  `_BaseSAXHandler__namespaceContext` = None
  `_BaseSAXHandler__nextNamespaceContext` = None
  `_BaseSAXHandler__pendingText` = None
  `_BaseSAXHandler__pendingTextLocation` = None
  `_BaseSAXHandler__rootObject` = None
  `characters`(content)

    Save the text as content

  `elementState`()
  `endElementNS`(name, qname)

    Process the completion of an element.

  `fallbackNamespace`()

    Return the namespace used to resolve unqualified names with no default namespace.

  `ignorableWhitespace`(whitespace)

    Save whitespace as content too.

  `location`()

    Return the current location within the SAX-processed document.

  `namespaceContext`()

    Return the namespace context used for QName resolution within the current element.

    @return: An instance of L{pyxb.namespace.NamespaceContext}

  `processingInstruction`(target, data)
  `reset`()

    Reset the state of the handler in preparation for processing a new document.

    @return: C{self}

  `rootObject`()

    Return the binding object corresponding to the top-most element in the document

    @return: An instance of L{basis._TypeBinding_mixin} (most usually a L{basis.complexTypeDefinition}.

  `setDocumentLocator`(locator)

    Save the locator object.

  `startDocument`()

    Process the start of a document.

    This resets this handler for a new document. @note: setDocumentLocator is invoked before startDocument

  `startElementNS`(name, qname, attrs)

    Process the start of an element.

  `startPrefixMapping`(prefix, uri)

    Implement base class method.

    @note: For this to be invoked, the C{feature_namespaces} feature must be enabled in the SAX parser.

class `pyxb.utils.saxutils.``SAXElementState`(**kw)

  Bases: `object`

  State corresponding to processing a given element with the SAX model.

  `_SAXElementState__content` = None
  `_SAXElementState__contentHandler` = None
  `_SAXElementState__expandedName` = None
  `_SAXElementState__location` = None
  `_SAXElementState__namespaceContext` = None
  `_SAXElementState__parentState` = None
  `addElementContent`(location, element, element_decl=None)

    Add the given binding instance as element content corresponding to the given use.

    @param element: Any L{binding instance<pyxb.binding.basis._TypeBinding_mixin>}.

    @param element_decl: The L{element use<pyxb.binding.content.ElementDeclaration>} in the containing complex type.

  `addTextContent`(location, content)

    Add the given text as non-element content of the current element. @type content: C{unicode} or C{str} @return: C{self}

  `content`()

    An accumulation of content to be supplied to the content model when the element end is reached.

    This is a list, with each member being C{(content, element_use, maybe_element)}. C{content} is text or a binding instance; C{element_use} is C{None} or the L{ElementDeclaration<pyxb.binding.content.ElementDeclaration>} instance used to create the content; and C{maybe_element} is C{True} iff the content is non-content text.

  `contentHandler`()

    Reference to the C{xml.sxa.handler.ContentHandler} that is processing the document.

  `expandedName`()

    The L{expanded name<pyxb.namespace.ExpandedName>} of the element.

  `location`()

    The L{location<pyxb.utils.utility.Location>} corresponding to the element event.

  `namespaceContext`()

    The L{pyxb.namespace.NamespaceContext} used for this binding.

  `parentState`()

    Reference to the SAXElementState of the element enclosing this one.

class `pyxb.utils.saxutils.``SAXInformationItem`(location, item, maybe_element, element_decl=None)

  Bases: `object`

  Class used to capture an item discovered in the body of an element.

  `element_decl` = None

    A reference to the L{ElementDeclaration<pyxb.binding.content.ElementDeclaration>} used for the L{item}. This will be C{None} for element content that does not have an enclosing CTD scope.

  `item` = None

    The item. Generally either character information (as text) or a DOM Node instance or a binding instance.

  `location` = None

    Where the item began in the document.

  `maybe_element` = None

    C{False} iff the L{item} is character information as opposed to element content.

`pyxb.utils.saxutils.``SetCreateParserModules`(create_parser_modules)

  Provide list of modules to be used when creating parsers.

  C{xml.sax.make_parser()} takes as a parameter an optional list of modules which allow customization of the parser to be used. Certain parsers have better support for Unicode than others.

  As an example, providing C{[“drv_libxml2”]} causes the libxml2 parser to be used.

  The default behavior if this function is not called, or if it is called with an empty list or C{None}, is to provide no specific modules, which will result in the system default parser (probably expat).

  @param create_parser_modules: an iterable list of names of modules that provide a C{create_parser} function. Pass C{None} to reset to the system default.

class `pyxb.utils.saxutils.``TracingSAXHandler`

  Bases: `xml.sax.handler.ContentHandler`

  A SAX handler class which prints each method invocation.

  `_TracingSAXHandler__trace` = False
  `characters`(content)
  `endElementNS`(name, qname)
  `endPrefixMapping`(prefix)
  `ignorableWhitespace`(whitespace)
  `processingInstruction`(target, data)
  `setDocumentLocator`(locator)
  `startDocument`()
  `startElementNS`(name, qname, attrs)
  `startPrefixMapping`(prefix, uri)

class `pyxb.utils.saxutils.``_EntityResolver`

  Bases: `object`

  Dummy used to prevent the SAX parser from crashing when it sees processing instructions that we don’t care about.

  `resolveEntity`(public_id, system_id)

class `pyxb.utils.saxutils.``_NoopSAXHandler`

  Bases: `xml.sax.handler.ContentHandler`

  A SAX handler class which doesn’t do anything. Used to get baseline performance parsing a particular document.

  `characters`(content)
  `endElementNS`(name, qname)
  `endPrefixMapping`(prefix)
  `ignorableWhitespace`(whitespace)
  `processingInstruction`(target, data)
  `setDocumentLocator`(locator)
  `startDocument`()
  `startElementNS`(name, qname, attrs)
  `startPrefixMapping`(prefix, uri)

`pyxb.utils.saxutils.``make_parser`(**kw)

  Extend C{xml.sax.make_parser} to configure the parser the way we need it:

  > - C{feature_namespaces} is set to C{True} so we process xmlns directives properly
  > - C{feature_namespace_prefixes} is set to C{False} so we don’t get prefixes encoded into our names (probably redundant with the above but still…)

  All keywords not documented here (and C{fallback_namespace}, which is) are passed to the C{content_handler_constructor} if that must be invoked.

  @keyword content_handler: The content handler instance for the parser to use. If not provided, an instance of C{content_handler_constructor} is created and used. @type content_handler: C{xml.sax.handler.ContentHandler}

  @keyword content_handler_constructor: A callable which produces an appropriate instance of (a subclass of) L{BaseSAXHandler}. The default is L{BaseSAXHandler}.

  @keyword fallback_namespace: The namespace to use for lookups of unqualified names in absent namespaces; see L{pyxb.namespace.ExpandedName}. This keyword is not used by this function, but is passed to the C{content_handler_constructor}. @type fallback_namespace: L{pyxb.namespace.Namespace}

## pyxb.utils.six module

Utilities for writing code that runs on Python 2 and 3

class `pyxb.utils.six.``Module_six_moves_urllib`

  Bases: `module`

  Create a six.moves.urllib namespace that resembles the Python 3 namespace

  `error` = <module 'pyxb.utils.six.moves.urllib.error'>
  `parse` = <module 'pyxb.utils.six.moves.urllib_parse'>
  `request` = <module 'pyxb.utils.six.moves.urllib.request'>
  `response` = <module 'pyxb.utils.six.moves.urllib.response'>
  `robotparser` = <module 'pyxb.utils.six.moves.urllib.robotparser'>

class `pyxb.utils.six.``Module_six_moves_urllib_error`(name)

  Bases: `pyxb.utils.six._LazyModule`

  Lazy loading of moved objects in six.moves.urllib_error

  `ContentTooShortError`
  `HTTPError`
  `URLError`
  `_moved_attributes` = [<pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>]

class `pyxb.utils.six.``Module_six_moves_urllib_parse`(name)

  Bases: `pyxb.utils.six._LazyModule`

  Lazy loading of moved objects in six.moves.urllib_parse

  `ParseResult`
  `SplitResult`
  `_moved_attributes` = [<pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>]
  `parse_qs`
  `parse_qsl`
  `quote`
  `quote_plus`
  `splitquery`
  `splittag`
  `splituser`
  `unquote`
  `unquote_plus`
  `urldefrag`
  `urlencode`
  `urljoin`
  `urlsplit`
  `urlunparse`
  `urlunsplit`
  `uses_fragment`
  `uses_netloc`
  `uses_params`
  `uses_query`
  `uses_relative`

class `pyxb.utils.six.``Module_six_moves_urllib_request`(name)

  Bases: `pyxb.utils.six._LazyModule`

  Lazy loading of moved objects in six.moves.urllib_request

  `AbstractBasicAuthHandler`
  `AbstractDigestAuthHandler`
  `BaseHandler`
  `CacheFTPHandler`
  `FTPHandler`
  `FancyURLopener`
  `FileHandler`
  `HTTPBasicAuthHandler`
  `HTTPCookieProcessor`
  `HTTPDefaultErrorHandler`
  `HTTPDigestAuthHandler`
  `HTTPErrorProcessor`
  `HTTPHandler`
  `HTTPPasswordMgr`
  `HTTPPasswordMgrWithDefaultRealm`
  `HTTPRedirectHandler`
  `HTTPSHandler`
  `OpenerDirector`
  `ProxyBasicAuthHandler`
  `ProxyDigestAuthHandler`
  `ProxyHandler`
  `Request`
  `URLopener`
  `UnknownHandler`
  `_moved_attributes` = [<pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>]
  `build_opener`
  `getproxies`
  `install_opener`
  `pathname2url`
  `proxy_bypass`
  `url2pathname`
  `urlcleanup`
  `urlopen`
  `urlretrieve`

class `pyxb.utils.six.``Module_six_moves_urllib_response`(name)

  Bases: `pyxb.utils.six._LazyModule`

  Lazy loading of moved objects in six.moves.urllib_response

  `_moved_attributes` = [<pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>]
  `addbase`
  `addclosehook`
  `addinfo`
  `addinfourl`

class `pyxb.utils.six.``Module_six_moves_urllib_robotparser`(name)

  Bases: `pyxb.utils.six._LazyModule`

  Lazy loading of moved objects in six.moves.urllib_robotparser

  `RobotFileParser`
  `_moved_attributes` = [<pyxb.utils.six.MovedAttribute object>]

class `pyxb.utils.six.``MovedAttribute`(name, old_mod, new_mod, old_attr=None, new_attr=None)

  Bases: `pyxb.utils.six._LazyDescr`

  `_resolve`()

class `pyxb.utils.six.``MovedModule`(name, old, new=None)

  Bases: `pyxb.utils.six._LazyDescr`

  `_resolve`()

class `pyxb.utils.six.``_LazyDescr`(name)

  Bases: `object`

class `pyxb.utils.six.``_LazyModule`(name)

  Bases: `module`

  `_moved_attributes` = []

class `pyxb.utils.six.``_MovedItems`(name)

  Bases: `pyxb.utils.six._LazyModule`

  Lazy loading of moved objects

  `BaseHTTPServer`
  `CGIHTTPServer`
  `SimpleHTTPServer`
  `StringIO`
  `UserDict`
  `UserList`
  `UserString`
  `_dummy_thread`
  `_moved_attributes` = [<pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedAttribute object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>, <pyxb.utils.six.MovedModule object>]
  `_thread`
  `cStringIO`
  `configparser`
  `copyreg`
  `dbm_gnu`
  `email_mime_base`
  `email_mime_multipart`
  `email_mime_nonmultipart`
  `email_mime_text`
  `file`
  `filter`
  `filterfalse`
  `getcwd`
  `getcwdb`
  `html_entities`
  `html_parser`
  `http_client`
  `http_cookiejar`
  `http_cookies`
  `input`
  `map`
  `queue`
  `range`
  `reduce`
  `reload_module`
  `reprlib`
  `shlex_quote`
  `socketserver`
  `tkinter`
  `tkinter_colorchooser`
  `tkinter_commondialog`
  `tkinter_constants`
  `tkinter_dialog`
  `tkinter_dnd`
  `tkinter_filedialog`
  `tkinter_font`
  `tkinter_messagebox`
  `tkinter_scrolledtext`
  `tkinter_simpledialog`
  `tkinter_tix`
  `tkinter_tkfiledialog`
  `tkinter_tksimpledialog`
  `tkinter_ttk`
  `urllib`
  `urllib_error`
  `urllib_parse`
  `urllib_robotparser`
  `xmlrpc_client`
  `xmlrpc_server`
  `zip`
  `zip_longest`

class `pyxb.utils.six.``_SixMetaPathImporter`(six_module_name)

  Bases: `object`

  A meta path importer to import six.moves and its submodules.

  This class implements a PEP302 finder and loader. It should be compatible with Python 2.5 and all existing versions of Python3

  `_SixMetaPathImporter__get_module`(fullname)
  `_add_module`(mod, *fullnames)
  `_get_module`(fullname)
  `find_module`(fullname, path=None)
  `get_code`(fullname)

    Return None

    Required, if is_package is implemented

  `get_source`(fullname)

    Return None

    Required, if is_package is implemented

  `is_package`(fullname)

    Return true, if the named module is a package.

    We need this method to get correct spec objects with Python 3.4 (see PEP451)

  `load_module`(fullname)

`pyxb.utils.six.``_add_doc`(func, doc)

  Add documentation to a function.

`pyxb.utils.six.``_import_module`(name)

  Import module, returning the module after the last dot.

`pyxb.utils.six.``add_metaclass`(metaclass)

  Class decorator for creating a class with a metaclass.

`pyxb.utils.six.``add_move`(move)

  Add an item to six.moves.

`pyxb.utils.six.``assertCountEqual`(self, *args, **kwargs)

`pyxb.utils.six.``assertRaisesRegex`(self, *args, **kwargs)

`pyxb.utils.six.``assertRegex`(self, *args, **kwargs)

`pyxb.utils.six.``b`(s)

  Byte literal

`pyxb.utils.six.``create_unbound_method`(func, cls)

`pyxb.utils.six.``get_unbound_function`(unbound)

  Get the function out of a possibly unbound function

`pyxb.utils.six.``int2byte`()

  S.pack(v1, v2, …) -> bytes

  Return a bytes object containing values v1, v2, … packed according to the format string S.format. See help(struct) for more on format strings.

`pyxb.utils.six.``iteritems`(d, **kw)

  Return an iterator over the (key, value) pairs of a dictionary.

`pyxb.utils.six.``iterkeys`(d, **kw)

  Return an iterator over the keys of a dictionary.

`pyxb.utils.six.``iterlists`(d, **kw)

  Return an iterator over the (key, [values]) pairs of a dictionary.

`pyxb.utils.six.``itervalues`(d, **kw)

  Return an iterator over the values of a dictionary.

`pyxb.utils.six.``python_2_unicode_compatible`(klass)

  A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing.

  To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class.

`pyxb.utils.six.``raise_from`(value, from_value)

`pyxb.utils.six.``remove_move`(name)

  Remove item from six.moves.

`pyxb.utils.six.``reraise`(tp, value, tb=None)

  Reraise an exception.

`pyxb.utils.six.``u`(s)

  Text literal

`pyxb.utils.six.``with_metaclass`(meta, *bases)

  Create a base class with a metaclass.

## pyxb.utils.templates module

Functions that aid with generating text from templates and maps.

`pyxb.utils.templates.``_bodyConditionalPattern`(match_object, dictionary)

`pyxb.utils.templates.``_bodyIfDefinedPattern`(match_object, dictionary)

`pyxb.utils.templates.``replaceInText`(text, **dictionary)

## pyxb.utils.unicode module

This module contains support for Unicode characters as required to support the regular expression syntax defined in U{annex F <http://www/Documentation/W3C/www.w3.org/TR/xmlschema-2/index.html#regexs>} of the XML Schema definition.

In particular, we need to be able to identify character properties and block escapes, as defined in F.1.1, by name.

> - Block data: U{http://www.unicode.org/Public/3.1-Update/Blocks-4.txt}
> - Property list data: U{http://www.unicode.org/Public/3.1-Update/PropList-3.1.0.txt}
> - Full dataset: U{http://www.unicode.org/Public/3.1-Update/UnicodeData-3.1.0.txt}

The Unicode database active at the time XML Schema 1.0 was defined is archived at U{http://www.unicode.org/Public/3.1-Update/UnicodeCharacterDatabase-3.1.0.html}, and refers to U{Unicode Standard Annex #27: Unicode 3.1 <http://www.unicode.org/unicode/reports/tr27/>}.

class `pyxb.utils.unicode.``CodePointSet`(*args)

  Bases: `object`

  Represent a set of Unicode code points.

  Each code point is an integral value between 0 and 0x10FFFF. This class is used to represent a set of code points in a manner suitable for use as regular expression character sets.

  `MaxCodePoint` = 1114111

    The maximum value for a code point in the Unicode code point space. This is normally 0xFFFF, because wide unicode characters are generally not enabled in Python builds. If, however, they are enabled, this will be the full value of 0x10FFFF.

  `MaxShortCodePoint` = 65535
  `_CodePointSet__XMLtoPythonREEscapedCodepoints` = (0, 94, 92, 91, 93, 45)
  `_CodePointSet__codepoints` = None
  `_CodePointSet__mutate`(value, do_add)
  `_CodePointSet__unichr`(code_point)
  `_codepoints`()

    For testing purrposes only, access to the codepoints internal representation.

  `add`(value)

    Add the given value to the code point set.

    @param value: An integral value denoting a code point, or a tuple C{(s,e)} denoting the start and end (inclusive) code points in a range. @return: C{self}

  `asPattern`(with_brackets=True)

    Return the code point set as Unicode regular expression character group consisting of a sequence of characters or character ranges.

    This returns a regular expression fragment using Python’s regular expression syntax. Note that different regular expression syntaxes are not compatible, often in subtle ways.

    @param with_brackets: If C{True} (default), square brackets are added to enclose the returned character group.

  `asSingleCharacter`()

    If this set represents a single character, return it as its unicode string value. Otherwise return C{None}.

  `asTuples`()

    Return the codepoints as tuples denoting the ranges that are in the set.

    Each tuple C{(s, e)} indicates that the code points from C{s} (inclusive) to C{e}) (inclusive) are in the set.

  `extend`(values)

    Add multiple values to a code point set.

    @param values: Either a L{CodePointSet} instance, or an iterable whose members are valid parameters to L{add}.

    @return: C{self}

  `negate`()

    Return an instance that represents the inverse of this set.

  `subtract`(value)

    Remove the given value from the code point set.

    @param value: An integral value denoting a code point, or a tuple C{(s,e)} denoting the start and end (inclusive) code points in a range, or a L{CodePointSet}.

    @return: C{self}

exception `pyxb.utils.unicode.``CodePointSetError`

  Bases: `LookupError`

  Raised when some abuse of a L{CodePointSet} is detected.

class `pyxb.utils.unicode.``XML1p0e2`

  Bases: `object`

  Regular expression support for XML Schema Data Types.

  This class holds character classes and regular expressions used to constrain the lexical space of XML Schema datatypes derived from U{string<http://www.w3.org/TR/xmlschema-2/#string>}. They are from U{XML 1.0 (Second Edition)<http://www.w3.org/TR/2000/WD-xml-2e-20000814>} and U{Namespaces in XML <http://www.w3.org/TR/1999/REC-xml-names-19990114/>}.

  Unlike the regular expressions used for pattern constraints in XML Schema, which are derived from the Unicode 3.1 specification, these are derived from the Unicode 2.0 specification.

  The XML Schema definition refers explicitly to the second edition of XML, so we have to use these code point sets and patterns. Be aware that U{subsequent updates to the XML specification <http://www.w3.org/XML/xml-V10-4e-errata#E09>} have changed the corresponding patterns for other uses of XML. One significant change is that the original specification, used here, does not allow wide unicode characters.

  `BaseChar` = <pyxb.utils.unicode.CodePointSet object>
  `Char` = <pyxb.utils.unicode.CodePointSet object>
  `CombiningChar` = <pyxb.utils.unicode.CodePointSet object>
  `Digit` = <pyxb.utils.unicode.CodePointSet object>
  `Extender` = <pyxb.utils.unicode.CodePointSet object>
  `Ideographic` = <pyxb.utils.unicode.CodePointSet object>
  `Letter` = <pyxb.utils.unicode.CodePointSet object>
  `NCNameChar` = <pyxb.utils.unicode.CodePointSet object>
  `NCNameStartChar` = <pyxb.utils.unicode.CodePointSet object>
  `NCName_pat` = '[A-Z_a-zÀ-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂ〇〡-〩ぁ-ゔァ-ヺㄅ-ㄬ一-龥가-힣][\\--.0-9A-Z_a-z·À-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁː-ˑ̀-͠ͅ-͡Ά-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁ҃-҆Ґ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆ֑-֣֡-ֹֻ-ֽֿׁ-ׂׄא-תװ-ײء-غـ-ْ٠-٩ٰ-ڷں-ھۀ-ێې-ۓە-۪ۨ-ۭ۰-۹ँ-ःअ-ह़-्॑-॔क़-ॣ०-९ঁ-ঃঅ-ঌএ-ঐও-নপ-রলশ-হ়া-ৄে-ৈো-্ৗড়-ঢ়য়-ৣ০-ৱਂਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹ਼ਾ-ੂੇ-ੈੋ-੍ਖ਼-ੜਫ਼੦-ੴઁ-ઃઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હ઼-ૅે-ૉો-્ૠ૦-૯ଁ-ଃଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହ଼-ୃେ-ୈୋ-୍ୖ-ୗଡ଼-ଢ଼ୟ-ୡ୦-୯ஂ-ஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹா-ூெ-ைொ-்ௗ௧-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హా-ౄె-ైొ-్ౕ-ౖౠ-ౡ౦-౯ಂ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಾ-ೄೆ-ೈೊ-್ೕ-ೖೞೠ-ೡ೦-೯ം-ഃഅ-ഌഎ-ഐഒ-നപ-ഹാ-ൃെ-ൈൊ-്ൗൠ-ൡ൦-൯ก-ฮะ-ฺเ-๎๐-๙ກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙༘-༙༠-༩༹༵༷༾-ཇཉ-ཀྵཱ-྄྆-ྋྐ-ྕྗྙ-ྭྱ-ྷྐྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ⃐-⃜⃡ΩK-Å℮ↀ-ↂ々〇〡-〯〱-〵ぁ-ゔ゙-゚ゝ-ゞァ-ヺー-ヾㄅ-ㄬ一-龥가-힣]*'
  `NCName_re` = re.compile('^[A-Z_a-zÀ-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ)
  `NameChar` = <pyxb.utils.unicode.CodePointSet object>
  `NameStartChar` = <pyxb.utils.unicode.CodePointSet object>
  `Name_pat` = '[:A-Z_a-zÀ-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂ〇〡-〩ぁ-ゔァ-ヺㄅ-ㄬ一-龥가-힣][\\--.0-:A-Z_a-z·À-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁː-ˑ̀-͠ͅ-͡Ά-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁ҃-҆Ґ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆ֑-֣֡-ֹֻ-ֽֿׁ-ׂׄא-תװ-ײء-غـ-ْ٠-٩ٰ-ڷں-ھۀ-ێې-ۓە-۪ۨ-ۭ۰-۹ँ-ःअ-ह़-्॑-॔क़-ॣ०-९ঁ-ঃঅ-ঌএ-ঐও-নপ-রলশ-হ়া-ৄে-ৈো-্ৗড়-ঢ়য়-ৣ০-ৱਂਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹ਼ਾ-ੂੇ-ੈੋ-੍ਖ਼-ੜਫ਼੦-ੴઁ-ઃઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હ઼-ૅે-ૉો-્ૠ૦-૯ଁ-ଃଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହ଼-ୃେ-ୈୋ-୍ୖ-ୗଡ଼-ଢ଼ୟ-ୡ୦-୯ஂ-ஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹா-ூெ-ைொ-்ௗ௧-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హా-ౄె-ైొ-్ౕ-ౖౠ-ౡ౦-౯ಂ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಾ-ೄೆ-ೈೊ-್ೕ-ೖೞೠ-ೡ೦-೯ം-ഃഅ-ഌഎ-ഐഒ-നപ-ഹാ-ൃെ-ൈൊ-്ൗൠ-ൡ൦-൯ก-ฮะ-ฺเ-๎๐-๙ກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙༘-༙༠-༩༹༵༷༾-ཇཉ-ཀྵཱ-྄྆-ྋྐ-ྕྗྙ-ྭྱ-ྷྐྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ⃐-⃜⃡ΩK-Å℮ↀ-ↂ々〇〡-〯〱-〵ぁ-ゔ゙-゚ゝ-ゞァ-ヺー-ヾㄅ-ㄬ一-龥가-힣]*'
  `Name_re` = re.compile('^[:A-Z_a-zÀ-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑ)
  `NmToken_pat` = '[\\--.0-:A-Z_a-z·À-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁː-ˑ̀-͠ͅ-͡Ά-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁ҃-҆Ґ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆ֑-֣֡-ֹֻ-ֽֿׁ-ׂׄא-תװ-ײء-غـ-ْ٠-٩ٰ-ڷں-ھۀ-ێې-ۓە-۪ۨ-ۭ۰-۹ँ-ःअ-ह़-्॑-॔क़-ॣ०-९ঁ-ঃঅ-ঌএ-ঐও-নপ-রলশ-হ়া-ৄে-ৈো-্ৗড়-ঢ়য়-ৣ০-ৱਂਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹ਼ਾ-ੂੇ-ੈੋ-੍ਖ਼-ੜਫ਼੦-ੴઁ-ઃઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હ઼-ૅે-ૉો-્ૠ૦-૯ଁ-ଃଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହ଼-ୃେ-ୈୋ-୍ୖ-ୗଡ଼-ଢ଼ୟ-ୡ୦-୯ஂ-ஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹா-ூெ-ைொ-்ௗ௧-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హా-ౄె-ైొ-్ౕ-ౖౠ-ౡ౦-౯ಂ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಾ-ೄೆ-ೈೊ-್ೕ-ೖೞೠ-ೡ೦-೯ം-ഃഅ-ഌഎ-ഐഒ-നപ-ഹാ-ൃെ-ൈൊ-്ൗൠ-ൡ൦-൯ก-ฮะ-ฺเ-๎๐-๙ກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙༘-༙༠-༩༹༵༷༾-ཇཉ-ཀྵཱ-྄྆-ྋྐ-ྕྗྙ-ྭྱ-ྷྐྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ⃐-⃜⃡ΩK-Å℮ↀ-ↂ々〇〡-〯〱-〵ぁ-ゔ゙-゚ゝ-ゞァ-ヺー-ヾㄅ-ㄬ一-龥가-힣]+'
  `NmToken_re` = re.compile('^[\\--.0-:A-Z_a-z·À-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁː-ˑ̀-͠ͅ-͡Ά-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁ҃-҆Ґ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆ֑-֣֡-ֹֻ-ֽֿׁ-ׂׄא-תװ-ײء-غـ-ْ٠-٩ٰ-ڷں-ھۀ-ێې-ۓە-۪ۨ-ۭ۰-۹ँ-ःअ-ह़-्॑-॔क़-ॣ०-९ঁ-ঃঅ-ঌএ-)
  `QName_pat` = '([A-Z_a-zÀ-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂ〇〡-〩ぁ-ゔァ-ヺㄅ-ㄬ一-龥가-힣][\\--.0-9A-Z_a-z·À-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁː-ˑ̀-͠ͅ-͡Ά-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁ҃-҆Ґ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆ֑-֣֡-ֹֻ-ֽֿׁ-ׂׄא-תװ-ײء-غـ-ْ٠-٩ٰ-ڷں-ھۀ-ێې-ۓە-۪ۨ-ۭ۰-۹ँ-ःअ-ह़-्॑-॔क़-ॣ०-९ঁ-ঃঅ-ঌএ-ঐও-নপ-রলশ-হ়া-ৄে-ৈো-্ৗড়-ঢ়য়-ৣ০-ৱਂਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹ਼ਾ-ੂੇ-ੈੋ-੍ਖ਼-ੜਫ਼੦-ੴઁ-ઃઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હ઼-ૅે-ૉો-્ૠ૦-૯ଁ-ଃଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହ଼-ୃେ-ୈୋ-୍ୖ-ୗଡ଼-ଢ଼ୟ-ୡ୦-୯ஂ-ஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹா-ூெ-ைொ-்ௗ௧-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హా-ౄె-ైొ-్ౕ-ౖౠ-ౡ౦-౯ಂ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಾ-ೄೆ-ೈೊ-್ೕ-ೖೞೠ-ೡ೦-೯ം-ഃഅ-ഌഎ-ഐഒ-നപ-ഹാ-ൃെ-ൈൊ-്ൗൠ-ൡ൦-൯ก-ฮะ-ฺเ-๎๐-๙ກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙༘-༙༠-༩༹༵༷༾-ཇཉ-ཀྵཱ-྄྆-ྋྐ-ྕྗྙ-ྭྱ-ྷྐྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ⃐-⃜⃡ΩK-Å℮ↀ-ↂ々〇〡-〯〱-〵ぁ-ゔ゙-゚ゝ-ゞァ-ヺー-ヾㄅ-ㄬ一-龥가-힣]*:)?[A-Z_a-zÀ-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હઽૠଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହଽଡ଼-ଢ଼ୟ-ୡஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡก-ฮะา-ำเ-ๅກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະາ-ຳຽເ-ໄཀ-ཇཉ-ཀྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼΩK-Å℮ↀ-ↂ〇〡-〩ぁ-ゔァ-ヺㄅ-ㄬ一-龥가-힣][\\--.0-9A-Z_a-z·À-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁː-ˑ̀-͠ͅ-͡Ά-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁ҃-҆Ґ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆ֑-֣֡-ֹֻ-ֽֿׁ-ׂׄא-תװ-ײء-غـ-ْ٠-٩ٰ-ڷں-ھۀ-ێې-ۓە-۪ۨ-ۭ۰-۹ँ-ःअ-ह़-्॑-॔क़-ॣ०-९ঁ-ঃঅ-ঌএ-ঐও-নপ-রলশ-হ়া-ৄে-ৈো-্ৗড়-ঢ়য়-ৣ০-ৱਂਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹ਼ਾ-ੂੇ-ੈੋ-੍ਖ਼-ੜਫ਼੦-ੴઁ-ઃઅ-ઋઍએ-ઑઓ-નપ-રલ-ળવ-હ઼-ૅે-ૉો-્ૠ૦-૯ଁ-ଃଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଶ-ହ଼-ୃେ-ୈୋ-୍ୖ-ୗଡ଼-ଢ଼ୟ-ୡ୦-୯ஂ-ஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-வஷ-ஹா-ூெ-ைொ-்ௗ௧-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హా-ౄె-ైొ-్ౕ-ౖౠ-ౡ౦-౯ಂ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಾ-ೄೆ-ೈೊ-್ೕ-ೖೞೠ-ೡ೦-೯ം-ഃഅ-ഌഎ-ഐഒ-നപ-ഹാ-ൃെ-ൈൊ-്ൗൠ-ൡ൦-൯ก-ฮะ-ฺเ-๎๐-๙ກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ຮະ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙༘-༙༠-༩༹༵༷༾-ཇཉ-ཀྵཱ-྄྆-ྋྐ-ྕྗྙ-ྭྱ-ྷྐྵႠ-Ⴥა-ჶᄀᄂ-ᄃᄅ-ᄇᄉᄋ-ᄌᄎ-ᄒᄼᄾᅀᅌᅎᅐᅔ-ᅕᅙᅟ-ᅡᅣᅥᅧᅩᅭ-ᅮᅲ-ᅳᅵᆞᆨᆫᆮ-ᆯᆷ-ᆸᆺᆼ-ᇂᇫᇰᇹḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ⃐-⃜⃡ΩK-Å℮ↀ-ↂ々〇〡-〯〱-〵ぁ-ゔ゙-゚ゝ-ゞァ-ヺー-ヾㄅ-ㄬ一-龥가-힣]*'
  `QName_re` = re.compile('^([A-Z_a-zÀ-ÖØ-öø-ıĴ-ľŁ-ňŊ-žƀ-ǃǍ-ǰǴ-ǵǺ-ȗɐ-ʨʻ-ˁΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϖϚϜϞϠϢ-ϳЁ-ЌЎ-яё-ќў-ҁҐ-ӄӇ-ӈӋ-ӌӐ-ӫӮ-ӵӸ-ӹԱ-Ֆՙա-ֆא-תװ-ײء-غف-يٱ-ڷں-ھۀ-ێې-ۓەۥ-ۦअ-हऽक़-ॡঅ-ঌএ-ঐও-নপ-রলশ-হড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઋઍએ-ઑ)

## pyxb.utils.unicode_data module

## pyxb.utils.utility module

Utility functions and classes.

`pyxb.utils.utility.``BackfillComparisons`(cls)

  Class decorator that fills in missing ordering methods.

  Concept derived from Python 2.7.5 functools.total_ordering, but this version requires that __eq__ and __lt__ be provided, and unconditionally overrides __ne__, __gt__, __le__, and __ge__ with the derived versions.

  This is still necessary in Python 3 because in Python 3 the comparison x >= y is done by the __ge__ inherited from object, which does not handle the case where x and y are not the same type even if the underlying y < x would convert x to be compatible.

`pyxb.utils.utility.``DataFromURI`(uri, archive_directory=None)

  Retrieve the contents of the uri as raw data.

  If the uri does not include a scheme (e.g., C{http:}), it is assumed to be a file path on the local system.

`pyxb.utils.utility.``DeconflictKeyword`(s, aux_keywords=frozenset())

  If the provided string C{s} matches a Python language keyword, append an underscore to distinguish them.

  See also L{MakeUnique}.

  @param s: string to be deconflicted

  @keyword aux_keywords: optional iterable of additional strings that should be treated as keywords.

  @rtype: C{str}

`pyxb.utils.utility.``GetMatchingFiles`(path, pattern=None, default_path_wildcard=None, default_path=None, prefix_pattern=None, prefix_substituend=None)

  Provide a list of absolute paths to files present in any of a set of directories and meeting certain criteria.

  This is used, for example, to locate namespace archive files within the archive path specified by the user. One could use:

      files = GetMatchingFiles('&bundles//:+',
                               pattern=re.compile('.*\.wxs$'),
                               default_path_wildcard='+',
                               default_path='/usr/local/pyxb/nsarchives',
                               prefix_pattern='&',
                               prefix_substituend='/opt/pyxb')

  to obtain all files that can be recursively found within C{/opt/pyxb/bundles}, or non-recursively within C{/usr/local/pyxb/nsarchives}.

  @param path: A list of directories in which the search should be performed. The entries are separated by os.pathsep, which is a colon on POSIX platforms and a semi-colon on Windows. If a path entry ends with C{//} regardless of platform, the suffix C{//} is stripped and any directory beneath the path is scanned as well, recursively.

  @keyword pattern: Optional regular expression object used to determine whether a given directory entry should be returned. If left as C{None}, all directory entries will be returned.

  @keyword default_path_wildcard: An optional string which, if present as a single directory in the path, is replaced by the value of C{default-path}.

  @keyword default_path: A system-defined directory which can be restored to the path by placing the C{default_path_wildcard} in the C{path}.

  @keyword prefix_pattern: An optional string which, if present at the start of a path element, is replaced by the value of C{prefix_substituend}.

  @keyword prefix_substituend: A system-defined string (path prefix) which can be combined with the user-provided path information to identify a file or subdirectory within an installation-specific area.

class `pyxb.utils.utility.``Graph`(root=None)

  Bases: `object`

  Represent a directed graph with arbitrary objects as nodes.

  This is used in the L{code generator<pyxb.binding.generate.Generator>} to determine order dependencies among components within a namespace, and schema that comprise various namespaces. An edge from C{source} to C{target} indicates that some aspect of C{source} requires that some aspect of C{target} already be available.

  `_Graph__dfsOrder` = None
  `_Graph__dfsWalk`(source)
  `_Graph__edgeMap` = None
  `_Graph__roots` = None
  `_Graph__scc` = None
  `_Graph__sccMap` = None
  `_Graph__sccOrder` = None
  `_generateDOT`(title='UNKNOWN', labeller=None)
  `_tarjan`(v)

    Do the work of Tarjan’s algorithm for a given root node.

  `addEdge`(source, target)

    Add a directed edge from the C{source} to the C{target}.

    The nodes are added to the graph if necessary.

  `addNode`(node)

    Add the given node to the graph.

  `addRoot`(root)

    Add the provided node as a root node, even if it has incoming edges.

    The node need not be present in the graph (if necessary, it is added).

    Note that roots added in this way do not survive a reset using L{roots}.

    @return: C{self}

  `cyclomaticComplexity`()

    Return the cyclomatic complexity of the graph.

  `dfsOrder`(reset=False)

    Return the nodes of the graph in U{depth-first-search order<http://en.wikipedia.org/wiki/Depth-first_search>}.

    The data structure is a list. Calculated lists are retained and returned on future invocations, subject to the C{reset} keyword.

    @keyword reset: If C{True}, discard cached results and recompute the order.

  `edgeMap`()

    Return the edges in the graph.

    The edge data structure is a map from the source node to the set of nodes that can be reached in a single step from the source.

  `edges`()

    Return the edges in the graph.

    The edge data structure is a set of node pairs represented as C{( source, target )}.

  `nodes`()

    Return the set of nodes in the graph.

    The node collection data structure is a set containing node objects, whatever they may be.

  `rootSetOrder`()

    Return the nodes of the graph as a sequence of root sets.

    The first root set is the set of nodes that are roots: i.e., have no incoming edges. The second root set is the set of nodes that have incoming nodes in the first root set. This continues until all nodes have been reached. The sets impose a partial order on the nodes, without being as constraining as L{sccOrder}.

    @return: a list of the root sets.

  `roots`(reset=False)

    Return the set of nodes calculated to be roots (i.e., those that have no incoming edges).

    This caches the roots calculated in a previous invocation unless the C{reset} keyword is given the value C{True}.

    @note: Upon reset, any notes that had been manually added using L{addNode} will no longer be in the set.

    @keyword reset: If C{True}, any cached value is discarded and recomputed. No effect if C{False} (defalut).

    @rtype: C{set}

  `scc`(reset=False)

    Return the strongly-connected components of the graph.

    The data structure is a set, each element of which is itself a set containing one or more nodes from the graph.

    @see: L{tarjan}.

  `sccForNode`(node, **kw)

    Return the strongly-connected component to which the given node belongs.

    Any keywords suppliend when invoking this method are passed to the L{sccMap} method.

    @return: The SCC set, or C{None} if the node is not present in the results of Tarjan’s algorithm.

  `sccMap`(reset=False)

    Return a map from nodes to the strongly-connected component to which the node belongs.

    @keyword reset: If C{True}, the L{tarjan} method will be re-invoked, propagating the C{reset} value. If C{False} (default), a cached value will be returned if available.

    @see: L{tarjan}.

  `sccOrder`(reset=False)

    Return the strongly-connected components in order.

    The data structure is a list, in dependency order, of strongly connected components (which can be single nodes). Appearance of a node in a set earlier in the list indicates that it has no dependencies on any node that appears in a subsequent set. This order is preferred over L{dfsOrder} for code generation, since it detects loops.

    @see: L{tarjan}.

  `tarjan`(reset=False)

    Execute Tarjan’s algorithm on the graph.

    U{Tarjan’s algorithm<http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm>} computes the U{strongly-connected components<http://en.wikipedia.org/wiki/Strongly_connected_component>} of the graph: i.e., the sets of nodes that form a minimal closed set under edge transition. In essence, the loops. We use this to detect groups of components that have a dependency cycle.

    @keyword reset: If C{True}, any cached component set is erased and recomputed. If C{True}, an existing previous result is left unchanged.

`pyxb.utils.utility.``HashForText`(text)

  Calculate a cryptographic hash of the given string.

  For example, this is used to verify that a given module file contains bindings from a previous generation run for the same namespace. See L{OpenOrCreate}. If the text is in Unicode, the hash is calculated on the UTF-8 encoding of the text.

  @return: A C{str}, generally a sequence of hexadecimal “digit”s.

`pyxb.utils.utility.``IteratedCompareMixed`(lhs, rhs)

  Tuple comparison that permits C{None} as lower than any value, and defines other cross-type comparison.

  @return: -1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs.

class `pyxb.utils.utility.``LocalTimeZone`

  Bases: `datetime.tzinfo`

  A C{datetime.tzinfo} subclass for the local time zone.

  Mostly pinched from the C{datetime.tzinfo} documentation in Python 2.5.1.

  `_LocalTimeZone__DSTDelta` = datetime.timedelta(0)
  `_LocalTimeZone__DSTOffset` = datetime.timedelta(0)
  `_LocalTimeZone__STDOffset` = datetime.timedelta(0)
  `_LocalTimeZone__ZeroDelta` = datetime.timedelta(0)
  `_LocalTimeZone__isDST`(dt)
  `dst`(dt)
  `tzname`(dt)
  `utcoffset`(dt)

class `pyxb.utils.utility.``Locatable_mixin`(*args, **kw)

  Bases: `pyxb.cscRoot`

  `_Locatable_mixin__location` = None
  `_location`()
  `_setLocation`(location)

class `pyxb.utils.utility.``Location`(location_base=None, line_number=None, column_number=None)

  Bases: `object`

  `_Location__cmpSingleUnlessNone`(v1, v2)
  `_Location__cmpTupleUnlessNone`(v1, v2)
  `_Location__columnNumber` = None
  `_Location__lineNumber` = None
  `_Location__locationBase` = None
  `columnNumber`
  `lineNumber`
  `locationBase`
  `newLocation`(locator=None, line_number=None, column_number=None)

`pyxb.utils.utility.``MakeIdentifier`(s, camel_case=False)

  Convert a string into something suitable to be a Python identifier.

  The string is processed by L{_XMLIdentifierToPython}. Following this, dashes, spaces, and periods are replaced by underscores, and characters not permitted in Python identifiers are stripped. Furthermore, any leading underscores are removed. If the result begins with a digit, the character ‘n’ is prepended. If the result is the empty string, the string ‘emptyString’ is substituted.

  No check is made for L{conflicts with keywords <DeconflictKeyword>}.

  @keyword camel_case : If C{True}, any underscore in the result string that is immediately followed by an alphanumeric is replaced by the capitalized version of that alphanumeric. Thus, ‘one_or_two’ becomes ‘oneOrTwo’. If C{False} (default), has no effect.

  @rtype: C{str}

`pyxb.utils.utility.``MakeModuleElement`(s)

  Convert a string into something that can be a valid element in a Python module path.

  Module path elements are similar to identifiers, but may begin with numbers and should not have leading underscores removed.

`pyxb.utils.utility.``MakeUnique`(s, in_use)

  Return an identifier based on C{s} that is not in the given set.

  The returned identifier is made unique by appending an underscore and, if necessary, a serial number.

  The order is : C{x}, C{x_}, C{x_2}, C{x_3}, …

  @param in_use: The set of identifiers already in use in the relevant scope. C{in_use} is updated to contain the returned identifier.

  @rtype: C{str}

`pyxb.utils.utility.``NormalizeLocation`(uri, parent_uri=None, prefix_map=None)

  Normalize a URI against an optional parent_uri in the way that is done for C{schemaLocation} attribute values.

  If no URI schema is present, this will normalize a file system path.

  Optionally, the resulting absolute URI can subsequently be rewritten to replace specified prefix strings with alternative strings, e.g. to convert a remote URI to a local repository. This rewriting is done after the conversion to an absolute URI, but before normalizing file system URIs.

  @param uri : The URI to normalize. If C{None}, function returns C{None}

  @param parent_uri : The base URI against which normalization is done, if C{uri} is a relative URI.

  @param prefix_map : A map used to rewrite URI prefixes. If C{None}, the value defaults to that stored by L{SetLocationPrefixRewriteMap}.

`pyxb.utils.utility.``NormalizeWhitespace`(text, preserve=False, replace=False, collapse=False)

  Normalize the given string.

  Exactly one of the C{preserve}, C{replace}, and C{collapse} keyword parameters must be assigned the value C{True} by the caller.

  > - C{preserve}: the text is returned unchanged.
  > - C{replace}: all tabs, newlines, and carriage returns are

  > replaced with ASCII spaces.

  > - C{collapse}: the C{replace} normalization is done, then

  > sequences of two or more spaces are replaced by a single space.

  See the U{whiteSpace facet<http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace>}.

  @rtype: C{str}

class `pyxb.utils.utility.``Object`

  Bases: `object`

  A dummy class used to hold arbitrary attributes.

  Essentially this gives us a map without having to worry about converting names to text to use as keys.

`pyxb.utils.utility.``OpenOrCreate`(file_name, tag=None, preserve_contents=False)

  Return a file object used to write binary data into the given file.

  Use the C{tag} keyword to preserve the contents of existing files that are not supposed to be overwritten.

  To get a writable file but leaving any existing contents in place, set the C{preserve_contents} keyword to C{True}. Normally, existing file contents are erased.

  The returned file pointer is positioned at the end of the file.

  @keyword tag: If not C{None} and the file already exists, absence of the given value in the first 4096 bytes of the file (decoded as UTF-8) causes an C{IOError} to be raised with C{errno} set to C{EEXIST}. I.e., only files with this value in the first 4KB will be returned for writing.

  @keyword preserve_contents: This value controls whether existing contents of the file will be erased (C{False}, default) or left in place (C{True}).

`pyxb.utils.utility.``PrepareIdentifier`(s, in_use, aux_keywords=frozenset(), private=False, protected=False)

  Combine everything required to create a unique identifier.

  Leading and trailing underscores are stripped from all identifiers.

  @param in_use: the set of already used identifiers. Upon return from this function, it is updated to include the returned identifier.

  @keyword aux_keywords: an optional set of additional symbols that are illegal in the given context; use this to prevent conflicts with known method names.

  @keyword private: if C{False} (default), all leading underscores are stripped, guaranteeing the identifier will not be private. If C{True}, the returned identifier has two leading underscores, making it a private variable within a Python class.

  @keyword protected: as for C{private}, but uses only one underscore.

  @rtype: C{str}

  @note: Only module-level identifiers should be treated as protected. The class-level L{_DeconflictSymbols_mixin} infrastructure does not include protected symbols. All class and instance members beginning with a single underscore are reserved for the PyXB infrastructure.

class `pyxb.utils.utility.``PrivateTransient_mixin`(*args, **kw)

  Bases: `pyxb.cscRoot`

  Emulate the B{transient} keyword from Java for private member variables.

  This class defines a C{__getstate__} method which returns a copy of C{self.__dict__} with certain members removed. Specifically, if a string “s” appears in a class member variable named C{__PrivateTransient} defined in the “Class” class, then the corresponding private variable “_Class__s” will be removed from the state dictionary. This is used to eliminate unnecessary fields from instances placed in L{namespace archives<pyxb.namespace.archive.NamespaceArchive>} without having to implement a C{__getstate__} method in every class in the instance hierarchy.

  For an example, see L{pyxb.xmlschema.structures._SchemaComponent_mixin}

  If you use this, it is your responsibility to define the C{__PrivateTransient} class variable and add to it the required variable names.

  Classes that inherit from this are free to define their own C{__getstate__} method, which may or may not invoke the superclass one. If you do this, be sure that the class defining C{__getstate__} lists L{PrivateTransient_mixin} as one of its direct superclasses, lest the latter end up earlier in the mro and consequently bypass the local override.

  `_PrivateTransient_mixin__Attribute` = '__PrivateTransient'

`pyxb.utils.utility.``QuotedEscaped`(s)

  Convert a string into a literal value that can be used in Python source.

  This just calls C{repr}. No point in getting all complex when the language already gives us what we need.

  @rtype: C{str}

`pyxb.utils.utility.``SetLocationPrefixRewriteMap`(prefix_map)

  Set the map that is used to by L{NormalizeLocation} to rewrite URI prefixes.

class `pyxb.utils.utility.``UTCOffsetTimeZone`(spec=None)

  Bases: `datetime.tzinfo`

  A C{datetime.tzinfo} subclass that helps deal with UTC conversions in an ISO8601 world.

  This class only supports fixed offsets from UTC.

  `_UTCOffsetTimeZone__Lexical_re` = re.compile('^([-+])(\\d\\d):(\\d\\d)$')
  `_UTCOffsetTimeZone__MaxOffset_td` = datetime.timedelta(0, 50400)
  `_UTCOffsetTimeZone__ZeroDuration` = datetime.timedelta(0)
  `_UTCOffsetTimeZone__otherForComparison`(other)
  `_UTCOffsetTimeZone__utcOffset_min` = 0
  `_UTCOffsetTimeZone__utcOffset_td` = None
  `dst`(dt)

    Returns a constant zero duration.

  `tzname`(dt)

    Return the name of the timezone in the format expected by XML Schema.

  `utcoffset`(dt)

    Returns the constant offset for this zone.

class `pyxb.utils.utility.``UniqueIdentifier`(uid=None)

  Bases: `object`

  Records a unique identifier, generally associated with a binding generation action.

  The identifier is a string, but gets wrapped in an instance of this class to optimize comparisons and reduce memory footprint.

  Invoking the constructor for this class on the same string multiple times will return the same Python object.

  An instance of this class compares equal to, and hashes equivalent to, the uid string. When C{str}’d, the result is the uid; when C{repr}’d, the result is a constructor call to C{pyxb.utils.utility.UniqueIdentifier}.

  `_UniqueIdentifier__ExistingUIDs` = {'PyXB-1.2.6-Builtin': pyxb.utils.utility.UniqueIdentifier('PyXB-1.2.6-Builtin')}
  `_UniqueIdentifier__associatedObjects` = None
  `_UniqueIdentifier__uid` = None
  `associateObject`(obj)

    Associate the given object witth this identifier.

    This is a one-way association: the object is not provided with a return path to this identifier instance.

  `associatedObjects`()

    The set of objects that have been associated with this identifier instance.

  `uid`()

    The string unique identifier

class `pyxb.utils.utility.``_DeconflictSymbols_mixin`

  Bases: `object`

  Mix-in used to deconflict public symbols in classes that may be inherited by generated binding classes.

  Some classes, like the L{pyxb.binding.basis.element} or L{pyxb.binding.basis.simpleTypeDefinition} classes in L{pyxb.binding.basis}, have public symbols associated with functions and variables. It is possible that an XML schema might include tags and attribute names that match these symbols. To avoid conflict, the reserved symbols marked in this class are added to the pre-defined identifier set.

  Subclasses should create a class-level variable C{_ReservedSymbols} that contains a set of strings denoting the symbols reserved in this class, combined with those from any superclasses that also have reserved symbols. Code like the following is suggested:

      # For base classes (direct mix-in):
      _ReservedSymbols = set([ 'one', 'two' ])
      # For subclasses:
      _ReservedSymbols = SuperClass._ReservedSymbols.union(set([ 'three' ]))

  Only public symbols (those with no underscores) are currently supported. (Private symbols can’t be deconflicted that easily, and no protected symbols that derive from the XML are created by the binding generator.)

  `_ReservedSymbols` = set()

    There are no reserved symbols in the base class.

`pyxb.utils.utility.``_DefaultXMLIdentifierToPython`(identifier)

  Default implementation for _XMLIdentifierToPython

  For historical reasons, this converts the identifier from a str to unicode in the system default encoding. This should have no practical effect.

  @param identifier : some XML identifier

  @return: C{unicode(identifier)}

`pyxb.utils.utility.``_Keywords` = frozenset({'False', 'finally', 'if', 'True', 'NotImplemented', 'while', '__debug__', 'from', 'yield', 'or', 'return', 'pass', 'for', 'def', 'continue', 'assert', 'set', 'not', 'class', 'except', 'raise', 'elif', 'del', 'with', 'break', 'None', 'Ellipsis', 'try', 'and', 'in', 'print', 'exec', 'global', 'is', 'lambda', 'import', 'else', 'as'})

  The keywords reserved for Python, derived from L{_PythonKeywords} and L{_PythonBuiltInConstants}.

`pyxb.utils.utility.``_NewUUIDString`()

  Obtain a UUID using the best available method. On a version of python that does not incorporate the C{uuid} class, this creates a string combining the current date and time (to the second) with a random number.

  @rtype: C{str}

`pyxb.utils.utility.``_PythonBuiltInConstants` = frozenset({'False', 'True', 'NotImplemented', 'None', '__debug__', 'Ellipsis', 'set'})

  Other symbols that aren’t keywords but that can’t be used.

  @see: U{http://docs.python.org/library/constants.html}.

`pyxb.utils.utility.``_PythonKeywords` = frozenset({'while', 'yield', 'or', 'return', 'for', 'continue', 'class', 'raise', 'elif', 'del', 'with', 'try', 'in', 'print', 'global', 'import', 'as', 'finally', 'if', 'from', 'pass', 'def', 'assert', 'not', 'except', 'break', 'and', 'exec', 'is', 'lambda', 'else'})

  Python keywords. Note that types like int and float are not keywords.

  @see: U{http://docs.python.org/reference/lexical_analysis.html#keywords}.

`pyxb.utils.utility.``_SetXMLIdentifierToPython`(xml_identifier_to_python)

  Configure a callable L{MakeIdentifier} uses to pre-process an XM Lidentifier.

  In Python3, identifiers can be full Unicode tokens, but in Python2, all identifiers must be ASCII characters. L{MakeIdentifier} enforces this by removing all characters that are not valid within an identifier.

  In some cases, an application generating bindings may be able to transliterate Unicode code points that are not valid Python identifier characters into something else. This callable can be assigned to perform that translation before the invalid characters are stripped.

  For example, see unidecode and this forum posting.

  It is not the responsibility of this callable to do anything other than replace whatever characters it wishes to. All transformations performed by L{MakeIdentifier} will still be applied, to ensure the output is in fact a legal identifier.

  @param xml_identifier_to_python : A callable that takes a string and returns a Unicode, possibly with non-identifier characters replaced by other characters. Pass C{None} to reset to the default implementation, which is L{_DefaultXMLIdentifierToPython}.

  @rtype: C{unicode}

`pyxb.utils.utility.``_XMLIdentifierToPython`(identifier)

  Default implementation for _XMLIdentifierToPython

  For historical reasons, this converts the identifier from a str to unicode in the system default encoding. This should have no practical effect.

  @param identifier : some XML identifier

  @return: C{unicode(identifier)}

`pyxb.utils.utility.``repr2to3`(v)

  Filtered built-in repr for python 2/3 compatibility in generated bindings.

  All generated string values are to be unicode. We always import unicode_literals from __future__, so we want plain quotes with no prefix u. Strip that off.

  Integer constants should not have the suffix L even if they do not fit in a Python2 int. The references generated through this function are never used for calculations, so the implicit cast to a larger type is sufficient.

  All other values use their standard representations.

## pyxb.utils.xmlre module

Support for regular expressions conformant to the XML Schema specification.

For the most part, XML regular expressions are similar to the POSIX ones, and can be handled by the Python C{re} module. The exceptions are for multi-character (C{w}) and category escapes (e.g., C{p{N}} or C{p{IPAExtensions}}) and the character set subtraction capability. This module supports those by scanning the regular expression, replacing the category escapes with equivalent charset expressions. It further detects the subtraction syntax and modifies the charset expression to remove the unwanted code points.

The basic technique is to step through the characters of the regular expression, entering a recursive-descent parser when one of the translated constructs is encountered.

There is a nice set of XML regular expressions at U{http://www.xmlschemareference.com/examples/Ch14/regexpDemo.xsd}, with a sample document at U{ http://www.xmlschemareference.com/examples/Ch14/regexpDemo.xml}

`pyxb.utils.xmlre.``MaybeMatchCharacterClass`(text, position)

  Attempt to match a U{character class expression <http://www.w3.org/TR/xmlschema-2/#nt-charClassExpr>}.

  @param text: The complete text of the regular expression being translated

  @param position: The offset of the start of the potential expression.

  @return: C{None} if C{position} does not begin a character class expression; otherwise a pair C{(cps, p)} where C{cps} is a L{pyxb.utils.unicode.CodePointSet} containing the code points associated with the property, and C{p} is the text offset immediately following the closing brace.

exception `pyxb.utils.xmlre.``RegularExpressionError`(position, description)

  Bases: `ValueError`

  Raised when a regular expression cannot be processed..

`pyxb.utils.xmlre.``XMLToPython`(pattern)

  Convert the given pattern to the format required for Python regular expressions.

  @param pattern: A Unicode string defining a pattern consistent with U{XML regular expressions<http://www.w3.org/TR/xmlschema-2/index.html#regexs>}.

  @return: A Unicode string specifying a Python regular expression that matches the same language as C{pattern}.

`pyxb.utils.xmlre.``_InitializeAllEsc`()

  Set the values in _AllEsc without introducing C{k} and C{v} into the module.

`pyxb.utils.xmlre.``_MatchCharClassEsc`(text, position)

  Parse a U{charClassEsc<http://www.w3.org/TR/xmlschema-2/#nt-charClassEsc>} term.

  This is one of:

  > - U{SingleCharEsc<http://www.w3.org/TR/xmlschema-2/#nt-SingleCharEsc>},

  > an escaped single character such as C{E{}n}

  > - U{MultiCharEsc<http://www.w3.org/TR/xmlschema-2/#nt-MultiCharEsc>},

  > an escape code that can match a range of characters, e.g. C{E{}s} to match certain whitespace characters

  > - U{catEsc<http://www.w3.org/TR/xmlschema-2/#nt-catEsc>}, the

  > C{E{}pE{lb}…E{rb}} Unicode property escapes including categories and blocks

  > - U{complEsc<http://www.w3.org/TR/xmlschema-2/#nt-complEsc>},

  > the C{E{}PE{lb}…E{rb}} inverted Unicode property escapes

  If the parsing fails, throws a RegularExpressionError.

  @return: A pair C{(cps, p)} where C{cps} is a L{pyxb.utils.unicode.CodePointSet} containing the code points associated with the character class, and C{p} is the text offset immediately following the escape sequence.

  @raise RegularExpressionError: if the expression is syntactically invalid.

`pyxb.utils.xmlre.``_MatchCharClassExpr`(text, position)

  Parse a U{charClassExpr<http://www.w3.org/TR/xmlschema-2/#nt-charClassExpr>}.

  These are XML regular expression classes such as C{[abc]}, C{[a-c]}, C{[^abc]}, or C{[a-z-[q]]}.

  @param text: The complete text of the regular expression being translated. The first character must be the C{[} starting a character class.

  @param position: The offset of the start of the character group.

  @return: A pair C{(cps, p)} where C{cps} is a L{pyxb.utils.unicode.CodePointSet} containing the code points associated with the property, and C{p} is the text offset immediately following the closing brace.

  @raise RegularExpressionError: if the expression is syntactically invalid.

`pyxb.utils.xmlre.``_MatchPosCharGroup`(text, position)

  Parse a U{posCharGroup<http://www.w3.org/TR/xmlschema-2/#nt-posCharGroup>} term.

  @return: A tuple C{(cps, fs, p)} where:
    - C{cps} is a L{pyxb.utils.unicode.CodePointSet} containing the code points associated with the group;
    - C{fs} is a C{bool} that is C{True} if the next character is the C{-} in a U{charClassSub<http://www.w3.org/TR/xmlschema-2/#nt-charClassSub>} and C{False} if the group is not part of a charClassSub;
    - C{p} is the text offset immediately following the closing brace.

  @raise RegularExpressionError: if the expression is syntactically invalid.

## Module contents

pyxb.utils – Utilities for the PyWXSB package.