xml_common package#
Subpackages#
- xml_common.utils package
- Submodules
- xml_common.utils.enum module
- xml_common.utils.establishment_means module
- xml_common.utils.gpolygon module
- xml_common.utils.iteratate module
- xml_common.utils.language module
- xml_common.utils.length_unit module
LengthUnit
LengthUnit.ANGSTROM
LengthUnit.CENTIMETER
LengthUnit.DECIMETER
LengthUnit.DEKAMETER
LengthUnit.FATHOM
LengthUnit.FOOT
LengthUnit.FOOT_GOLD_COAST
LengthUnit.FOOT_US
LengthUnit.HECTOMETER
LengthUnit.INCH
LengthUnit.KILOMETER
LengthUnit.LINK_CLARKE
LengthUnit.MEGAMETER
LengthUnit.METER
LengthUnit.MICROMETER
LengthUnit.MICRON
LengthUnit.MILE
LengthUnit.MILLIMETER
LengthUnit.NANOMETER
LengthUnit.NAUTICALMILE
LengthUnit.YARD
LengthUnit.YARD_INDIAN
LengthUnit.YARD_SEARS
LengthUnit.valid_name
- xml_common.utils.type_functions module
- Module contents
Submodules#
xml_common.xml_object module#
- class xml_common.xml_object.XMLObject#
Bases:
ABC
Abstract class for XML Object, to be parsed on the read of the Darwin Core Archive file.
- Attributes:
- NAMESPACE_TAG
Methods
check_principal_tag
(tag, nmap)Checks if the tag is the Principal tag of the object.
from_string
(text)Generates XML Object from a string of an XML file.
from_xml
(file[, encoding])Generates an XML Object from an XML file.
Returns the principal tag with namespaces if it is present.
object_to_element
(tag[, prefix])Generates an element using tag, adding namespace tag.
parse
(element, nmap)Parses a lxml element into an XMLObject.
Generates a lxml.tree.Element from the object.
to_xml
()Generates text of an XML file.
- NAMESPACES = {'xml': 'http://www.w3.org/XML/1998/namespace'}#
Dict[str, str] : Namespaces to use on the particular XML portion that represent the object.
- NAMESPACE_TAG = None#
str : If the principal tag has a namespace attribute, this must be used.
- PRINCIPAL_TAG = 'placeholder'#
str : The principal tag of the XML document.
- classmethod check_principal_tag(tag: str, nmap: Dict) None #
Checks if the tag is the Principal tag of the object.
- Parameters:
- tagstr
Tag obtained from outside source.
- nmapDict
The namespace to check the format of the Principal tag.
- Raises:
- AssertionError
If the tag is not a representation of the principal tag of the object.
- classmethod from_string(text: str) XMLObject #
Generates XML Object from a string of an XML file.
- Parameters:
- textstr
XML File as a string.
- Returns:
- XMLObject
Object parsed from the string.
- classmethod from_xml(file: str, encoding: str = 'utf-8') XMLObject #
Generates an XML Object from an XML file.
- Parameters:
- filestr
Path to XML file.
- encodingstr, default “utf-8”
Encoding of the XML file.
- Returns:
- XMLObject
Parsed XML object from XML file.
- get_principal_tag() str #
Returns the principal tag with namespaces if it is present.
- Returns:
- str
Principal tag of the XML file.
- object_to_element(tag: str, prefix: str | None = None) Element #
Generates an element using tag, adding namespace tag.
- Parameters:
- tagstr
Tag for XML Element.
- prefixstr, optional
Prefix of namespace, default None.
- Returns:
- lxml.tree.Element
Generated element.
- abstract classmethod parse(element: Element, nmap: Dict) XMLObject | None #
Parses a lxml element into an XMLObject.
- Parameters:
- elementlxml.tree.Element
Object in the Element format to be parsed into a Python object.
- nmapDict
Dictionary of namespace.
- Returns:
- XMLObject
Object parsed.
- abstract to_element() Element #
Generates a lxml.tree.Element from the object.
- Returns:
- lxml.tree.Element
Object in the Element format.
- to_xml() str #
Generates text of an XML file.
- Returns:
- str
Text of an XML File from the object.