module: xml_utility

XML utility methods

exception Assign_GUP.xml_utility.IncorrectXmlRootTag[source]

Bases: lxml.etree.DocumentInvalid

the root tag of the XML file is incorrect

exception Assign_GUP.xml_utility.InvalidWithXmlSchema[source]

Bases: lxml.etree.DocumentInvalid

error while validating against the XML Schema

exception Assign_GUP.xml_utility.XmlSyntaxError[source]

Bases: lxml.etree.XMLSyntaxError

Xml Syntax error

Assign_GUP.xml_utility.getXmlText(parent, tag, default=None)[source]

Read the text content of an XML node

Parameters:
  • reviewer – lxml node node
  • default – default value is no node text
Returns:

node text or None

Assign_GUP.xml_utility.readValidXmlDoc(filename, expected_root_tag, XML_Schema_file, alt_root_tag='', alt_schema=None)[source]

Common code to read an XML file, validate it with an XML Schema, and return the XML doc object

Parameters:XML_Schema_file (str) – name of XML Schema file (local to package directory)
Assign_GUP.xml_utility.validate(xml_tree, XSD_Schema_file)[source]

validate an XML document tree against an XML Schema file

Parameters:
  • xml_tree (obj) – instance of etree._ElementTree
  • XSD_Schema_file (str) – name of XSD Schema file (local to package directory)