NXDL Rules: The XML Schema files : nxdl_schema

Read the NeXus XML Schema


source code documentation

Read the NeXus XML Schema

NXDL_Summary(nxdl_xsd_file_name)

provide an easy interface for the nxdl_manager

render_class_str(obj)

useful optimization for classes

get_reference_keys(xml_node)

reference an xml_node in the catalog: catalog[section][line]

get_named_parent_node(xml_node)

return closest XML ancestor node with a name attribute or the schema node

get_xml_namespace_dictionary()

return the NeXus XML namespace dictionary

The NXDL_item_catalog.definition_element will provide the defaults for the definition, group, field, link, and symbols NXDL structures. These internal structures are used:

NXDL_item_catalog(nxdl_file_name)

content from the NeXus XML Schema (nxdl.xsd)

NXDL_schema__attribute()

node matches XPath query: //xs:attribute

NXDL_schema__attributeGroup()

node matches XPath query: /xs:schema/xs:attributeGroup

NXDL_schema__complexType()

node matches XPath query: /xs:schema/xs:complexType

NXDL_schema__element()

a complete description of a specific NXDL xs:element node

NXDL_schema__group()

node matches XPath query: //xs:group

NXDL_schema_named_simpleType()

node matches XPath query: /xs:schema/xs:simpleType

Note there is a recursion within NXDL_schema__group since a group may contain a child group.

class punx.nxdl_schema.NXDL_Summary(nxdl_xsd_file_name)[source]

provide an easy interface for the nxdl_manager

USAGE:

summary = NXDL_Summary(nxdl_xsd_file_name)
...
summary.simpleType['validItemName'].patterns
class punx.nxdl_schema.NXDL_item_catalog(nxdl_file_name)[source]

content from the NeXus XML Schema (nxdl.xsd)

EXAMPLE:

nxdl_xsd_file_name = os.path.join(‘cache’, ‘v3.2’,’nxdl.xsd’) catalog = NXDL_item_catalog(nxdl_xsd_file_name) definition = catalog.definition_element

class punx.nxdl_schema.NXDL_schema__attribute[source]

node matches XPath query: //xs:attribute

xml_node is xs:attribute

a complete description of a specific NXDL attribute element

NOTES ON ATTRIBUTES

In nxdl.xsd, “attributeType” is used by fieldType and groupGroup to define the NXDL “attribute” element used in fields and groups, respectively. It is not necessary for this code to parse “attributeType” from the rules.

Each of these XML complexType elements defines its own set of attributes and defaults for use in corresponding NXDL components:

  • attributeType

  • basicComponent

  • definitionType

  • enumerationType

  • fieldType

  • groupType

  • linkType

There is also an “xs:attributeGroup” which may appear as a sibling to any xs:attribute element. The xs:attributeGroup provides a list of additional xs:attribute elements to add to the list. This is the only one known at this time (2017-01-08):

  • deprecatedAttributeGroup

When the content under xs:complexType is described within an xs:complexContent/xs:extension element, the xs:extension element has a base attribute which names a xs:complexType element to use as a starting point (like a superclass) for the additional content described within the xs:extension element.

The content may be found at any of these nodes under the parent XML element. Parse them in the order shown:

  • xs:complexContent/xs:extension/xs:attribute

  • xs:attribute

  • (xs:attributeGroup/)``xs:attribute``

This will get picked up when parsing the xs:sequence/xs:element.

  • xs:sequence/xs:element/xs:complexType/xs:attribute (

The XPath query for //xs:attribute from the root node will pick up all of these. It will be necessary to walk through the parent nodes to determine where each should be applied.

parse(xml_node)[source]

read the attribute node content from the XML Schema

xml_node is xs:attribute

class punx.nxdl_schema.NXDL_schema__attributeGroup[source]

node matches XPath query: /xs:schema/xs:attributeGroup

xml_node is xs:attributeGroup

parse(xml_node)[source]

read the attributeGroup node content from the XML Schema

xml_node is xs:attributeGroup

class punx.nxdl_schema.NXDL_schema__complexType[source]

node matches XPath query: /xs:schema/xs:complexType

xml_node is xs:complexType

parse(xml_node, catalog)[source]

read the element node content from the XML Schema

class punx.nxdl_schema.NXDL_schema__element[source]

a complete description of a specific NXDL xs:element node

parse(xml_node)[source]

read the element node content from the XML Schema

class punx.nxdl_schema.NXDL_schema__group[source]

node matches XPath query: //xs:group

xml_node is xs:group

parse(xml_node)[source]

read the element node content from the XML Schema

class punx.nxdl_schema.NXDL_schema_named_simpleType[source]

node matches XPath query: /xs:schema/xs:simpleType

xml_node is xs:simpleType

parse(xml_node)[source]

read the attribute node content from the XML Schema

punx.nxdl_schema.get_named_parent_node(xml_node)[source]

return closest XML ancestor node with a name attribute or the schema node

punx.nxdl_schema.get_reference_keys(xml_node)[source]

reference an xml_node in the catalog: catalog[section][line]

punx.nxdl_schema.get_xml_namespace_dictionary()[source]

return the NeXus XML namespace dictionary

punx.nxdl_schema.render_class_str(obj)[source]

useful optimization for classes

USAGE:

def __str__(self):
    return render_class_str(self)