Home | Top | ← | → | Overview | Module | Class | Index | Help |
|
About |
---|
|
||||
Functions | |||
|
|||
|
|||
|
|||
|
Function Details |
Validates an XML document against a schema instance. This function builds an :class:`XMLSchema` object for validating the XML document. Raises an :exc:`XMLSchemaValidationError` if the XML document is not validated against the schema. :param xml_document: can be a file-like object or a string containing the XML data or a file path or a URL of a resource or an ElementTree/Element instance. :param schema: can be a schema instance or a file-like object or a file path or a URL of a resource or a string containing the schema. :param cls: schema class to use for building the instance (for default uses :class:`XMLSchema`). :param use_defaults: defines when to use elements and attribute defaults for filling missing required values. :param namespaces: is an optional mapping from namespace prefix to URI. :param locations: additional schema location hints, in case a schema instance has to be built. :param base_url: is an optional custom base URL for remapping relative locations, for default uses the directory where the XSD or alternatively the XML document is located.
|
Decodes an XML document to a Python's nested dictionary. The decoding is based on an XML Schema class instance. For default the document is validated during the decoding phase. Raises an :exc:`XMLSchemaValidationError` if the XML document is not validated against the schema. :param xml_document: can be a file-like object or a string containing the XML data or a file path or a URL of a resource or an ElementTree/Element instance. :param schema: can be a schema instance or a file-like object or a file path or a URL of a resource or a string containing the schema. :param cls: schema class to use for building the instance (for default uses :class:`XMLSchema`). :param path: is an optional XPath expression that matches the subelement of the document that have to be decoded. The XPath expression considers the schema as the root element with global elements as its children. :param process_namespaces: indicates whether to use namespace information in the decoding process. :param locations: additional schema location hints, in case a schema instance has to be built. :param base_url: is an optional custom base URL for remapping relative locations, for default uses the directory where the XSD or alternatively the XML document is located. :param kwargs: optional arguments of :meth:`XMLSchema.iter_decode` as keyword arguments to variate the decoding process. :return: an object containing the decoded data. If ``validation='lax'`` keyword argument is provided the validation errors are collected and returned coupled in a tuple with the decoded data. :raises: :exc:`XMLSchemaValidationError` if the object is not decodable by the XSD component, or also if it's invalid when ``validation='strict'`` is provided.
|
Serialize an XML document to JSON. For default the XML data is validated during the decoding phase. Raises an :exc:`XMLSchemaValidationError` if the XML document is not validated against the schema. :param xml_document: can be a file-like object or a string containing the XML data or a file path or an URI of a resource or an ElementTree/Element instance. :param fp: can be a :meth:`write()` supporting file-like object. :param schema: can be a schema instance or a file-like object or a file path or an URL of a resource or a string containing the schema. :param cls: schema class to use for building the instance (for default uses :class:`XMLSchema`). :param path: is an optional XPath expression that matches the subelement of the document that have to be decoded. The XPath expression considers the schema as the root element with global elements as its children. :param converter: an :class:`XMLSchemaConverter` subclass or instance to use for the decoding. :param process_namespaces: indicates whether to use namespace information in the decoding process. :param locations: additional schema location hints, in case a schema instance has to be built. :param base_url: is an optional custom base URL for remapping relative locations, for default uses the directory where the XSD or alternatively the XML document is located. :param json_options: a dictionary with options for the JSON serializer. :param kwargs: optional arguments of :meth:`XMLSchema.iter_decode` as keyword arguments to variate the decoding process. :return: a string containing the JSON data if *fp* is `None`, otherwise doesn't return anything. If ``validation='lax'`` keyword argument is provided the validation errors are collected and returned, eventually coupled in a tuple with the JSON data. :raises: :exc:`XMLSchemaValidationError` if the object is not decodable by the XSD component, or also if it's invalid when ``validation='strict'`` is provided.
|
Deserialize JSON data to an XML Element. :param source: can be a string or a :meth:`read()` supporting file-like object containing the JSON document. :param schema: an :class:`XMLSchema` instance. :param path: is an optional XPath expression for selecting the element of the schema that matches the data that has to be encoded. For default the first global element of the schema is used. :param converter: an :class:`XMLSchemaConverter` subclass or instance to use for the encoding. :param json_options: a dictionary with options for the JSON deserializer. :param kwargs: Keyword arguments containing options for converter and encoding. :return: An element tree's Element instance. If ``validation='lax'`` keyword argument is provided the validation errors are collected and returned coupled in a tuple with the Element instance. :raises: :exc:`XMLSchemaValidationError` if the object is not encodable by the schema, or also if it's invalid when ``validation='strict'`` is provided.
|
Home | Top | ← | → | Overview | Module | Class | Index | Help |
|
About |
---|
Copyright(C) 2019 Arno-Can Uestuensoez @Ingenieurbuero Arno-Can Uestuensoez | https://arnocan.wordpress.com |
Generated by Epydoc 4.0.4 / Python-3.8 / fedora27 on Fri Dec 13 15:25:22 2019 | http://epydoc.sourceforge.net |