lxml 5.2.0__cp310-cp310-win32.whl → 5.2.2__cp310-cp310-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. lxml/ElementInclude.py +244 -244
  2. lxml/__init__.py +22 -22
  3. lxml/_elementpath.cp310-win32.pyd +0 -0
  4. lxml/_elementpath.py +341 -341
  5. lxml/apihelpers.pxi +1793 -1793
  6. lxml/builder.cp310-win32.pyd +0 -0
  7. lxml/builder.py +232 -232
  8. lxml/classlookup.pxi +580 -580
  9. lxml/cleanup.pxi +215 -215
  10. lxml/cssselect.py +101 -101
  11. lxml/debug.pxi +90 -90
  12. lxml/docloader.pxi +178 -178
  13. lxml/doctestcompare.py +488 -488
  14. lxml/dtd.pxi +478 -478
  15. lxml/etree.cp310-win32.pyd +0 -0
  16. lxml/etree.h +6 -6
  17. lxml/etree.pyx +3732 -3711
  18. lxml/extensions.pxi +833 -833
  19. lxml/html/ElementSoup.py +10 -10
  20. lxml/html/__init__.py +1923 -1923
  21. lxml/html/_diffcommand.py +86 -86
  22. lxml/html/_html5builder.py +100 -100
  23. lxml/html/_setmixin.py +56 -56
  24. lxml/html/builder.py +133 -133
  25. lxml/html/clean.py +21 -21
  26. lxml/html/defs.py +135 -135
  27. lxml/html/diff.cp310-win32.pyd +0 -0
  28. lxml/html/diff.py +878 -878
  29. lxml/html/formfill.py +299 -299
  30. lxml/html/html5parser.py +260 -260
  31. lxml/html/soupparser.py +314 -314
  32. lxml/html/usedoctest.py +13 -13
  33. lxml/includes/c14n.pxd +25 -25
  34. lxml/includes/config.pxd +3 -3
  35. lxml/includes/dtdvalid.pxd +18 -18
  36. lxml/includes/etree_defs.h +379 -379
  37. lxml/includes/etreepublic.pxd +237 -237
  38. lxml/includes/htmlparser.pxd +56 -56
  39. lxml/includes/lxml-version.h +1 -1
  40. lxml/includes/relaxng.pxd +64 -64
  41. lxml/includes/schematron.pxd +34 -34
  42. lxml/includes/tree.pxd +494 -494
  43. lxml/includes/uri.pxd +5 -5
  44. lxml/includes/xinclude.pxd +22 -22
  45. lxml/includes/xmlerror.pxd +852 -852
  46. lxml/includes/xmlparser.pxd +265 -265
  47. lxml/includes/xmlschema.pxd +35 -35
  48. lxml/includes/xpath.pxd +136 -136
  49. lxml/includes/xslt.pxd +190 -190
  50. lxml/isoschematron/__init__.py +348 -348
  51. lxml/isoschematron/resources/rng/iso-schematron.rng +709 -709
  52. lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl +75 -75
  53. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl +312 -312
  54. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl +1159 -1159
  55. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl +54 -54
  56. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl +1796 -1796
  57. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl +588 -588
  58. lxml/iterparse.pxi +438 -438
  59. lxml/lxml.etree.h +6 -6
  60. lxml/nsclasses.pxi +281 -281
  61. lxml/objectify.cp310-win32.pyd +0 -0
  62. lxml/objectify.pyx +2145 -2145
  63. lxml/objectpath.pxi +332 -332
  64. lxml/parser.pxi +1994 -1994
  65. lxml/parsertarget.pxi +180 -180
  66. lxml/proxy.pxi +619 -619
  67. lxml/public-api.pxi +178 -178
  68. lxml/pyclasslookup.py +3 -3
  69. lxml/readonlytree.pxi +565 -565
  70. lxml/relaxng.pxi +165 -165
  71. lxml/sax.cp310-win32.pyd +0 -0
  72. lxml/sax.py +275 -275
  73. lxml/saxparser.pxi +875 -875
  74. lxml/schematron.pxi +168 -168
  75. lxml/serializer.pxi +1871 -1871
  76. lxml/usedoctest.py +13 -13
  77. lxml/xinclude.pxi +67 -67
  78. lxml/xmlerror.pxi +1654 -1654
  79. lxml/xmlid.pxi +179 -179
  80. lxml/xmlschema.pxi +215 -215
  81. lxml/xpath.pxi +487 -487
  82. lxml/xslt.pxi +950 -950
  83. lxml/xsltext.pxi +242 -242
  84. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSE.txt +29 -29
  85. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSES.txt +29 -29
  86. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/METADATA +9 -17
  87. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/RECORD +89 -89
  88. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/WHEEL +0 -0
  89. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/top_level.txt +0 -0
lxml/schematron.pxi CHANGED
@@ -1,168 +1,168 @@
1
- # support for Schematron validation
2
- from lxml.includes cimport schematron
3
-
4
-
5
- cdef class SchematronError(LxmlError):
6
- """Base class of all Schematron errors.
7
- """
8
-
9
- cdef class SchematronParseError(SchematronError):
10
- """Error while parsing an XML document as Schematron schema.
11
- """
12
-
13
- cdef class SchematronValidateError(SchematronError):
14
- """Error while validating an XML document with a Schematron schema.
15
- """
16
-
17
-
18
- ################################################################################
19
- # Schematron
20
-
21
- cdef class Schematron(_Validator):
22
- """Schematron(self, etree=None, file=None)
23
- A Schematron validator.
24
-
25
- Pass a root Element or an ElementTree to turn it into a validator.
26
- Alternatively, pass a filename as keyword argument 'file' to parse from
27
- the file system.
28
-
29
- Schematron is a less well known, but very powerful schema language. The main
30
- idea is to use the capabilities of XPath to put restrictions on the structure
31
- and the content of XML documents. Here is a simple example::
32
-
33
- >>> schematron = Schematron(XML('''
34
- ... <schema xmlns="http://www.ascc.net/xml/schematron" >
35
- ... <pattern name="id is the only permitted attribute name">
36
- ... <rule context="*">
37
- ... <report test="@*[not(name()='id')]">Attribute
38
- ... <name path="@*[not(name()='id')]"/> is forbidden<name/>
39
- ... </report>
40
- ... </rule>
41
- ... </pattern>
42
- ... </schema>
43
- ... '''))
44
-
45
- >>> xml = XML('''
46
- ... <AAA name="aaa">
47
- ... <BBB id="bbb"/>
48
- ... <CCC color="ccc"/>
49
- ... </AAA>
50
- ... ''')
51
-
52
- >>> schematron.validate(xml)
53
- 0
54
-
55
- >>> xml = XML('''
56
- ... <AAA id="aaa">
57
- ... <BBB id="bbb"/>
58
- ... <CCC/>
59
- ... </AAA>
60
- ... ''')
61
-
62
- >>> schematron.validate(xml)
63
- 1
64
-
65
- Schematron was added to libxml2 in version 2.6.21. Before version 2.6.32,
66
- however, Schematron lacked support for error reporting other than to stderr.
67
- This version is therefore required to retrieve validation warnings and
68
- errors in lxml.
69
- """
70
- cdef schematron.xmlSchematron* _c_schema
71
- cdef xmlDoc* _c_schema_doc
72
- def __cinit__(self):
73
- self._c_schema = NULL
74
- self._c_schema_doc = NULL
75
-
76
- def __init__(self, etree=None, *, file=None):
77
- cdef _Document doc
78
- cdef _Element root_node
79
- cdef xmlNode* c_node
80
- cdef char* c_href
81
- cdef schematron.xmlSchematronParserCtxt* parser_ctxt = NULL
82
- _Validator.__init__(self)
83
- if not config.ENABLE_SCHEMATRON:
84
- raise SchematronError, \
85
- "lxml.etree was compiled without Schematron support."
86
- if etree is not None:
87
- doc = _documentOrRaise(etree)
88
- root_node = _rootNodeOrRaise(etree)
89
- self._c_schema_doc = _copyDocRoot(doc._c_doc, root_node._c_node)
90
- parser_ctxt = schematron.xmlSchematronNewDocParserCtxt(self._c_schema_doc)
91
- elif file is not None:
92
- filename = _getFilenameForFile(file)
93
- if filename is None:
94
- # XXX assume a string object
95
- filename = file
96
- filename = _encodeFilename(filename)
97
- with self._error_log:
98
- orig_loader = _register_document_loader()
99
- parser_ctxt = schematron.xmlSchematronNewParserCtxt(_cstr(filename))
100
- _reset_document_loader(orig_loader)
101
- else:
102
- raise SchematronParseError, "No tree or file given"
103
-
104
- if parser_ctxt is NULL:
105
- if self._c_schema_doc is not NULL:
106
- tree.xmlFreeDoc(self._c_schema_doc)
107
- self._c_schema_doc = NULL
108
- raise MemoryError()
109
-
110
- try:
111
- with self._error_log:
112
- orig_loader = _register_document_loader()
113
- self._c_schema = schematron.xmlSchematronParse(parser_ctxt)
114
- _reset_document_loader(orig_loader)
115
- finally:
116
- schematron.xmlSchematronFreeParserCtxt(parser_ctxt)
117
-
118
- if self._c_schema is NULL:
119
- raise SchematronParseError(
120
- "Document is not a valid Schematron schema",
121
- self._error_log)
122
-
123
- def __dealloc__(self):
124
- schematron.xmlSchematronFree(self._c_schema)
125
- if self._c_schema_doc is not NULL:
126
- tree.xmlFreeDoc(self._c_schema_doc)
127
-
128
- def __call__(self, etree):
129
- """__call__(self, etree)
130
-
131
- Validate doc using Schematron.
132
-
133
- Returns true if document is valid, false if not."""
134
- cdef _Document doc
135
- cdef _Element root_node
136
- cdef xmlDoc* c_doc
137
- cdef schematron.xmlSchematronValidCtxt* valid_ctxt
138
- cdef int ret
139
-
140
- assert self._c_schema is not NULL, "Schematron instance not initialised"
141
- doc = _documentOrRaise(etree)
142
- root_node = _rootNodeOrRaise(etree)
143
-
144
- valid_ctxt = schematron.xmlSchematronNewValidCtxt(
145
- self._c_schema, schematron.XML_SCHEMATRON_OUT_ERROR)
146
- if valid_ctxt is NULL:
147
- raise MemoryError()
148
-
149
- try:
150
- self._error_log.clear()
151
- # Need a cast here because older libxml2 releases do not use 'const' in the functype.
152
- schematron.xmlSchematronSetValidStructuredErrors(
153
- valid_ctxt, <xmlerror.xmlStructuredErrorFunc> _receiveError, <void*>self._error_log)
154
- c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
155
- with nogil:
156
- ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
157
- _destroyFakeDoc(doc._c_doc, c_doc)
158
- finally:
159
- schematron.xmlSchematronFreeValidCtxt(valid_ctxt)
160
-
161
- if ret == -1:
162
- raise SchematronValidateError(
163
- "Internal error in Schematron validation",
164
- self._error_log)
165
- if ret == 0:
166
- return True
167
- else:
168
- return False
1
+ # support for Schematron validation
2
+ from lxml.includes cimport schematron
3
+
4
+
5
+ cdef class SchematronError(LxmlError):
6
+ """Base class of all Schematron errors.
7
+ """
8
+
9
+ cdef class SchematronParseError(SchematronError):
10
+ """Error while parsing an XML document as Schematron schema.
11
+ """
12
+
13
+ cdef class SchematronValidateError(SchematronError):
14
+ """Error while validating an XML document with a Schematron schema.
15
+ """
16
+
17
+
18
+ ################################################################################
19
+ # Schematron
20
+
21
+ cdef class Schematron(_Validator):
22
+ """Schematron(self, etree=None, file=None)
23
+ A Schematron validator.
24
+
25
+ Pass a root Element or an ElementTree to turn it into a validator.
26
+ Alternatively, pass a filename as keyword argument 'file' to parse from
27
+ the file system.
28
+
29
+ Schematron is a less well known, but very powerful schema language. The main
30
+ idea is to use the capabilities of XPath to put restrictions on the structure
31
+ and the content of XML documents. Here is a simple example::
32
+
33
+ >>> schematron = Schematron(XML('''
34
+ ... <schema xmlns="http://www.ascc.net/xml/schematron" >
35
+ ... <pattern name="id is the only permitted attribute name">
36
+ ... <rule context="*">
37
+ ... <report test="@*[not(name()='id')]">Attribute
38
+ ... <name path="@*[not(name()='id')]"/> is forbidden<name/>
39
+ ... </report>
40
+ ... </rule>
41
+ ... </pattern>
42
+ ... </schema>
43
+ ... '''))
44
+
45
+ >>> xml = XML('''
46
+ ... <AAA name="aaa">
47
+ ... <BBB id="bbb"/>
48
+ ... <CCC color="ccc"/>
49
+ ... </AAA>
50
+ ... ''')
51
+
52
+ >>> schematron.validate(xml)
53
+ 0
54
+
55
+ >>> xml = XML('''
56
+ ... <AAA id="aaa">
57
+ ... <BBB id="bbb"/>
58
+ ... <CCC/>
59
+ ... </AAA>
60
+ ... ''')
61
+
62
+ >>> schematron.validate(xml)
63
+ 1
64
+
65
+ Schematron was added to libxml2 in version 2.6.21. Before version 2.6.32,
66
+ however, Schematron lacked support for error reporting other than to stderr.
67
+ This version is therefore required to retrieve validation warnings and
68
+ errors in lxml.
69
+ """
70
+ cdef schematron.xmlSchematron* _c_schema
71
+ cdef xmlDoc* _c_schema_doc
72
+ def __cinit__(self):
73
+ self._c_schema = NULL
74
+ self._c_schema_doc = NULL
75
+
76
+ def __init__(self, etree=None, *, file=None):
77
+ cdef _Document doc
78
+ cdef _Element root_node
79
+ cdef xmlNode* c_node
80
+ cdef char* c_href
81
+ cdef schematron.xmlSchematronParserCtxt* parser_ctxt = NULL
82
+ _Validator.__init__(self)
83
+ if not config.ENABLE_SCHEMATRON:
84
+ raise SchematronError, \
85
+ "lxml.etree was compiled without Schematron support."
86
+ if etree is not None:
87
+ doc = _documentOrRaise(etree)
88
+ root_node = _rootNodeOrRaise(etree)
89
+ self._c_schema_doc = _copyDocRoot(doc._c_doc, root_node._c_node)
90
+ parser_ctxt = schematron.xmlSchematronNewDocParserCtxt(self._c_schema_doc)
91
+ elif file is not None:
92
+ filename = _getFilenameForFile(file)
93
+ if filename is None:
94
+ # XXX assume a string object
95
+ filename = file
96
+ filename = _encodeFilename(filename)
97
+ with self._error_log:
98
+ orig_loader = _register_document_loader()
99
+ parser_ctxt = schematron.xmlSchematronNewParserCtxt(_cstr(filename))
100
+ _reset_document_loader(orig_loader)
101
+ else:
102
+ raise SchematronParseError, "No tree or file given"
103
+
104
+ if parser_ctxt is NULL:
105
+ if self._c_schema_doc is not NULL:
106
+ tree.xmlFreeDoc(self._c_schema_doc)
107
+ self._c_schema_doc = NULL
108
+ raise MemoryError()
109
+
110
+ try:
111
+ with self._error_log:
112
+ orig_loader = _register_document_loader()
113
+ self._c_schema = schematron.xmlSchematronParse(parser_ctxt)
114
+ _reset_document_loader(orig_loader)
115
+ finally:
116
+ schematron.xmlSchematronFreeParserCtxt(parser_ctxt)
117
+
118
+ if self._c_schema is NULL:
119
+ raise SchematronParseError(
120
+ "Document is not a valid Schematron schema",
121
+ self._error_log)
122
+
123
+ def __dealloc__(self):
124
+ schematron.xmlSchematronFree(self._c_schema)
125
+ if self._c_schema_doc is not NULL:
126
+ tree.xmlFreeDoc(self._c_schema_doc)
127
+
128
+ def __call__(self, etree):
129
+ """__call__(self, etree)
130
+
131
+ Validate doc using Schematron.
132
+
133
+ Returns true if document is valid, false if not."""
134
+ cdef _Document doc
135
+ cdef _Element root_node
136
+ cdef xmlDoc* c_doc
137
+ cdef schematron.xmlSchematronValidCtxt* valid_ctxt
138
+ cdef int ret
139
+
140
+ assert self._c_schema is not NULL, "Schematron instance not initialised"
141
+ doc = _documentOrRaise(etree)
142
+ root_node = _rootNodeOrRaise(etree)
143
+
144
+ valid_ctxt = schematron.xmlSchematronNewValidCtxt(
145
+ self._c_schema, schematron.XML_SCHEMATRON_OUT_ERROR)
146
+ if valid_ctxt is NULL:
147
+ raise MemoryError()
148
+
149
+ try:
150
+ self._error_log.clear()
151
+ # Need a cast here because older libxml2 releases do not use 'const' in the functype.
152
+ schematron.xmlSchematronSetValidStructuredErrors(
153
+ valid_ctxt, <xmlerror.xmlStructuredErrorFunc> _receiveError, <void*>self._error_log)
154
+ c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
155
+ with nogil:
156
+ ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
157
+ _destroyFakeDoc(doc._c_doc, c_doc)
158
+ finally:
159
+ schematron.xmlSchematronFreeValidCtxt(valid_ctxt)
160
+
161
+ if ret == -1:
162
+ raise SchematronValidateError(
163
+ "Internal error in Schematron validation",
164
+ self._error_log)
165
+ if ret == 0:
166
+ return True
167
+ else:
168
+ return False