Package xmlschema_acue :: Module helpers

Module helpers

source code

This module contains various helper functions and classes.

Classes
  ParticleCounter
An helper class for counting total min/max occurrences of XSD particles.
Functions
 
get_namespace(name) source code
 
get_qname(uri, name)
Returns an expanded QName from URI and local part.
source code
 
local_name(qname)
Return the local part of an expanded QName.
source code
 
qname_to_prefixed(qname, namespaces)
Transforms a fully qualified name into a prefixed name using a namespace map.
source code
 
get_xsd_annotation(elem)
Returns the annotation of an XSD component.
source code
 
iter_xsd_components(elem, start=0)
Returns an iterator for XSD child components, excluding the annotation.
source code
 
has_xsd_components(elem, start=0) source code
 
get_xsd_component(elem, required=True, strict=True)
Returns the first XSD component child, excluding the annotation.
source code
 
get_xml_bool_attribute(elem, attribute, default=None)
Get an XML boolean attribute.
source code
 
get_xsd_derivation_attribute(elem, attribute, values=None)
Get a derivation attribute (maybe 'block', 'blockDefault', 'final' or 'finalDefault') checking the items with the values arguments.
source code
 
get_xsd_form_attribute(elem, attribute)
Get an XSD form attribute, checking the value.
source code
Variables
  XSD_FINAL_ATTRIBUTE_VALUES = {'restriction', 'extension', 'lis...
  NAMESPACE_PATTERN = re.compile(r'{([^}]*)}')
Function Details

get_qname(uri, name)

source code 

Returns an expanded QName from URI and local part. If any argument has boolean value `False` or if the name is already an expanded QName, returns the *name* argument.

:param uri: namespace URI :param name: local or qualified name :return: string or the name argument

Decorators:

local_name(qname)

source code 

Return the local part of an expanded QName. If the name is `None` or empty returns the *name* argument.

:param qname: an expanded QName or a local name.

Decorators:

qname_to_prefixed(qname, namespaces)

source code 

Transforms a fully qualified name into a prefixed name using a namespace map. Returns the *qname* argument if it's not a fully qualified name or if it has boolean value `False`.

:param qname: a fully qualified name or a local name. :param namespaces: a map from prefixes to namespace URIs. :return: string with a prefixed or local reference.

Decorators:

get_xsd_annotation(elem)

source code 

Returns the annotation of an XSD component.

:param elem: ElementTree's node :return: The first child element containing an XSD annotation, `None` if the XSD information item doesn't have an annotation.

Decorators:

iter_xsd_components(elem, start=0)

source code 

Returns an iterator for XSD child components, excluding the annotation.

:param elem: the parent Element. :param start: the start child component to yield, the optional annotation is not counted. With the default value 0 starts from the first component.

Decorators:

get_xsd_component(elem, required=True, strict=True)

source code 

Returns the first XSD component child, excluding the annotation.

:param elem: the parent Element. :param required: if `True`, that is the default, raises a *ValueError* if there is not any component; with `False` in those cases `None` is returned. :param strict: raises a *ValueError* if there is more than one component.

Decorators:

get_xml_bool_attribute(elem, attribute, default=None)

source code 

Get an XML boolean attribute.

:param elem: the Element instance. :param attribute: the attribute name. :param default: default value, accepted values are `True` or `False`. :return: `True` or `False`.

Decorators:

get_xsd_derivation_attribute(elem, attribute, values=None)

source code 

Get a derivation attribute (maybe 'block', 'blockDefault', 'final' or 'finalDefault') checking the items with the values arguments. Returns a string.

:param elem: the Element instance. :param attribute: the attribute name. :param values: sequence of admitted values when the attribute value is not '#all'. :return: a string.

Decorators:

get_xsd_form_attribute(elem, attribute)

source code 

Get an XSD form attribute, checking the value. If the attribute is missing returns `None`

:param elem: the Element instance. :param attribute: the attribute name (maybe 'form', or 'elementFormDefault' or 'attributeFormDefault'). :return: a string.

Decorators:

Variables Details

XSD_FINAL_ATTRIBUTE_VALUES

Value:
{'restriction', 'extension', 'list', 'union'}