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 None, and the second is a QName to be used for the expanded name within this document.

Parameters:node – An xml.dom.Node instance, presumably from a wildcard match.
Return type:( str, str )
addAttribute(element, expanded_name, value)

Add an attribute to the given element.

Parameters:
  • element (xml.dom.Element) – The element to which the attribute should be added
  • expanded_name – The name of the attribute. This may be a local

name if the attribute is not in a namespace. :type expanded_name: pyxb.namespace.Namespace or str or unicode :param value: The value of the attribute :type value: str or unicode

addXMLNSDeclaration(element, namespace, prefix=None)

Manually add an XMLNS declaration to the document element.

Parameters:

None, the default prefix as previously declared will be used; if '' (empty string) a declaration for namespace as the default namespace will be generated.

Returns: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.

Parameters:
  • child (xml.dom.Node) – The value to be appended
  • parent (xml.dom.Node) – The new parent of the child
Return type:

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., pyxb.utils.saxdom) into another (e.g., xml.dom.minidom).

createChildElement(expanded_name, parent=None)

Create a new element node in the tree.

Parameters:expanded_name – The name of the element. A plain string

indicates a name in no namespace. :type expanded_name: pyxb.namespace.ExpandedName or str or unicode

Parameters:parent – The node in the tree that will serve as the child’s

parent. If None, the document element is used. (If there is no document element, then this call creates it as a side-effect.)

Returns:A newly created DOM element
Return type: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.

Returns:The document that has been created.
Return type:xml.dom.Document
implementation()

The DOMImplementation object to be used.

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

namespacePrefix(namespace, enable_default_namespace=True)

Return the prefix to be used for the given namespace.

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

Parameters:namespace – The namespace for which a prefix is needed. If the

provided namespace is None or an absent namespace, the None value will be returned as the corresponding prefix.

Parameters:enable_default_namespace – Normally if the namespace is the default

namespace None is returned to indicate this. If this keyword is 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 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 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.

Return type:unicode or 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 node has an ELEMENT_NODE child that is not an XMLSchema annotation node.

Return type:bool
pyxb.utils.domutils.LocateFirstChildElement(node, absent_ok=True, require_unique=False, ignore_annotations=True)

Locate the first element child of the node.

Parameters:
  • node – An a xml.dom.Node ELEMENT_NODE instance.
  • absent_ok – If True (default), None is returned if no match

can be found. If False, an exception is raised if no match can be found. :keyword require_unique: If False (default), it is acceptable for there to be multiple child elements. If True, presence of multiple child elements raises an exception. :keyword ignore_annotations: If True (default), annotations are skipped wheen looking for the first child element. If False, an annotation counts as an element. :rtype: xml.dom.Node

Raises:SchemaValidationErrorabsent_ok is False and no child

element was identified. :raise SchemaValidationError: require_unique is 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.

Parameters:
  • node – An a xml.dom.Node ELEMENT_NODE instance.
  • 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.

Return type: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 tag are found, or absent_ok is False and no matching tag is found, an exception is raised.

Parameters:
  • node – An a xml.dom.Node ELEMENT_NODE instance
  • tag – the NCName of an element in the namespace
  • absent_ok – If True (default), None is returned if no match

can be found. If 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: xml.dom.Node

Raises:
  • pyxb.SchemaValidationError – multiple elements are identified
  • pyxb.SchemaValidationErrorabsent_ok is 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.

Parameters:
  • attribute_ncname (str or unicode) – The local name of the attribute.
  • attribute_ns – The namespace of the attribute. Defaults to None

since most attributes are not in a namespace. Can be provided as either a pyxb.namespace.Namespace instance, or a string URI. :type attribute_ns: None or str or unicode or pyxb.namespace.Namespace

Returns:The value of the attribute, or None if the attribute is not

present. (Unless None, the value will always be a (unicode) string.)

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

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

Parameters:
Returns:

The expanded name to which the value of the attribute resolves

given current namespaces, or None if the attribute is not present :rtype: 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: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 wildcard elements. A numerical constraint node corresponds to an L{XML particle <pyxb.xmlschema.structures.Particle>}, and choice and sequence nodes derive from model groups 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 cloned as required to satisfy the tree requirements of the term tree.

Parameters:terms – The tuple of terms that are elements of an

accepted sequence.

Returns: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 State instance for which this is a sub-automaton.

None if this is not a sub-automaton.

_Automaton__get_counterConditions()

The set of :py:obj:`CounterCondition`s in the automaton.

These are marked positions in the regular expression, or particles in an XML schema, paired with their occurrence constraints.

_Automaton__get_finalStates()

The set of 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 State.transitionSet, the set is represented

as a list to preserve priority when resolving non-deterministic matches.

_Automaton__get_nullable()

True iff the automaton accepts the empty string.

_Automaton__get_states()

The set of :py:obj:`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 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 State instance for which this is a sub-automaton.

None if this is not a sub-automaton.

counterConditions

The set of :py:obj:`CounterCondition`s in the automaton.

These are marked positions in the regular expression, or particles in an XML schema, paired with their occurrence constraints.

finalStates

The set of 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 State.transitionSet, the set is represented

as a list to preserve priority when resolving non-deterministic matches.

newConfiguration()

Return a new Configuration instance for this automaton.

nullable

True iff the automaton accepts the empty string.

states

The set of :py:obj:`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 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: exceptions.Exception

Symbol rejected by Configuration_ABC.step.

The exception indicates that the proposed symbol either failed to produce a transition (UnrecognizedSymbolError) or produced multiple equally valid transitions (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 Configuration_ABC that raised the exception. From 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 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 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.

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 unordered catenation 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.

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
_clone(clone_map, super_configuration)
_get_counterValues()
_set_state(state, is_layer_change)

Internal state transition interface.

Parameters:
  • state – the new destination state
  • is_layer_changeTrue 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 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.

Parameters:symbol – A symbol through which a transition from this

state is intended. A value of None indicates that the set of transitions should ignore the symbol; candidates are still filtered based on the counter state of the configuration.

Returns:A list of Transition instances permitted from the

current configuration. If symbol is not 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.

Parameters: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.

Parameters:automaton – The automaton to be entered
Returns:The configuration that executes the new automaton as

a sub-configuration of self.

isAccepting()

Return True iff the automaton is in an accepting state.

isInitial()

Return True iff no transitions have ever been made.

leaveAutomaton(sub_configuration)

Execute steps to leave a sub-automaton.

Parameters:sub_configuration – The configuration associated with

the automata that has completed.

Returns: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 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.

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 unordered catenation 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.

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 Automaton in execution.

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

For non-deterministic automata, this is a MultiConfiguration which records a set of :py:obj:`Configuration`s.

acceptableSymbols()

Return the acceptable :py:obj:`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.

Parameters:symbol – A symbol from the alphabet of the automaton’s

language. This is a Python value that should be accepted by the SymbolMatch_mixin.match method of a State.symbol. It is not a Symbol instance.

Returns:The new configuration resulting from the step.
Raises:AutomatonStepErrorUnrecognizedSymbolError

when no transition compatible with symbol is available, and NondeterministicSymbolError if symbol admits multiple transitions and the subclass does not support non-deterministic steps (see 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 metadata.

_CounterCondition__get_max()

The maximum legal value for the counter.

This is a positive integer, or 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 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: exceptions.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 Symbol node appears multiple times, or a cycle is detected.

parent = None

The MultiTermNode containing the term that proves invalidity

term = None

The 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 UnrecognizedSymbolError be raised. If a step admits multiple valid transitions, a configuration is added for each one.

See 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} (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} (psi) is a map from positions to either Node.RESET or 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 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()

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 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 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 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 nullable for the subclass.

The return value should be True or False.

_walkTermTree(position, pre, post, arg)

Abstract method implementing 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.

Parameters:args – A tuple of arguments to be passed to the instance

constructor.

Parameters:kw – A dict of keywords to be passed to the instance

constructor.

Note:Subclasses should pre-extend this method to augment the

args and kw parameters as necessary to match the expectations of the __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 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 counterPositions that occur along the path to 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

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 metadata link, or any existing structural data.

walkTermTree(pre, post, arg)

Utility function for term tree processing.

Parameters:pre – a callable that, unless None, is invoked at

each node n with parameters n, pos, and arg, where 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.

Parameters:post – as with pre but invocation occurs after

processing any subordinate nodes.

Parameters:arg – a value passed to invocations of pre and

post.

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

Bases: pyxb.utils.fac.AutomatonStepError

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 State wrapper is provided to maintain distinct values.

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

Link to the 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()

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 None unless isUnorderedCatenation is True.

_State__get_symbol()

Application-specific metadata identifying the symbol.

See also match.

_State__get_transitionSet()

Definitions of viable transitions from this state.

The transition set of a state is a set of 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 unordered catenation of terms, 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.)

Parameters:transition_set – a list of pairs where the first

member is the destination State and the second member is the set of :py:obj:`UpdateInstruction`s that apply when the automaton transitions to the destination state.

automaton

Link to the 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)

True iff this state is an accepting state for the automaton.

Parameters:counter_values – Counter values that further validate

whether the requirements of the automaton have been met.

Returns:True if this is an accepting state and the

counter values relevant at it are satisfied.

isInitial

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 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 SymbolMatch_mixin, then its match method will be used. Otherwise symbol matches only if it is equal to the symbol of this state.

Parameters:symbol – A candidate symbol corresponding to the

expression symbol for this state.

Returns:True iff symbol is a match for this state.
subAutomata

A sequence of sub-automata supporting internal state transitions.

This will return None unless isUnorderedCatenation is True.

subAutomataInitialTransitions(sub_automata=None)

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

Parameters:sub_automata – A subset of the sub-automata of this

state which should contribute to the result. If None, all sub-automata are used.

Returns:A pair (nullable, transitions) where nullable

is True iff there is at least one sub-automaton that is in an accepting state on entry, and transitions is a list of 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 match.

transitionSet

Definitions of viable transitions from this state.

The transition set of a state is a set of 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 unordered catenation of terms, 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 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 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.

A directive relating to changing automaton layer on transition.

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

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

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

_Transition__get_nextTransition()

The next transition to apply in this chain.

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__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)
Parameters:

Configuration reflecting the replacements made when the configuration for which the transition was calculated was subsequently cloned into the configuration passed into this method. This is only necessary when the transition includes layer transitions.

Returns: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.

Parameters:next_transition – A Transition node describing a

subsequent transition.

Returns:a clone of this node, augmented with a link to

next_transition.

consumedSymbol()

Return the symbol of the consumingState.

consumingState()

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

destination

The transition destination state.

A directive relating to changing automaton layer on transition.

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

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

An instance of Automaton requires creation of a sub-configuration and initial entry into the automaton. The 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.

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.

Parameters:configuration – A Configuration instance containing

counter data against which update instruction satisfaction is checked.

Returns: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

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 UpdateInstruction with an unsatisfied CounterCondition

values = None

The unsatisfying value map from CounterCondition instances to integers

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

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.

Parameters:update_instructions – A set of UpdateInstruction

instances.

Parameters:counter_values – A map from CounterCondition

instances to non-negative integers. This map is updated in-place by applying each instruction in update_instructions.

classmethod Satisfies(counter_values, update_instructions)

Return True iff the counter values satisfy the update instructions.

Parameters:counter_values – A map from CounterCondition to

integer counter values

Parameters:update_instructions – A set of UpdateInstruction

instances

Returns:True iff all instructions are satisfied by the

values and limits.

_UpdateInstruction__counterCondition = None
_UpdateInstruction__doIncrement = None
_UpdateInstruction__get_counterCondition()

A reference to the 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()

True if the counter is to be incremented; 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.

Parameters:counter_values – A map from CounterCondition to

integer counter values. This map is updated in-place.

counterCondition

A reference to the CounterCondition identifying the counter to be updated.

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

doIncrement

True if the counter is to be incremented; 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.

Parameters:counter_values – A map from :py:obj:`CounterCondition`s to

non-negative integers

Returns:True or 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 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 pyxb.utils.saxutils.make_parser.

Parameters:stream – An object presenting the standard file read interface

from which the document can be read. The content should be data, not text.

Parameters:content_handler_constructor – Input is overridden to assign this a

value of _DOMSAXHandler.

Return type:xml.dom.Document
pyxb.utils.saxdom.parseString(xml_text, **kw)

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

Parameters: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 base content handler class 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., 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 pyxb.utils.saxdom._DOMSAXHandler and 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.

Returns:An instance of pyxb.namespace.NamespaceContext
processingInstruction(target, data)
reset()

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

Returns:self
rootObject()

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

Returns:An instance of basis._TypeBinding_mixin (most usually a

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 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.

Parameters:

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: unicode or str :return: 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)}. content is text or a binding instance; element_use is None or the ElementDeclaration instance used to create the content; and maybe_element is True iff the content is non-content text.

contentHandler()

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

expandedName()

The expanded name of the element.

location()

The location corresponding to the element event.

namespaceContext()

The 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 ElementDeclaration used for the item. This will be 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

False iff the 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.

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 ["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 None, is to provide no specific modules, which will result in the system default parser (probably expat).

Parameters:create_parser_modules – an iterable list of names of modules that

provide a create_parser function. Pass 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 xml.sax.make_parser to configure the parser the way we need it:

  • feature_namespaces is set to True so we process xmlns directives properly
  • feature_namespace_prefixes is set to False so we don’t get prefixes encoded into our names (probably redundant with the above but still...)

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

Parameters:content_handler – The content handler instance for the

parser to use. If not provided, an instance of content_handler_constructor is created and used. :type content_handler: xml.sax.handler.ContentHandler

Parameters:content_handler_constructor – A callable which produces an

appropriate instance of (a subclass of) BaseSAXHandler. The default is BaseSAXHandler.

Parameters:fallback_namespace – The namespace to use for lookups of

unqualified names in absent namespaces; see pyxb.namespace.ExpandedName. This keyword is not used by this function, but is passed to the content_handler_constructor. :type fallback_namespace: pyxb.namespace.Namespace

pyxb.utils.six module

Utilities for writing code that runs on Python 2 and 3

class pyxb.utils.six.Iterator

Bases: object

next()
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' (built-in)>
parse = <module 'pyxb.utils.six.moves.urllib_parse' (built-in)>
request = <module 'pyxb.utils.six.moves.urllib.request' (built-in)>
response = <module 'pyxb.utils.six.moves.urllib.response' (built-in)>
robotparser = <module 'pyxb.utils.six.moves.urllib.robotparser' (built-in)>
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.byte2int(bs)
pyxb.utils.six.create_bound_method(func, obj)
pyxb.utils.six.create_unbound_method(func, cls)
pyxb.utils.six.exec_(_code_, _globs_=None, _locs_=None)

Execute code in a namespace.

pyxb.utils.six.get_unbound_function(unbound)

Get the function out of a possibly unbound function

pyxb.utils.six.indexbytes(buf, i)
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.print_(*args, **kwargs)
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.six.wraps(wrapped, assigned=('__module__', '__name__', '__doc__'), updated=('__dict__', ))

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.

The Unicode database active at the time XML Schema 1.0 was defined is archived at 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.

Parameters:value – An integral value denoting a code point, or a

tuple (s,e) denoting the start and end (inclusive) code points in a range. :return: 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.

Parameters:with_brackets – If 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 None.

asTuples()

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

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

extend(values)

Add multiple values to a code point set.

Parameters:values – Either a CodePointSet instance, or an iterable

whose members are valid parameters to add.

Returns:self
negate()

Return an instance that represents the inverse of this set.

subtract(value)

Remove the given value from the code point set.

Parameters:value – An integral value denoting a code point, or a tuple

(s,e) denoting the start and end (inclusive) code points in a range, or a CodePointSet.

Returns:self
exception pyxb.utils.unicode.CodePointSetError

Bases: exceptions.LookupError

Raised when some abuse of a 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 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 = u'[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3007\u3021-\u3029\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3][\\--.0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u02d0-\u02d1\u0300-\u0345\u0360-\u0361\u0386-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0483-\u0486\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u0652\u0660-\u0669\u0670-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5-\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0901-\u0903\u0905-\u0939\u093c-\u094d\u0951-\u0954\u0958-\u0963\u0966-\u096f\u0981-\u0983\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09dc-\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a02\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a59-\u0a5c\u0a5e\u0a66-\u0a74\u0a81-\u0a83\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae0\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3c-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b5c-\u0b5d\u0b5f-\u0b61\u0b66-\u0b6f\u0b82-\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be7-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c60-\u0c61\u0c66-\u0c6f\u0c82-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0cde\u0ce0-\u0ce1\u0ce6-\u0cef\u0d02-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d60-\u0d61\u0d66-\u0d6f\u0e01-\u0e2e\u0e30-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18-\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f69\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u20d0-\u20dc\u20e1\u2126\u212a-\u212b\u212e\u2180-\u2182\u3005\u3007\u3021-\u302f\u3031-\u3035\u3041-\u3094\u3099-\u309a\u309d-\u309e\u30a1-\u30fa\u30fc-\u30fe\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3]*'
NCName_re = <_sre.SRE_Pattern object at 0x3bd73f0>
NameChar = <pyxb.utils.unicode.CodePointSet object>
NameStartChar = <pyxb.utils.unicode.CodePointSet object>
Name_pat = u'[:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3007\u3021-\u3029\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3][\\--.0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u02d0-\u02d1\u0300-\u0345\u0360-\u0361\u0386-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0483-\u0486\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u0652\u0660-\u0669\u0670-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5-\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0901-\u0903\u0905-\u0939\u093c-\u094d\u0951-\u0954\u0958-\u0963\u0966-\u096f\u0981-\u0983\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09dc-\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a02\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a59-\u0a5c\u0a5e\u0a66-\u0a74\u0a81-\u0a83\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae0\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3c-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b5c-\u0b5d\u0b5f-\u0b61\u0b66-\u0b6f\u0b82-\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be7-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c60-\u0c61\u0c66-\u0c6f\u0c82-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0cde\u0ce0-\u0ce1\u0ce6-\u0cef\u0d02-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d60-\u0d61\u0d66-\u0d6f\u0e01-\u0e2e\u0e30-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18-\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f69\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u20d0-\u20dc\u20e1\u2126\u212a-\u212b\u212e\u2180-\u2182\u3005\u3007\u3021-\u302f\u3031-\u3035\u3041-\u3094\u3099-\u309a\u309d-\u309e\u30a1-\u30fa\u30fc-\u30fe\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3]*'
Name_re = <_sre.SRE_Pattern object at 0x3bd27a0>
NmToken_pat = u'[\\--.0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u02d0-\u02d1\u0300-\u0345\u0360-\u0361\u0386-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0483-\u0486\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u0652\u0660-\u0669\u0670-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5-\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0901-\u0903\u0905-\u0939\u093c-\u094d\u0951-\u0954\u0958-\u0963\u0966-\u096f\u0981-\u0983\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09dc-\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a02\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a59-\u0a5c\u0a5e\u0a66-\u0a74\u0a81-\u0a83\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae0\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3c-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b5c-\u0b5d\u0b5f-\u0b61\u0b66-\u0b6f\u0b82-\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be7-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c60-\u0c61\u0c66-\u0c6f\u0c82-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0cde\u0ce0-\u0ce1\u0ce6-\u0cef\u0d02-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d60-\u0d61\u0d66-\u0d6f\u0e01-\u0e2e\u0e30-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18-\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f69\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u20d0-\u20dc\u20e1\u2126\u212a-\u212b\u212e\u2180-\u2182\u3005\u3007\u3021-\u302f\u3031-\u3035\u3041-\u3094\u3099-\u309a\u309d-\u309e\u30a1-\u30fa\u30fc-\u30fe\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3]+'
NmToken_re = <_sre.SRE_Pattern object at 0x425ff10>
QName_pat = u'([A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3007\u3021-\u3029\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3][\\--.0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u02d0-\u02d1\u0300-\u0345\u0360-\u0361\u0386-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0483-\u0486\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u0652\u0660-\u0669\u0670-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5-\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0901-\u0903\u0905-\u0939\u093c-\u094d\u0951-\u0954\u0958-\u0963\u0966-\u096f\u0981-\u0983\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09dc-\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a02\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a59-\u0a5c\u0a5e\u0a66-\u0a74\u0a81-\u0a83\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae0\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3c-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b5c-\u0b5d\u0b5f-\u0b61\u0b66-\u0b6f\u0b82-\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be7-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c60-\u0c61\u0c66-\u0c6f\u0c82-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0cde\u0ce0-\u0ce1\u0ce6-\u0cef\u0d02-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d60-\u0d61\u0d66-\u0d6f\u0e01-\u0e2e\u0e30-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18-\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f69\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u20d0-\u20dc\u20e1\u2126\u212a-\u212b\u212e\u2180-\u2182\u3005\u3007\u3021-\u302f\u3031-\u3035\u3041-\u3094\u3099-\u309a\u309d-\u309e\u30a1-\u30fa\u30fc-\u30fe\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3]*:)?[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3007\u3021-\u3029\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3][\\--.0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u02d0-\u02d1\u0300-\u0345\u0360-\u0361\u0386-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0483-\u0486\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u0652\u0660-\u0669\u0670-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5-\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0901-\u0903\u0905-\u0939\u093c-\u094d\u0951-\u0954\u0958-\u0963\u0966-\u096f\u0981-\u0983\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09dc-\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a02\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a59-\u0a5c\u0a5e\u0a66-\u0a74\u0a81-\u0a83\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae0\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3c-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b5c-\u0b5d\u0b5f-\u0b61\u0b66-\u0b6f\u0b82-\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be7-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c60-\u0c61\u0c66-\u0c6f\u0c82-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0cde\u0ce0-\u0ce1\u0ce6-\u0cef\u0d02-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d60-\u0d61\u0d66-\u0d6f\u0e01-\u0e2e\u0e30-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18-\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f69\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u20d0-\u20dc\u20e1\u2126\u212a-\u212b\u212e\u2180-\u2182\u3005\u3007\u3021-\u302f\u3031-\u3035\u3041-\u3094\u3099-\u309a\u309d-\u309e\u30a1-\u30fa\u30fc-\u30fe\u3105-\u312c\u4e00-\u9fa5\uac00-\ud7a3]*'
QName_re = <_sre.SRE_Pattern object at 0x4276480>

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., 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 s matches a Python language keyword, append an underscore to distinguish them.

See also MakeUnique.

Parameters:
  • s – string to be deconflicted
  • aux_keywords – optional iterable of additional strings

that should be treated as keywords.

Return type: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 /opt/pyxb/bundles, or non-recursively within /usr/local/pyxb/nsarchives.

Parameters: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 // regardless of platform, the suffix // is stripped and any directory beneath the path is scanned as well, recursively.

Parameters:pattern – Optional regular expression object used to

determine whether a given directory entry should be returned. If left as None, all directory entries will be returned.

Parameters:default_path_wildcard – An optional string which, if

present as a single directory in the path, is replaced by the value of default-path.

Parameters:default_path – A system-defined directory which can be

restored to the path by placing the default_path_wildcard in the path.

Parameters:prefix_pattern – An optional string which, if present at

the start of a path element, is replaced by the value of prefix_substituend.

Parameters: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)

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 source to target indicates that some aspect of source requires that some aspect of 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 source to the 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 roots.

Returns: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 reset keyword.

Parameters:reset – If 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 ( 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 sccOrder.

Returns: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 reset keyword is given the value True.

Note:Upon reset, any notes that had been manually added

using addNode will no longer be in the set.

Parameters:reset – If True, any cached value is discarded and

recomputed. No effect if False (defalut).

Return type: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: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 sccMap method.

Returns:The SCC set, or 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.

Parameters:reset – If True, the tarjan method will be

re-invoked, propagating the reset value. If False (default), a cached value will be returned if available.

See: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 dfsOrder for code generation, since it detects loops.

See: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.

Parameters:reset – If True, any cached component set is erased

and recomputed. If 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 OpenOrCreate. If the text is in Unicode, the hash is calculated on the UTF-8 encoding of the text.

Returns:A str, generally a sequence of hexadecimal “digit”s.
pyxb.utils.utility.IteratedCompareMixed(lhs, rhs)

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

Returns:-1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs.
class pyxb.utils.utility.LocalTimeZone

Bases: datetime.tzinfo

A datetime.tzinfo subclass for the local time zone.

Mostly pinched from the datetime.tzinfo documentation in Python 2.5.1.

_LocalTimeZone__DSTDelta = datetime.timedelta(0, 3600)
_LocalTimeZone__DSTOffset = datetime.timedelta(-1, 68400)
_LocalTimeZone__STDOffset = datetime.timedelta(-1, 64800)
_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 _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 conflicts with keywords.

:keyword camel_case : If 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 False (default), has no effect.

Return type: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 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 : x, x_, x_2, x_3, ...

Parameters:in_use – The set of identifiers already in use in the

relevant scope. in_use is updated to contain the returned identifier.

Return type: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 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 None, function returns None

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

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

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

Normalize the given string.

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

  • preserve: the text is returned unchanged.
  • replace: all tabs, newlines, and carriage returns are

replaced with ASCII spaces.

  • collapse: the replace normalization is done, then

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

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

Return type: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 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 preserve_contents keyword to True. Normally, existing file contents are erased.

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

Parameters:tag – If not 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 IOError to be raised with errno set to EEXIST. I.e., only files with this value in the first 4KB will be returned for writing.

Parameters:preserve_contents – This value controls whether existing

contents of the file will be erased (False, default) or left in place (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.

Parameters:in_use – the set of already used identifiers. Upon return

from this function, it is updated to include the returned identifier.

Parameters:aux_keywords – an optional set of additional symbols that

are illegal in the given context; use this to prevent conflicts with known method names.

Parameters:private – if False (default), all leading underscores

are stripped, guaranteeing the identifier will not be private. If True, the returned identifier has two leading underscores, making it a private variable within a Python class.

Parameters:protected – as for private, but uses only one

underscore.

Return type:str
Note:Only module-level identifiers should be treated as

protected. The class-level _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 __getstate__ method which returns a copy of self.__dict__ with certain members removed. Specifically, if a string “s” appears in a class member variable named __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 __getstate__ method in every class in the instance hierarchy.

For an example, see pyxb.xmlschema.structures._SchemaComponent_mixin

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

Classes that inherit from this are free to define their own __getstate__ method, which may or may not invoke the superclass one. If you do this, be sure that the class defining __getstate__ lists 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 repr. No point in getting all complex when the language already gives us what we need.

Return type:str
pyxb.utils.utility.SetLocationPrefixRewriteMap(prefix_map)

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

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

Bases: datetime.tzinfo

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

This class only supports fixed offsets from UTC.

_UTCOffsetTimeZone__Lexical_re = <_sre.SRE_Pattern object>
_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 str‘d, the result is the uid; when repr‘d, the result is a constructor call to 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 pyxb.binding.basis.element or pyxb.binding.basis.simpleTypeDefinition classes in 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 _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

Returns:unicode(identifier)
pyxb.utils.utility._NewUUIDString()

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

Return type:str
pyxb.utils.utility._SetXMLIdentifierToPython(xml_identifier_to_python)

Configure a callable 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. 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 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 None to reset to the default implementation, which is _DefaultXMLIdentifierToPython.

Return type: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

Returns: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 re module. The exceptions are for multi-character (w) and category escapes (e.g., p{N} or 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 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>}.

Parameters:text – The complete text of the regular expression being

translated

Parameters:position – The offset of the start of the potential

expression.

Returns:None if position does not begin a character class

expression; otherwise a pair (cps, p) where cps is a pyxb.utils.unicode.CodePointSet containing the code points associated with the property, and p is the text offset immediately following the closing brace.

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

Bases: exceptions.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.

Parameters:pattern – A Unicode string defining a pattern consistent

with U{XML regular expressions<http://www.w3.org/TR/xmlschema-2/index.html#regexs>}.

Returns:A Unicode string specifying a Python regular expression

that matches the same language as pattern.

pyxb.utils.xmlre._InitializeAllEsc()

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

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

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

This is one of:

an escaped single character such as :py:obj:`E{`n}

an escape code that can match a range of characters, e.g. :py:obj:`E{`s} to match certain whitespace characters

:py:obj:`E{`pE{lb}...E{rb}} Unicode property escapes including categories and blocks

the :py:obj:`E{`PE{lb}...E{rb}} inverted Unicode property escapes

If the parsing fails, throws a RegularExpressionError.

Returns:A pair (cps, p) where cps is a

pyxb.utils.unicode.CodePointSet containing the code points associated with the character class, and p is the text offset immediately following the escape sequence.

Raises:RegularExpressionError – if the expression is syntactically

invalid.

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

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

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

Parameters:text – The complete text of the regular expression being

translated. The first character must be the [ starting a character class.

Parameters:position – The offset of the start of the character group.
Returns:A pair (cps, p) where cps is a

pyxb.utils.unicode.CodePointSet containing the code points associated with the property, and p is the text offset immediately following the closing brace.

Raises:RegularExpressionError – if the expression is syntactically

invalid.

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

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

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

invalid.

Module contents

pyxb.utils – Utilities for the PyWXSB package.