Module geolink_formatter.parser¶
XML¶
-
class
geolink_formatter.parser.
XML
(host_url=None, version='1.2.2', dtd_validation=False, xsd_validation=True)[source]¶ Bases:
object
Create a new XML parser instance containing the geoLink XSD for validation.
Parameters: - host_url (str) – URL of the OEREBlex host to resolve relative URLs. The complete URL until but without the /api part has to be set, starting with http:// or https://.
- version (str) – The version of the geoLink schema to be used. Defaults to 1.2.0.
- dtd_validation (bool) – Enable/disable validation of document type definition (DTD). Optional, defaults to False.
- xsd_validation (bool) – Enable/disable validation against XML schema (XSD). Optional, defaults to True.
-
from_string
(xml)[source]¶ Parses XML into internal structure.
The specified XML string is gets validated against the geoLink XSD on parsing.
Parameters: xml (str or bytes) – The XML to be parsed. Returns: A list containing the parsed document elements. Return type: list[geolink_formatter.entity.Document] Raises: lxml.etree.XMLSyntaxError
– Raised on failed validation.
-
from_url
(url, params=None, **kwargs)[source]¶ Loads the geoLink of the specified URL and parses it into the internal structure.
Parameters: - url (str) – The URL of the geoLink to be parsed.
- params (dict) – Dictionary or bytes to be sent in the query string for the
requests.models.Request
. - **kwargs – Optional arguments that
requests.api.request
takes.
Returns: A list containing the parsed document elements.
Return type: Raises: lxml.etree.XMLSyntaxError
– Raised on failed validation.requests.HTTPError
– Raised on failed HTTP request.
-
host_url
¶ str – The OEREBlex host URL to resolve relative URLs.