schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xmldocument module

This module contains XMLDocument class for xsdtypes package

class schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xmldocument.XmlDocument(xsd_file)[source]

Bases: object

Generic XML schema based document.

A XSD schema is needed for checking types, validation of the configuration and for lookup of default values of the attributes. Full schema’s validation is available only if lxml library is installed.

Supported files data format for configuration are XML, YAML and JSON.

__init__(xsd_file)[source]
read(filename, data_format='XML')[source]

Read configuration from a text file in a specific data format.

Parameters
  • filename – Name of the text file containing the configuration

  • data_format – Input file data format (XML, JSON or YAML)

parse_xml(filename)[source]

Return an ElementTree object representing an XML file

parse_json(filename)[source]

Build an ElementTree object representing a YAML file

parse_yaml(filename)[source]

Build an ElementTree object representing a YAML file

from_dict()[source]

Build an ElementTree object from a dictionary

validate(filename=None)[source]
extra_validations(xlm_tree)[source]

Hook for ad-hoc validations of dependencies between parameters that are not explainable with the XSD schema.

write(filename, output_format='XML')[source]

Write configuration to a text file in a specific data format.

Parameters
  • filename

  • output_format

Returns

read_string(text)[source]
get(qualified_name)[source]
to_dict()[source]
to_json()[source]

Converts the configuration to to json.

iter(tag=None)[source]
find(path, namespaces=None)[source]

Find first matching element by tag name or path.

Parameters
  • path – is a string having either an element tag or an XPath,

  • namespaces – is an optional mapping from namespace prefix to full name.

Returns

the first matching element, or None if no element was found

findall(path, namespaces=None)[source]

Find all matching subelements by tag name or path.

Parameters
  • path – is a string having either an element tag or an XPath,

  • namespaces – is an optional mapping from namespace prefix to full name.

Returns

the first matching element, or None if no element was found