Movatterモバイル変換


[0]ホーム

URL:


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

Commitbcb9ff5

Browse files
authored
Merge pull request#1116 from axtimhaus/patch-1
Add section for xmlschema
2 parents0a0b45e +db3c45b commitbcb9ff5

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 xmlschemaimport 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)

[8]ページ先頭

©2009-2025 Movatter.jp