Skip to content

Commit bcb9ff5

Browse files
authored
Merge pull request #1116 from axtimhaus/patch-1
Add section for xmlschema
2 parents 0a0b45e + db3c45b commit bcb9ff5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/scenarios/xml.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,30 @@ and then you can access elements, attributes, and values like this:
8181
xmltodict also lets you roundtrip back to XML with the unparse function,
8282
has a streaming mode suitable for handling files that don't fit in memory,
8383
and supports XML namespaces.
84+
85+
**********
86+
xmlschema
87+
**********
88+
89+
`xmlschema <https://github.com/sissaschool/xmlschema>`_ provides support for using XSD-Schemas in Python.
90+
Unlike other XML libraries, automatic type parsing is available, so f.e. if the schema defines an element to be of type ``int``, the parsed ``dict`` will contain also an ``int`` value for that element.
91+
Moreover the library supports automatic and explicit validation of XML documents against a schema.
92+
93+
.. code-block:: python
94+
95+
from xmlschema import XMLSchema, etree_tostring
96+
97+
# load a XSD schema file
98+
schema = XMLSchema("your_schema.xsd")
99+
100+
# validate against the schema
101+
schema.validate("your_file.xml")
102+
103+
# or
104+
schema.is_valid("your_file.xml")
105+
106+
# decode a file
107+
data = schmema.decode("your_file.xml")
108+
109+
# encode to string
110+
s = etree_tostring(schema.encode(data))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy