Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 32db4ae

Browse files
add section for xmlschema
1 parent cf14c4c commit 32db4ae

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)

AltStyle によって変換されたページ (->オリジナル) /