applied-ai-018 commited on
Commit
f19dc03
·
verified ·
1 Parent(s): b648e8e

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. llmeval-env/lib/python3.10/site-packages/lxml/html/ElementSoup.py +10 -0
  2. llmeval-env/lib/python3.10/site-packages/lxml/html/__init__.py +1923 -0
  3. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/ElementSoup.cpython-310.pyc +0 -0
  4. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/__init__.cpython-310.pyc +0 -0
  5. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_html5builder.cpython-310.pyc +0 -0
  6. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/clean.cpython-310.pyc +0 -0
  7. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/defs.cpython-310.pyc +0 -0
  8. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/formfill.cpython-310.pyc +0 -0
  9. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/html5parser.cpython-310.pyc +0 -0
  10. llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/usedoctest.cpython-310.pyc +0 -0
  11. llmeval-env/lib/python3.10/site-packages/lxml/html/_diffcommand.py +86 -0
  12. llmeval-env/lib/python3.10/site-packages/lxml/html/_setmixin.py +56 -0
  13. llmeval-env/lib/python3.10/site-packages/lxml/html/builder.py +133 -0
  14. llmeval-env/lib/python3.10/site-packages/lxml/html/defs.py +135 -0
  15. llmeval-env/lib/python3.10/site-packages/lxml/html/diff.py +878 -0
  16. llmeval-env/lib/python3.10/site-packages/lxml/html/formfill.py +299 -0
  17. llmeval-env/lib/python3.10/site-packages/lxml/html/usedoctest.py +13 -0
  18. llmeval-env/lib/python3.10/site-packages/lxml/includes/__init__.pxd +0 -0
  19. llmeval-env/lib/python3.10/site-packages/lxml/includes/__init__.py +0 -0
  20. llmeval-env/lib/python3.10/site-packages/lxml/includes/c14n.pxd +25 -0
  21. llmeval-env/lib/python3.10/site-packages/lxml/includes/config.pxd +3 -0
  22. llmeval-env/lib/python3.10/site-packages/lxml/includes/dtdvalid.pxd +18 -0
  23. llmeval-env/lib/python3.10/site-packages/lxml/includes/etree_defs.h +379 -0
  24. llmeval-env/lib/python3.10/site-packages/lxml/includes/etreepublic.pxd +237 -0
  25. llmeval-env/lib/python3.10/site-packages/lxml/includes/htmlparser.pxd +56 -0
  26. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/HTMLparser.h +343 -0
  27. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/HTMLtree.h +147 -0
  28. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/dict.h +82 -0
  29. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/encoding.h +235 -0
  30. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/globals.h +41 -0
  31. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/parser.h +1384 -0
  32. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/parserInternals.h +663 -0
  33. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/schematron.h +143 -0
  34. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/valid.h +450 -0
  35. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlexports.h +50 -0
  36. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlreader.h +434 -0
  37. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlsave.h +97 -0
  38. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlschemas.h +249 -0
  39. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlschemastypes.h +152 -0
  40. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlstring.h +140 -0
  41. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlwriter.h +488 -0
  42. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/__init__.py +0 -0
  43. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/__pycache__/__init__.cpython-310.pyc +0 -0
  44. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/attributes.h +39 -0
  45. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/documents.h +93 -0
  46. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/extensions.h +262 -0
  47. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/extra.h +72 -0
  48. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/functions.h +78 -0
  49. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/imports.h +75 -0
  50. llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/keys.h +53 -0
llmeval-env/lib/python3.10/site-packages/lxml/html/ElementSoup.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ __doc__ = """Legacy interface to the BeautifulSoup HTML parser.
2
+ """
3
+
4
+ __all__ = ["parse", "convert_tree"]
5
+
6
+ from .soupparser import convert_tree, parse as _parse
7
+
8
+ def parse(file, beautifulsoup=None, makeelement=None):
9
+ root = _parse(file, beautifulsoup=beautifulsoup, makeelement=makeelement)
10
+ return root.getroot()
llmeval-env/lib/python3.10/site-packages/lxml/html/__init__.py ADDED
@@ -0,0 +1,1923 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2004 Ian Bicking. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are
5
+ # met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in
12
+ # the documentation and/or other materials provided with the
13
+ # distribution.
14
+ #
15
+ # 3. Neither the name of Ian Bicking nor the names of its contributors may
16
+ # be used to endorse or promote products derived from this software
17
+ # without specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IAN BICKING OR
23
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ """The ``lxml.html`` tool set for HTML handling.
32
+ """
33
+
34
+
35
+ __all__ = [
36
+ 'document_fromstring', 'fragment_fromstring', 'fragments_fromstring', 'fromstring',
37
+ 'tostring', 'Element', 'defs', 'open_in_browser', 'submit_form',
38
+ 'find_rel_links', 'find_class', 'make_links_absolute',
39
+ 'resolve_base_href', 'iterlinks', 'rewrite_links', 'parse']
40
+
41
+
42
+ import copy
43
+ import re
44
+
45
+ from collections.abc import MutableMapping, MutableSet
46
+ from functools import partial
47
+ from urllib.parse import urljoin
48
+
49
+ from .. import etree
50
+ from . import defs
51
+ from ._setmixin import SetMixin
52
+
53
+
54
+ def __fix_docstring(s):
55
+ # TODO: remove and clean up doctests
56
+ if not s:
57
+ return s
58
+ sub = re.compile(r"^(\s*)u'", re.M).sub
59
+ return sub(r"\1'", s)
60
+
61
+
62
+ XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"
63
+
64
+ _rel_links_xpath = etree.XPath("descendant-or-self::a[@rel]|descendant-or-self::x:a[@rel]",
65
+ namespaces={'x':XHTML_NAMESPACE})
66
+ _options_xpath = etree.XPath("descendant-or-self::option|descendant-or-self::x:option",
67
+ namespaces={'x':XHTML_NAMESPACE})
68
+ _forms_xpath = etree.XPath("descendant-or-self::form|descendant-or-self::x:form",
69
+ namespaces={'x':XHTML_NAMESPACE})
70
+ #_class_xpath = etree.XPath(r"descendant-or-self::*[regexp:match(@class, concat('\b', $class_name, '\b'))]", {'regexp': 'http://exslt.org/regular-expressions'})
71
+ _class_xpath = etree.XPath("descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), concat(' ', $class_name, ' '))]")
72
+ _id_xpath = etree.XPath("descendant-or-self::*[@id=$id]")
73
+ _collect_string_content = etree.XPath("string()")
74
+ _iter_css_urls = re.compile(r'url\(('+'["][^"]*["]|'+"['][^']*[']|"+r'[^)]*)\)', re.I).finditer
75
+ _iter_css_imports = re.compile(r'@import "(.*?)"').finditer
76
+ _label_xpath = etree.XPath("//label[@for=$id]|//x:label[@for=$id]",
77
+ namespaces={'x':XHTML_NAMESPACE})
78
+ _archive_re = re.compile(r'[^ ]+')
79
+ _parse_meta_refresh_url = re.compile(
80
+ r'[^;=]*;\s*(?:url\s*=\s*)?(?P<url>.*)$', re.I).search
81
+
82
+
83
+ def _unquote_match(s, pos):
84
+ if s[:1] == '"' and s[-1:] == '"' or s[:1] == "'" and s[-1:] == "'":
85
+ return s[1:-1], pos+1
86
+ else:
87
+ return s,pos
88
+
89
+
90
+ def _transform_result(typ, result):
91
+ """Convert the result back into the input type.
92
+ """
93
+ if issubclass(typ, bytes):
94
+ return tostring(result, encoding='utf-8')
95
+ elif issubclass(typ, str):
96
+ return tostring(result, encoding='unicode')
97
+ else:
98
+ return result
99
+
100
+
101
+ def _nons(tag):
102
+ if isinstance(tag, str):
103
+ if tag[0] == '{' and tag[1:len(XHTML_NAMESPACE)+1] == XHTML_NAMESPACE:
104
+ return tag.split('}')[-1]
105
+ return tag
106
+
107
+
108
+ class Classes(MutableSet):
109
+ """Provides access to an element's class attribute as a set-like collection.
110
+ Usage::
111
+
112
+ >>> el = fromstring('<p class="hidden large">Text</p>')
113
+ >>> classes = el.classes # or: classes = Classes(el.attrib)
114
+ >>> classes |= ['block', 'paragraph']
115
+ >>> el.get('class')
116
+ 'hidden large block paragraph'
117
+ >>> classes.toggle('hidden')
118
+ False
119
+ >>> el.get('class')
120
+ 'large block paragraph'
121
+ >>> classes -= ('some', 'classes', 'block')
122
+ >>> el.get('class')
123
+ 'large paragraph'
124
+ """
125
+ def __init__(self, attributes):
126
+ self._attributes = attributes
127
+ self._get_class_value = partial(attributes.get, 'class', '')
128
+
129
+ def add(self, value):
130
+ """
131
+ Add a class.
132
+
133
+ This has no effect if the class is already present.
134
+ """
135
+ if not value or re.search(r'\s', value):
136
+ raise ValueError("Invalid class name: %r" % value)
137
+ classes = self._get_class_value().split()
138
+ if value in classes:
139
+ return
140
+ classes.append(value)
141
+ self._attributes['class'] = ' '.join(classes)
142
+
143
+ def discard(self, value):
144
+ """
145
+ Remove a class if it is currently present.
146
+
147
+ If the class is not present, do nothing.
148
+ """
149
+ if not value or re.search(r'\s', value):
150
+ raise ValueError("Invalid class name: %r" % value)
151
+ classes = [name for name in self._get_class_value().split()
152
+ if name != value]
153
+ if classes:
154
+ self._attributes['class'] = ' '.join(classes)
155
+ elif 'class' in self._attributes:
156
+ del self._attributes['class']
157
+
158
+ def remove(self, value):
159
+ """
160
+ Remove a class; it must currently be present.
161
+
162
+ If the class is not present, raise a KeyError.
163
+ """
164
+ if not value or re.search(r'\s', value):
165
+ raise ValueError("Invalid class name: %r" % value)
166
+ super().remove(value)
167
+
168
+ def __contains__(self, name):
169
+ classes = self._get_class_value()
170
+ return name in classes and name in classes.split()
171
+
172
+ def __iter__(self):
173
+ return iter(self._get_class_value().split())
174
+
175
+ def __len__(self):
176
+ return len(self._get_class_value().split())
177
+
178
+ # non-standard methods
179
+
180
+ def update(self, values):
181
+ """
182
+ Add all names from 'values'.
183
+ """
184
+ classes = self._get_class_value().split()
185
+ extended = False
186
+ for value in values:
187
+ if value not in classes:
188
+ classes.append(value)
189
+ extended = True
190
+ if extended:
191
+ self._attributes['class'] = ' '.join(classes)
192
+
193
+ def toggle(self, value):
194
+ """
195
+ Add a class name if it isn't there yet, or remove it if it exists.
196
+
197
+ Returns true if the class was added (and is now enabled) and
198
+ false if it was removed (and is now disabled).
199
+ """
200
+ if not value or re.search(r'\s', value):
201
+ raise ValueError("Invalid class name: %r" % value)
202
+ classes = self._get_class_value().split()
203
+ try:
204
+ classes.remove(value)
205
+ enabled = False
206
+ except ValueError:
207
+ classes.append(value)
208
+ enabled = True
209
+ if classes:
210
+ self._attributes['class'] = ' '.join(classes)
211
+ else:
212
+ del self._attributes['class']
213
+ return enabled
214
+
215
+
216
+ class HtmlMixin:
217
+
218
+ def set(self, key, value=None):
219
+ """set(self, key, value=None)
220
+
221
+ Sets an element attribute. If no value is provided, or if the value is None,
222
+ creates a 'boolean' attribute without value, e.g. "<form novalidate></form>"
223
+ for ``form.set('novalidate')``.
224
+ """
225
+ super().set(key, value)
226
+
227
+ @property
228
+ def classes(self):
229
+ """
230
+ A set-like wrapper around the 'class' attribute.
231
+ """
232
+ return Classes(self.attrib)
233
+
234
+ @classes.setter
235
+ def classes(self, classes):
236
+ assert isinstance(classes, Classes) # only allow "el.classes |= ..." etc.
237
+ value = classes._get_class_value()
238
+ if value:
239
+ self.set('class', value)
240
+ elif self.get('class') is not None:
241
+ del self.attrib['class']
242
+
243
+ @property
244
+ def base_url(self):
245
+ """
246
+ Returns the base URL, given when the page was parsed.
247
+
248
+ Use with ``urlparse.urljoin(el.base_url, href)`` to get
249
+ absolute URLs.
250
+ """
251
+ return self.getroottree().docinfo.URL
252
+
253
+ @property
254
+ def forms(self):
255
+ """
256
+ Return a list of all the forms
257
+ """
258
+ return _forms_xpath(self)
259
+
260
+ @property
261
+ def body(self):
262
+ """
263
+ Return the <body> element. Can be called from a child element
264
+ to get the document's head.
265
+ """
266
+ return self.xpath('//body|//x:body', namespaces={'x':XHTML_NAMESPACE})[0]
267
+
268
+ @property
269
+ def head(self):
270
+ """
271
+ Returns the <head> element. Can be called from a child
272
+ element to get the document's head.
273
+ """
274
+ return self.xpath('//head|//x:head', namespaces={'x':XHTML_NAMESPACE})[0]
275
+
276
+ @property
277
+ def label(self):
278
+ """
279
+ Get or set any <label> element associated with this element.
280
+ """
281
+ id = self.get('id')
282
+ if not id:
283
+ return None
284
+ result = _label_xpath(self, id=id)
285
+ if not result:
286
+ return None
287
+ else:
288
+ return result[0]
289
+
290
+ @label.setter
291
+ def label(self, label):
292
+ id = self.get('id')
293
+ if not id:
294
+ raise TypeError(
295
+ "You cannot set a label for an element (%r) that has no id"
296
+ % self)
297
+ if _nons(label.tag) != 'label':
298
+ raise TypeError(
299
+ "You can only assign label to a label element (not %r)"
300
+ % label)
301
+ label.set('for', id)
302
+
303
+ @label.deleter
304
+ def label(self):
305
+ label = self.label
306
+ if label is not None:
307
+ del label.attrib['for']
308
+
309
+ def drop_tree(self):
310
+ """
311
+ Removes this element from the tree, including its children and
312
+ text. The tail text is joined to the previous element or
313
+ parent.
314
+ """
315
+ parent = self.getparent()
316
+ assert parent is not None
317
+ if self.tail:
318
+ previous = self.getprevious()
319
+ if previous is None:
320
+ parent.text = (parent.text or '') + self.tail
321
+ else:
322
+ previous.tail = (previous.tail or '') + self.tail
323
+ parent.remove(self)
324
+
325
+ def drop_tag(self):
326
+ """
327
+ Remove the tag, but not its children or text. The children and text
328
+ are merged into the parent.
329
+
330
+ Example::
331
+
332
+ >>> h = fragment_fromstring('<div>Hello <b>World!</b></div>')
333
+ >>> h.find('.//b').drop_tag()
334
+ >>> print(tostring(h, encoding='unicode'))
335
+ <div>Hello World!</div>
336
+ """
337
+ parent = self.getparent()
338
+ assert parent is not None
339
+ previous = self.getprevious()
340
+ if self.text and isinstance(self.tag, str):
341
+ # not a Comment, etc.
342
+ if previous is None:
343
+ parent.text = (parent.text or '') + self.text
344
+ else:
345
+ previous.tail = (previous.tail or '') + self.text
346
+ if self.tail:
347
+ if len(self):
348
+ last = self[-1]
349
+ last.tail = (last.tail or '') + self.tail
350
+ elif previous is None:
351
+ parent.text = (parent.text or '') + self.tail
352
+ else:
353
+ previous.tail = (previous.tail or '') + self.tail
354
+ index = parent.index(self)
355
+ parent[index:index+1] = self[:]
356
+
357
+ def find_rel_links(self, rel):
358
+ """
359
+ Find any links like ``<a rel="{rel}">...</a>``; returns a list of elements.
360
+ """
361
+ rel = rel.lower()
362
+ return [el for el in _rel_links_xpath(self)
363
+ if el.get('rel').lower() == rel]
364
+
365
+ def find_class(self, class_name):
366
+ """
367
+ Find any elements with the given class name.
368
+ """
369
+ return _class_xpath(self, class_name=class_name)
370
+
371
+ def get_element_by_id(self, id, *default):
372
+ """
373
+ Get the first element in a document with the given id. If none is
374
+ found, return the default argument if provided or raise KeyError
375
+ otherwise.
376
+
377
+ Note that there can be more than one element with the same id,
378
+ and this isn't uncommon in HTML documents found in the wild.
379
+ Browsers return only the first match, and this function does
380
+ the same.
381
+ """
382
+ try:
383
+ # FIXME: should this check for multiple matches?
384
+ # browsers just return the first one
385
+ return _id_xpath(self, id=id)[0]
386
+ except IndexError:
387
+ if default:
388
+ return default[0]
389
+ else:
390
+ raise KeyError(id)
391
+
392
+ def text_content(self):
393
+ """
394
+ Return the text content of the tag (and the text in any children).
395
+ """
396
+ return _collect_string_content(self)
397
+
398
+ def cssselect(self, expr, translator='html'):
399
+ """
400
+ Run the CSS expression on this element and its children,
401
+ returning a list of the results.
402
+
403
+ Equivalent to lxml.cssselect.CSSSelect(expr, translator='html')(self)
404
+ -- note that pre-compiling the expression can provide a substantial
405
+ speedup.
406
+ """
407
+ # Do the import here to make the dependency optional.
408
+ from lxml.cssselect import CSSSelector
409
+ return CSSSelector(expr, translator=translator)(self)
410
+
411
+ ########################################
412
+ ## Link functions
413
+ ########################################
414
+
415
+ def make_links_absolute(self, base_url=None, resolve_base_href=True,
416
+ handle_failures=None):
417
+ """
418
+ Make all links in the document absolute, given the
419
+ ``base_url`` for the document (the full URL where the document
420
+ came from), or if no ``base_url`` is given, then the ``.base_url``
421
+ of the document.
422
+
423
+ If ``resolve_base_href`` is true, then any ``<base href>``
424
+ tags in the document are used *and* removed from the document.
425
+ If it is false then any such tag is ignored.
426
+
427
+ If ``handle_failures`` is None (default), a failure to process
428
+ a URL will abort the processing. If set to 'ignore', errors
429
+ are ignored. If set to 'discard', failing URLs will be removed.
430
+ """
431
+ if base_url is None:
432
+ base_url = self.base_url
433
+ if base_url is None:
434
+ raise TypeError(
435
+ "No base_url given, and the document has no base_url")
436
+ if resolve_base_href:
437
+ self.resolve_base_href()
438
+
439
+ if handle_failures == 'ignore':
440
+ def link_repl(href):
441
+ try:
442
+ return urljoin(base_url, href)
443
+ except ValueError:
444
+ return href
445
+ elif handle_failures == 'discard':
446
+ def link_repl(href):
447
+ try:
448
+ return urljoin(base_url, href)
449
+ except ValueError:
450
+ return None
451
+ elif handle_failures is None:
452
+ def link_repl(href):
453
+ return urljoin(base_url, href)
454
+ else:
455
+ raise ValueError(
456
+ "unexpected value for handle_failures: %r" % handle_failures)
457
+
458
+ self.rewrite_links(link_repl)
459
+
460
+ def resolve_base_href(self, handle_failures=None):
461
+ """
462
+ Find any ``<base href>`` tag in the document, and apply its
463
+ values to all links found in the document. Also remove the
464
+ tag once it has been applied.
465
+
466
+ If ``handle_failures`` is None (default), a failure to process
467
+ a URL will abort the processing. If set to 'ignore', errors
468
+ are ignored. If set to 'discard', failing URLs will be removed.
469
+ """
470
+ base_href = None
471
+ basetags = self.xpath('//base[@href]|//x:base[@href]',
472
+ namespaces={'x': XHTML_NAMESPACE})
473
+ for b in basetags:
474
+ base_href = b.get('href')
475
+ b.drop_tree()
476
+ if not base_href:
477
+ return
478
+ self.make_links_absolute(base_href, resolve_base_href=False,
479
+ handle_failures=handle_failures)
480
+
481
+ def iterlinks(self):
482
+ """
483
+ Yield (element, attribute, link, pos), where attribute may be None
484
+ (indicating the link is in the text). ``pos`` is the position
485
+ where the link occurs; often 0, but sometimes something else in
486
+ the case of links in stylesheets or style tags.
487
+
488
+ Note: <base href> is *not* taken into account in any way. The
489
+ link you get is exactly the link in the document.
490
+
491
+ Note: multiple links inside of a single text string or
492
+ attribute value are returned in reversed order. This makes it
493
+ possible to replace or delete them from the text string value
494
+ based on their reported text positions. Otherwise, a
495
+ modification at one text position can change the positions of
496
+ links reported later on.
497
+ """
498
+ link_attrs = defs.link_attrs
499
+ for el in self.iter(etree.Element):
500
+ attribs = el.attrib
501
+ tag = _nons(el.tag)
502
+ if tag == 'object':
503
+ codebase = None
504
+ ## <object> tags have attributes that are relative to
505
+ ## codebase
506
+ if 'codebase' in attribs:
507
+ codebase = el.get('codebase')
508
+ yield (el, 'codebase', codebase, 0)
509
+ for attrib in ('classid', 'data'):
510
+ if attrib in attribs:
511
+ value = el.get(attrib)
512
+ if codebase is not None:
513
+ value = urljoin(codebase, value)
514
+ yield (el, attrib, value, 0)
515
+ if 'archive' in attribs:
516
+ for match in _archive_re.finditer(el.get('archive')):
517
+ value = match.group(0)
518
+ if codebase is not None:
519
+ value = urljoin(codebase, value)
520
+ yield (el, 'archive', value, match.start())
521
+ else:
522
+ for attrib in link_attrs:
523
+ if attrib in attribs:
524
+ yield (el, attrib, attribs[attrib], 0)
525
+ if tag == 'meta':
526
+ http_equiv = attribs.get('http-equiv', '').lower()
527
+ if http_equiv == 'refresh':
528
+ content = attribs.get('content', '')
529
+ match = _parse_meta_refresh_url(content)
530
+ url = (match.group('url') if match else content).strip()
531
+ # unexpected content means the redirect won't work, but we might
532
+ # as well be permissive and return the entire string.
533
+ if url:
534
+ url, pos = _unquote_match(
535
+ url, match.start('url') if match else content.find(url))
536
+ yield (el, 'content', url, pos)
537
+ elif tag == 'param':
538
+ valuetype = el.get('valuetype') or ''
539
+ if valuetype.lower() == 'ref':
540
+ ## FIXME: while it's fine we *find* this link,
541
+ ## according to the spec we aren't supposed to
542
+ ## actually change the value, including resolving
543
+ ## it. It can also still be a link, even if it
544
+ ## doesn't have a valuetype="ref" (which seems to be the norm)
545
+ ## http://www.w3.org/TR/html401/struct/objects.html#adef-valuetype
546
+ yield (el, 'value', el.get('value'), 0)
547
+ elif tag == 'style' and el.text:
548
+ urls = [
549
+ # (start_pos, url)
550
+ _unquote_match(match.group(1), match.start(1))[::-1]
551
+ for match in _iter_css_urls(el.text)
552
+ ] + [
553
+ (match.start(1), match.group(1))
554
+ for match in _iter_css_imports(el.text)
555
+ ]
556
+ if urls:
557
+ # sort by start pos to bring both match sets back into order
558
+ # and reverse the list to report correct positions despite
559
+ # modifications
560
+ urls.sort(reverse=True)
561
+ for start, url in urls:
562
+ yield (el, None, url, start)
563
+ if 'style' in attribs:
564
+ urls = list(_iter_css_urls(attribs['style']))
565
+ if urls:
566
+ # return in reversed order to simplify in-place modifications
567
+ for match in urls[::-1]:
568
+ url, start = _unquote_match(match.group(1), match.start(1))
569
+ yield (el, 'style', url, start)
570
+
571
+ def rewrite_links(self, link_repl_func, resolve_base_href=True,
572
+ base_href=None):
573
+ """
574
+ Rewrite all the links in the document. For each link
575
+ ``link_repl_func(link)`` will be called, and the return value
576
+ will replace the old link.
577
+
578
+ Note that links may not be absolute (unless you first called
579
+ ``make_links_absolute()``), and may be internal (e.g.,
580
+ ``'#anchor'``). They can also be values like
581
+ ``'mailto:email'`` or ``'javascript:expr'``.
582
+
583
+ If you give ``base_href`` then all links passed to
584
+ ``link_repl_func()`` will take that into account.
585
+
586
+ If the ``link_repl_func`` returns None, the attribute or
587
+ tag text will be removed completely.
588
+ """
589
+ if base_href is not None:
590
+ # FIXME: this can be done in one pass with a wrapper
591
+ # around link_repl_func
592
+ self.make_links_absolute(
593
+ base_href, resolve_base_href=resolve_base_href)
594
+ elif resolve_base_href:
595
+ self.resolve_base_href()
596
+
597
+ for el, attrib, link, pos in self.iterlinks():
598
+ new_link = link_repl_func(link.strip())
599
+ if new_link == link:
600
+ continue
601
+ if new_link is None:
602
+ # Remove the attribute or element content
603
+ if attrib is None:
604
+ el.text = ''
605
+ else:
606
+ del el.attrib[attrib]
607
+ continue
608
+
609
+ if attrib is None:
610
+ new = el.text[:pos] + new_link + el.text[pos+len(link):]
611
+ el.text = new
612
+ else:
613
+ cur = el.get(attrib)
614
+ if not pos and len(cur) == len(link):
615
+ new = new_link # most common case
616
+ else:
617
+ new = cur[:pos] + new_link + cur[pos+len(link):]
618
+ el.set(attrib, new)
619
+
620
+
621
+ class _MethodFunc:
622
+ """
623
+ An object that represents a method on an element as a function;
624
+ the function takes either an element or an HTML string. It
625
+ returns whatever the function normally returns, or if the function
626
+ works in-place (and so returns None) it returns a serialized form
627
+ of the resulting document.
628
+ """
629
+ def __init__(self, name, copy=False, source_class=HtmlMixin):
630
+ self.name = name
631
+ self.copy = copy
632
+ self.__doc__ = getattr(source_class, self.name).__doc__
633
+ def __call__(self, doc, *args, **kw):
634
+ result_type = type(doc)
635
+ if isinstance(doc, (str, bytes)):
636
+ if 'copy' in kw:
637
+ raise TypeError(
638
+ "The keyword 'copy' can only be used with element inputs to %s, not a string input" % self.name)
639
+ doc = fromstring(doc, **kw)
640
+ else:
641
+ if 'copy' in kw:
642
+ make_a_copy = kw.pop('copy')
643
+ else:
644
+ make_a_copy = self.copy
645
+ if make_a_copy:
646
+ doc = copy.deepcopy(doc)
647
+ meth = getattr(doc, self.name)
648
+ result = meth(*args, **kw)
649
+ # FIXME: this None test is a bit sloppy
650
+ if result is None:
651
+ # Then return what we got in
652
+ return _transform_result(result_type, doc)
653
+ else:
654
+ return result
655
+
656
+
657
+ find_rel_links = _MethodFunc('find_rel_links', copy=False)
658
+ find_class = _MethodFunc('find_class', copy=False)
659
+ make_links_absolute = _MethodFunc('make_links_absolute', copy=True)
660
+ resolve_base_href = _MethodFunc('resolve_base_href', copy=True)
661
+ iterlinks = _MethodFunc('iterlinks', copy=False)
662
+ rewrite_links = _MethodFunc('rewrite_links', copy=True)
663
+
664
+
665
+ class HtmlComment(HtmlMixin, etree.CommentBase):
666
+ pass
667
+
668
+
669
+ class HtmlElement(HtmlMixin, etree.ElementBase):
670
+ pass
671
+
672
+
673
+ class HtmlProcessingInstruction(HtmlMixin, etree.PIBase):
674
+ pass
675
+
676
+
677
+ class HtmlEntity(HtmlMixin, etree.EntityBase):
678
+ pass
679
+
680
+
681
+ class HtmlElementClassLookup(etree.CustomElementClassLookup):
682
+ """A lookup scheme for HTML Element classes.
683
+
684
+ To create a lookup instance with different Element classes, pass a tag
685
+ name mapping of Element classes in the ``classes`` keyword argument and/or
686
+ a tag name mapping of Mixin classes in the ``mixins`` keyword argument.
687
+ The special key '*' denotes a Mixin class that should be mixed into all
688
+ Element classes.
689
+ """
690
+ _default_element_classes = {}
691
+
692
+ def __init__(self, classes=None, mixins=None):
693
+ etree.CustomElementClassLookup.__init__(self)
694
+ if classes is None:
695
+ classes = self._default_element_classes.copy()
696
+ if mixins:
697
+ mixers = {}
698
+ for name, value in mixins:
699
+ if name == '*':
700
+ for n in classes.keys():
701
+ mixers.setdefault(n, []).append(value)
702
+ else:
703
+ mixers.setdefault(name, []).append(value)
704
+ for name, mix_bases in mixers.items():
705
+ cur = classes.get(name, HtmlElement)
706
+ bases = tuple(mix_bases + [cur])
707
+ classes[name] = type(cur.__name__, bases, {})
708
+ self._element_classes = classes
709
+
710
+ def lookup(self, node_type, document, namespace, name):
711
+ if node_type == 'element':
712
+ return self._element_classes.get(name.lower(), HtmlElement)
713
+ elif node_type == 'comment':
714
+ return HtmlComment
715
+ elif node_type == 'PI':
716
+ return HtmlProcessingInstruction
717
+ elif node_type == 'entity':
718
+ return HtmlEntity
719
+ # Otherwise normal lookup
720
+ return None
721
+
722
+
723
+ ################################################################################
724
+ # parsing
725
+ ################################################################################
726
+
727
+ _looks_like_full_html_unicode = re.compile(
728
+ r'^\s*<(?:html|!doctype)', re.I).match
729
+ _looks_like_full_html_bytes = re.compile(
730
+ br'^\s*<(?:html|!doctype)', re.I).match
731
+
732
+
733
+ def document_fromstring(html, parser=None, ensure_head_body=False, **kw):
734
+ if parser is None:
735
+ parser = html_parser
736
+ value = etree.fromstring(html, parser, **kw)
737
+ if value is None:
738
+ raise etree.ParserError(
739
+ "Document is empty")
740
+ if ensure_head_body and value.find('head') is None:
741
+ value.insert(0, Element('head'))
742
+ if ensure_head_body and value.find('body') is None:
743
+ value.append(Element('body'))
744
+ return value
745
+
746
+
747
+ def fragments_fromstring(html, no_leading_text=False, base_url=None,
748
+ parser=None, **kw):
749
+ """Parses several HTML elements, returning a list of elements.
750
+
751
+ The first item in the list may be a string.
752
+ If no_leading_text is true, then it will be an error if there is
753
+ leading text, and it will always be a list of only elements.
754
+
755
+ base_url will set the document's base_url attribute
756
+ (and the tree's docinfo.URL).
757
+ """
758
+ if parser is None:
759
+ parser = html_parser
760
+ # FIXME: check what happens when you give html with a body, head, etc.
761
+ if isinstance(html, bytes):
762
+ if not _looks_like_full_html_bytes(html):
763
+ # can't use %-formatting in early Py3 versions
764
+ html = (b'<html><body>' + html +
765
+ b'</body></html>')
766
+ else:
767
+ if not _looks_like_full_html_unicode(html):
768
+ html = '<html><body>%s</body></html>' % html
769
+ doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
770
+ assert _nons(doc.tag) == 'html'
771
+ bodies = [e for e in doc if _nons(e.tag) == 'body']
772
+ assert len(bodies) == 1, ("too many bodies: %r in %r" % (bodies, html))
773
+ body = bodies[0]
774
+ elements = []
775
+ if no_leading_text and body.text and body.text.strip():
776
+ raise etree.ParserError(
777
+ "There is leading text: %r" % body.text)
778
+ if body.text and body.text.strip():
779
+ elements.append(body.text)
780
+ elements.extend(body)
781
+ # FIXME: removing the reference to the parent artificial document
782
+ # would be nice
783
+ return elements
784
+
785
+
786
+ def fragment_fromstring(html, create_parent=False, base_url=None,
787
+ parser=None, **kw):
788
+ """
789
+ Parses a single HTML element; it is an error if there is more than
790
+ one element, or if anything but whitespace precedes or follows the
791
+ element.
792
+
793
+ If ``create_parent`` is true (or is a tag name) then a parent node
794
+ will be created to encapsulate the HTML in a single element. In this
795
+ case, leading or trailing text is also allowed, as are multiple elements
796
+ as result of the parsing.
797
+
798
+ Passing a ``base_url`` will set the document's ``base_url`` attribute
799
+ (and the tree's docinfo.URL).
800
+ """
801
+ if parser is None:
802
+ parser = html_parser
803
+
804
+ accept_leading_text = bool(create_parent)
805
+
806
+ elements = fragments_fromstring(
807
+ html, parser=parser, no_leading_text=not accept_leading_text,
808
+ base_url=base_url, **kw)
809
+
810
+ if create_parent:
811
+ if not isinstance(create_parent, str):
812
+ create_parent = 'div'
813
+ new_root = Element(create_parent)
814
+ if elements:
815
+ if isinstance(elements[0], str):
816
+ new_root.text = elements[0]
817
+ del elements[0]
818
+ new_root.extend(elements)
819
+ return new_root
820
+
821
+ if not elements:
822
+ raise etree.ParserError('No elements found')
823
+ if len(elements) > 1:
824
+ raise etree.ParserError(
825
+ "Multiple elements found (%s)"
826
+ % ', '.join([_element_name(e) for e in elements]))
827
+ el = elements[0]
828
+ if el.tail and el.tail.strip():
829
+ raise etree.ParserError(
830
+ "Element followed by text: %r" % el.tail)
831
+ el.tail = None
832
+ return el
833
+
834
+
835
+ def fromstring(html, base_url=None, parser=None, **kw):
836
+ """
837
+ Parse the html, returning a single element/document.
838
+
839
+ This tries to minimally parse the chunk of text, without knowing if it
840
+ is a fragment or a document.
841
+
842
+ base_url will set the document's base_url attribute (and the tree's docinfo.URL)
843
+ """
844
+ if parser is None:
845
+ parser = html_parser
846
+ if isinstance(html, bytes):
847
+ is_full_html = _looks_like_full_html_bytes(html)
848
+ else:
849
+ is_full_html = _looks_like_full_html_unicode(html)
850
+ doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
851
+ if is_full_html:
852
+ return doc
853
+ # otherwise, lets parse it out...
854
+ bodies = doc.findall('body')
855
+ if not bodies:
856
+ bodies = doc.findall('{%s}body' % XHTML_NAMESPACE)
857
+ if bodies:
858
+ body = bodies[0]
859
+ if len(bodies) > 1:
860
+ # Somehow there are multiple bodies, which is bad, but just
861
+ # smash them into one body
862
+ for other_body in bodies[1:]:
863
+ if other_body.text:
864
+ if len(body):
865
+ body[-1].tail = (body[-1].tail or '') + other_body.text
866
+ else:
867
+ body.text = (body.text or '') + other_body.text
868
+ body.extend(other_body)
869
+ # We'll ignore tail
870
+ # I guess we are ignoring attributes too
871
+ other_body.drop_tree()
872
+ else:
873
+ body = None
874
+ heads = doc.findall('head')
875
+ if not heads:
876
+ heads = doc.findall('{%s}head' % XHTML_NAMESPACE)
877
+ if heads:
878
+ # Well, we have some sort of structure, so lets keep it all
879
+ head = heads[0]
880
+ if len(heads) > 1:
881
+ for other_head in heads[1:]:
882
+ head.extend(other_head)
883
+ # We don't care about text or tail in a head
884
+ other_head.drop_tree()
885
+ return doc
886
+ if body is None:
887
+ return doc
888
+ if (len(body) == 1 and (not body.text or not body.text.strip())
889
+ and (not body[-1].tail or not body[-1].tail.strip())):
890
+ # The body has just one element, so it was probably a single
891
+ # element passed in
892
+ return body[0]
893
+ # Now we have a body which represents a bunch of tags which have the
894
+ # content that was passed in. We will create a fake container, which
895
+ # is the body tag, except <body> implies too much structure.
896
+ if _contains_block_level_tag(body):
897
+ body.tag = 'div'
898
+ else:
899
+ body.tag = 'span'
900
+ return body
901
+
902
+
903
+ def parse(filename_or_url, parser=None, base_url=None, **kw):
904
+ """
905
+ Parse a filename, URL, or file-like object into an HTML document
906
+ tree. Note: this returns a tree, not an element. Use
907
+ ``parse(...).getroot()`` to get the document root.
908
+
909
+ You can override the base URL with the ``base_url`` keyword. This
910
+ is most useful when parsing from a file-like object.
911
+ """
912
+ if parser is None:
913
+ parser = html_parser
914
+ return etree.parse(filename_or_url, parser, base_url=base_url, **kw)
915
+
916
+
917
+ def _contains_block_level_tag(el):
918
+ # FIXME: I could do this with XPath, but would that just be
919
+ # unnecessarily slow?
920
+ for el in el.iter(etree.Element):
921
+ if _nons(el.tag) in defs.block_tags:
922
+ return True
923
+ return False
924
+
925
+
926
+ def _element_name(el):
927
+ if isinstance(el, etree.CommentBase):
928
+ return 'comment'
929
+ elif isinstance(el, str):
930
+ return 'string'
931
+ else:
932
+ return _nons(el.tag)
933
+
934
+
935
+ ################################################################################
936
+ # form handling
937
+ ################################################################################
938
+
939
+ class FormElement(HtmlElement):
940
+ """
941
+ Represents a <form> element.
942
+ """
943
+
944
+ @property
945
+ def inputs(self):
946
+ """
947
+ Returns an accessor for all the input elements in the form.
948
+
949
+ See `InputGetter` for more information about the object.
950
+ """
951
+ return InputGetter(self)
952
+
953
+ @property
954
+ def fields(self):
955
+ """
956
+ Dictionary-like object that represents all the fields in this
957
+ form. You can set values in this dictionary to effect the
958
+ form.
959
+ """
960
+ return FieldsDict(self.inputs)
961
+
962
+ @fields.setter
963
+ def fields(self, value):
964
+ fields = self.fields
965
+ prev_keys = fields.keys()
966
+ for key, value in value.items():
967
+ if key in prev_keys:
968
+ prev_keys.remove(key)
969
+ fields[key] = value
970
+ for key in prev_keys:
971
+ if key is None:
972
+ # Case of an unnamed input; these aren't really
973
+ # expressed in form_values() anyway.
974
+ continue
975
+ fields[key] = None
976
+
977
+ def _name(self):
978
+ if self.get('name'):
979
+ return self.get('name')
980
+ elif self.get('id'):
981
+ return '#' + self.get('id')
982
+ iter_tags = self.body.iter
983
+ forms = list(iter_tags('form'))
984
+ if not forms:
985
+ forms = list(iter_tags('{%s}form' % XHTML_NAMESPACE))
986
+ return str(forms.index(self))
987
+
988
+ def form_values(self):
989
+ """
990
+ Return a list of tuples of the field values for the form.
991
+ This is suitable to be passed to ``urllib.urlencode()``.
992
+ """
993
+ results = []
994
+ for el in self.inputs:
995
+ name = el.name
996
+ if not name or 'disabled' in el.attrib:
997
+ continue
998
+ tag = _nons(el.tag)
999
+ if tag == 'textarea':
1000
+ results.append((name, el.value))
1001
+ elif tag == 'select':
1002
+ value = el.value
1003
+ if el.multiple:
1004
+ for v in value:
1005
+ results.append((name, v))
1006
+ elif value is not None:
1007
+ results.append((name, el.value))
1008
+ else:
1009
+ assert tag == 'input', (
1010
+ "Unexpected tag: %r" % el)
1011
+ if el.checkable and not el.checked:
1012
+ continue
1013
+ if el.type in ('submit', 'image', 'reset', 'file'):
1014
+ continue
1015
+ value = el.value
1016
+ if value is not None:
1017
+ results.append((name, el.value))
1018
+ return results
1019
+
1020
+ @property
1021
+ def action(self):
1022
+ """
1023
+ Get/set the form's ``action`` attribute.
1024
+ """
1025
+ base_url = self.base_url
1026
+ action = self.get('action')
1027
+ if base_url and action is not None:
1028
+ return urljoin(base_url, action)
1029
+ else:
1030
+ return action
1031
+
1032
+ @action.setter
1033
+ def action(self, value):
1034
+ self.set('action', value)
1035
+
1036
+ @action.deleter
1037
+ def action(self):
1038
+ attrib = self.attrib
1039
+ if 'action' in attrib:
1040
+ del attrib['action']
1041
+
1042
+ @property
1043
+ def method(self):
1044
+ """
1045
+ Get/set the form's method. Always returns a capitalized
1046
+ string, and defaults to ``'GET'``
1047
+ """
1048
+ return self.get('method', 'GET').upper()
1049
+
1050
+ @method.setter
1051
+ def method(self, value):
1052
+ self.set('method', value.upper())
1053
+
1054
+
1055
+ HtmlElementClassLookup._default_element_classes['form'] = FormElement
1056
+
1057
+
1058
+ def submit_form(form, extra_values=None, open_http=None):
1059
+ """
1060
+ Helper function to submit a form. Returns a file-like object, as from
1061
+ ``urllib.urlopen()``. This object also has a ``.geturl()`` function,
1062
+ which shows the URL if there were any redirects.
1063
+
1064
+ You can use this like::
1065
+
1066
+ form = doc.forms[0]
1067
+ form.inputs['foo'].value = 'bar' # etc
1068
+ response = form.submit()
1069
+ doc = parse(response)
1070
+ doc.make_links_absolute(response.geturl())
1071
+
1072
+ To change the HTTP requester, pass a function as ``open_http`` keyword
1073
+ argument that opens the URL for you. The function must have the following
1074
+ signature::
1075
+
1076
+ open_http(method, URL, values)
1077
+
1078
+ The action is one of 'GET' or 'POST', the URL is the target URL as a
1079
+ string, and the values are a sequence of ``(name, value)`` tuples with the
1080
+ form data.
1081
+ """
1082
+ values = form.form_values()
1083
+ if extra_values:
1084
+ if hasattr(extra_values, 'items'):
1085
+ extra_values = extra_values.items()
1086
+ values.extend(extra_values)
1087
+ if open_http is None:
1088
+ open_http = open_http_urllib
1089
+ if form.action:
1090
+ url = form.action
1091
+ else:
1092
+ url = form.base_url
1093
+ return open_http(form.method, url, values)
1094
+
1095
+
1096
+ def open_http_urllib(method, url, values):
1097
+ if not url:
1098
+ raise ValueError("cannot submit, no URL provided")
1099
+ ## FIXME: should test that it's not a relative URL or something
1100
+ try:
1101
+ from urllib import urlencode, urlopen
1102
+ except ImportError: # Python 3
1103
+ from urllib.request import urlopen
1104
+ from urllib.parse import urlencode
1105
+ if method == 'GET':
1106
+ if '?' in url:
1107
+ url += '&'
1108
+ else:
1109
+ url += '?'
1110
+ url += urlencode(values)
1111
+ data = None
1112
+ else:
1113
+ data = urlencode(values)
1114
+ if not isinstance(data, bytes):
1115
+ data = data.encode('ASCII')
1116
+ return urlopen(url, data)
1117
+
1118
+
1119
+ class FieldsDict(MutableMapping):
1120
+
1121
+ def __init__(self, inputs):
1122
+ self.inputs = inputs
1123
+ def __getitem__(self, item):
1124
+ return self.inputs[item].value
1125
+ def __setitem__(self, item, value):
1126
+ self.inputs[item].value = value
1127
+ def __delitem__(self, item):
1128
+ raise KeyError(
1129
+ "You cannot remove keys from ElementDict")
1130
+ def keys(self):
1131
+ return self.inputs.keys()
1132
+ def __contains__(self, item):
1133
+ return item in self.inputs
1134
+ def __iter__(self):
1135
+ return iter(self.inputs.keys())
1136
+ def __len__(self):
1137
+ return len(self.inputs)
1138
+
1139
+ def __repr__(self):
1140
+ return '<%s for form %s>' % (
1141
+ self.__class__.__name__,
1142
+ self.inputs.form._name())
1143
+
1144
+
1145
+ class InputGetter:
1146
+
1147
+ """
1148
+ An accessor that represents all the input fields in a form.
1149
+
1150
+ You can get fields by name from this, with
1151
+ ``form.inputs['field_name']``. If there are a set of checkboxes
1152
+ with the same name, they are returned as a list (a `CheckboxGroup`
1153
+ which also allows value setting). Radio inputs are handled
1154
+ similarly. Use ``.keys()`` and ``.items()`` to process all fields
1155
+ in this way.
1156
+
1157
+ You can also iterate over this to get all input elements. This
1158
+ won't return the same thing as if you get all the names, as
1159
+ checkboxes and radio elements are returned individually.
1160
+ """
1161
+
1162
+ def __init__(self, form):
1163
+ self.form = form
1164
+
1165
+ def __repr__(self):
1166
+ return '<%s for form %s>' % (
1167
+ self.__class__.__name__,
1168
+ self.form._name())
1169
+
1170
+ ## FIXME: there should be more methods, and it's unclear if this is
1171
+ ## a dictionary-like object or list-like object
1172
+
1173
+ def __getitem__(self, name):
1174
+ fields = [field for field in self if field.name == name]
1175
+ if not fields:
1176
+ raise KeyError("No input element with the name %r" % name)
1177
+
1178
+ input_type = fields[0].get('type')
1179
+ if input_type == 'radio' and len(fields) > 1:
1180
+ group = RadioGroup(fields)
1181
+ group.name = name
1182
+ return group
1183
+ elif input_type == 'checkbox' and len(fields) > 1:
1184
+ group = CheckboxGroup(fields)
1185
+ group.name = name
1186
+ return group
1187
+ else:
1188
+ # I don't like throwing away elements like this
1189
+ return fields[0]
1190
+
1191
+ def __contains__(self, name):
1192
+ for field in self:
1193
+ if field.name == name:
1194
+ return True
1195
+ return False
1196
+
1197
+ def keys(self):
1198
+ """
1199
+ Returns all unique field names, in document order.
1200
+
1201
+ :return: A list of all unique field names.
1202
+ """
1203
+ names = []
1204
+ seen = {None}
1205
+ for el in self:
1206
+ name = el.name
1207
+ if name not in seen:
1208
+ names.append(name)
1209
+ seen.add(name)
1210
+ return names
1211
+
1212
+ def items(self):
1213
+ """
1214
+ Returns all fields with their names, similar to dict.items().
1215
+
1216
+ :return: A list of (name, field) tuples.
1217
+ """
1218
+ items = []
1219
+ seen = set()
1220
+ for el in self:
1221
+ name = el.name
1222
+ if name not in seen:
1223
+ seen.add(name)
1224
+ items.append((name, self[name]))
1225
+ return items
1226
+
1227
+ def __iter__(self):
1228
+ return self.form.iter('select', 'input', 'textarea')
1229
+
1230
+ def __len__(self):
1231
+ return sum(1 for _ in self)
1232
+
1233
+
1234
+ class InputMixin:
1235
+ """
1236
+ Mix-in for all input elements (input, select, and textarea)
1237
+ """
1238
+ @property
1239
+ def name(self):
1240
+ """
1241
+ Get/set the name of the element
1242
+ """
1243
+ return self.get('name')
1244
+
1245
+ @name.setter
1246
+ def name(self, value):
1247
+ self.set('name', value)
1248
+
1249
+ @name.deleter
1250
+ def name(self):
1251
+ attrib = self.attrib
1252
+ if 'name' in attrib:
1253
+ del attrib['name']
1254
+
1255
+ def __repr__(self):
1256
+ type_name = getattr(self, 'type', None)
1257
+ if type_name:
1258
+ type_name = ' type=%r' % type_name
1259
+ else:
1260
+ type_name = ''
1261
+ return '<%s %x name=%r%s>' % (
1262
+ self.__class__.__name__, id(self), self.name, type_name)
1263
+
1264
+
1265
+ class TextareaElement(InputMixin, HtmlElement):
1266
+ """
1267
+ ``<textarea>`` element. You can get the name with ``.name`` and
1268
+ get/set the value with ``.value``
1269
+ """
1270
+ @property
1271
+ def value(self):
1272
+ """
1273
+ Get/set the value (which is the contents of this element)
1274
+ """
1275
+ content = self.text or ''
1276
+ if self.tag.startswith("{%s}" % XHTML_NAMESPACE):
1277
+ serialisation_method = 'xml'
1278
+ else:
1279
+ serialisation_method = 'html'
1280
+ for el in self:
1281
+ # it's rare that we actually get here, so let's not use ''.join()
1282
+ content += etree.tostring(
1283
+ el, method=serialisation_method, encoding='unicode')
1284
+ return content
1285
+
1286
+ @value.setter
1287
+ def value(self, value):
1288
+ del self[:]
1289
+ self.text = value
1290
+
1291
+ @value.deleter
1292
+ def value(self):
1293
+ self.text = ''
1294
+ del self[:]
1295
+
1296
+
1297
+ HtmlElementClassLookup._default_element_classes['textarea'] = TextareaElement
1298
+
1299
+
1300
+ class SelectElement(InputMixin, HtmlElement):
1301
+ """
1302
+ ``<select>`` element. You can get the name with ``.name``.
1303
+
1304
+ ``.value`` will be the value of the selected option, unless this
1305
+ is a multi-select element (``<select multiple>``), in which case
1306
+ it will be a set-like object. In either case ``.value_options``
1307
+ gives the possible values.
1308
+
1309
+ The boolean attribute ``.multiple`` shows if this is a
1310
+ multi-select.
1311
+ """
1312
+ @property
1313
+ def value(self):
1314
+ """
1315
+ Get/set the value of this select (the selected option).
1316
+
1317
+ If this is a multi-select, this is a set-like object that
1318
+ represents all the selected options.
1319
+ """
1320
+ if self.multiple:
1321
+ return MultipleSelectOptions(self)
1322
+ options = _options_xpath(self)
1323
+
1324
+ try:
1325
+ selected_option = next(el for el in reversed(options) if el.get('selected') is not None)
1326
+ except StopIteration:
1327
+ try:
1328
+ selected_option = next(el for el in options if el.get('disabled') is None)
1329
+ except StopIteration:
1330
+ return None
1331
+ value = selected_option.get('value')
1332
+ if value is None:
1333
+ value = (selected_option.text or '').strip()
1334
+ return value
1335
+
1336
+ @value.setter
1337
+ def value(self, value):
1338
+ if self.multiple:
1339
+ if isinstance(value, str):
1340
+ raise TypeError("You must pass in a sequence")
1341
+ values = self.value
1342
+ values.clear()
1343
+ values.update(value)
1344
+ return
1345
+ checked_option = None
1346
+ if value is not None:
1347
+ for el in _options_xpath(self):
1348
+ opt_value = el.get('value')
1349
+ if opt_value is None:
1350
+ opt_value = (el.text or '').strip()
1351
+ if opt_value == value:
1352
+ checked_option = el
1353
+ break
1354
+ else:
1355
+ raise ValueError(
1356
+ "There is no option with the value of %r" % value)
1357
+ for el in _options_xpath(self):
1358
+ if 'selected' in el.attrib:
1359
+ del el.attrib['selected']
1360
+ if checked_option is not None:
1361
+ checked_option.set('selected', '')
1362
+
1363
+ @value.deleter
1364
+ def value(self):
1365
+ # FIXME: should del be allowed at all?
1366
+ if self.multiple:
1367
+ self.value.clear()
1368
+ else:
1369
+ self.value = None
1370
+
1371
+ @property
1372
+ def value_options(self):
1373
+ """
1374
+ All the possible values this select can have (the ``value``
1375
+ attribute of all the ``<option>`` elements.
1376
+ """
1377
+ options = []
1378
+ for el in _options_xpath(self):
1379
+ value = el.get('value')
1380
+ if value is None:
1381
+ value = (el.text or '').strip()
1382
+ options.append(value)
1383
+ return options
1384
+
1385
+ @property
1386
+ def multiple(self):
1387
+ """
1388
+ Boolean attribute: is there a ``multiple`` attribute on this element.
1389
+ """
1390
+ return 'multiple' in self.attrib
1391
+
1392
+ @multiple.setter
1393
+ def multiple(self, value):
1394
+ if value:
1395
+ self.set('multiple', '')
1396
+ elif 'multiple' in self.attrib:
1397
+ del self.attrib['multiple']
1398
+
1399
+
1400
+ HtmlElementClassLookup._default_element_classes['select'] = SelectElement
1401
+
1402
+
1403
+ class MultipleSelectOptions(SetMixin):
1404
+ """
1405
+ Represents all the selected options in a ``<select multiple>`` element.
1406
+
1407
+ You can add to this set-like option to select an option, or remove
1408
+ to unselect the option.
1409
+ """
1410
+
1411
+ def __init__(self, select):
1412
+ self.select = select
1413
+
1414
+ @property
1415
+ def options(self):
1416
+ """
1417
+ Iterator of all the ``<option>`` elements.
1418
+ """
1419
+ return iter(_options_xpath(self.select))
1420
+
1421
+ def __iter__(self):
1422
+ for option in self.options:
1423
+ if 'selected' in option.attrib:
1424
+ opt_value = option.get('value')
1425
+ if opt_value is None:
1426
+ opt_value = (option.text or '').strip()
1427
+ yield opt_value
1428
+
1429
+ def add(self, item):
1430
+ for option in self.options:
1431
+ opt_value = option.get('value')
1432
+ if opt_value is None:
1433
+ opt_value = (option.text or '').strip()
1434
+ if opt_value == item:
1435
+ option.set('selected', '')
1436
+ break
1437
+ else:
1438
+ raise ValueError(
1439
+ "There is no option with the value %r" % item)
1440
+
1441
+ def remove(self, item):
1442
+ for option in self.options:
1443
+ opt_value = option.get('value')
1444
+ if opt_value is None:
1445
+ opt_value = (option.text or '').strip()
1446
+ if opt_value == item:
1447
+ if 'selected' in option.attrib:
1448
+ del option.attrib['selected']
1449
+ else:
1450
+ raise ValueError(
1451
+ "The option %r is not currently selected" % item)
1452
+ break
1453
+ else:
1454
+ raise ValueError(
1455
+ "There is not option with the value %r" % item)
1456
+
1457
+ def __repr__(self):
1458
+ return '<%s {%s} for select name=%r>' % (
1459
+ self.__class__.__name__,
1460
+ ', '.join([repr(v) for v in self]),
1461
+ self.select.name)
1462
+
1463
+
1464
+ class RadioGroup(list):
1465
+ """
1466
+ This object represents several ``<input type=radio>`` elements
1467
+ that have the same name.
1468
+
1469
+ You can use this like a list, but also use the property
1470
+ ``.value`` to check/uncheck inputs. Also you can use
1471
+ ``.value_options`` to get the possible values.
1472
+ """
1473
+ @property
1474
+ def value(self):
1475
+ """
1476
+ Get/set the value, which checks the radio with that value (and
1477
+ unchecks any other value).
1478
+ """
1479
+ for el in self:
1480
+ if 'checked' in el.attrib:
1481
+ return el.get('value')
1482
+ return None
1483
+
1484
+ @value.setter
1485
+ def value(self, value):
1486
+ checked_option = None
1487
+ if value is not None:
1488
+ for el in self:
1489
+ if el.get('value') == value:
1490
+ checked_option = el
1491
+ break
1492
+ else:
1493
+ raise ValueError("There is no radio input with the value %r" % value)
1494
+ for el in self:
1495
+ if 'checked' in el.attrib:
1496
+ del el.attrib['checked']
1497
+ if checked_option is not None:
1498
+ checked_option.set('checked', '')
1499
+
1500
+ @value.deleter
1501
+ def value(self):
1502
+ self.value = None
1503
+
1504
+ @property
1505
+ def value_options(self):
1506
+ """
1507
+ Returns a list of all the possible values.
1508
+ """
1509
+ return [el.get('value') for el in self]
1510
+
1511
+ def __repr__(self):
1512
+ return '%s(%s)' % (
1513
+ self.__class__.__name__,
1514
+ list.__repr__(self))
1515
+
1516
+
1517
+ class CheckboxGroup(list):
1518
+ """
1519
+ Represents a group of checkboxes (``<input type=checkbox>``) that
1520
+ have the same name.
1521
+
1522
+ In addition to using this like a list, the ``.value`` attribute
1523
+ returns a set-like object that you can add to or remove from to
1524
+ check and uncheck checkboxes. You can also use ``.value_options``
1525
+ to get the possible values.
1526
+ """
1527
+ @property
1528
+ def value(self):
1529
+ """
1530
+ Return a set-like object that can be modified to check or
1531
+ uncheck individual checkboxes according to their value.
1532
+ """
1533
+ return CheckboxValues(self)
1534
+
1535
+ @value.setter
1536
+ def value(self, value):
1537
+ values = self.value
1538
+ values.clear()
1539
+ if not hasattr(value, '__iter__'):
1540
+ raise ValueError(
1541
+ "A CheckboxGroup (name=%r) must be set to a sequence (not %r)"
1542
+ % (self[0].name, value))
1543
+ values.update(value)
1544
+
1545
+ @value.deleter
1546
+ def value(self):
1547
+ self.value.clear()
1548
+
1549
+ @property
1550
+ def value_options(self):
1551
+ """
1552
+ Returns a list of all the possible values.
1553
+ """
1554
+ return [el.get('value') for el in self]
1555
+
1556
+ def __repr__(self):
1557
+ return '%s(%s)' % (
1558
+ self.__class__.__name__, list.__repr__(self))
1559
+
1560
+
1561
+ class CheckboxValues(SetMixin):
1562
+ """
1563
+ Represents the values of the checked checkboxes in a group of
1564
+ checkboxes with the same name.
1565
+ """
1566
+
1567
+ def __init__(self, group):
1568
+ self.group = group
1569
+
1570
+ def __iter__(self):
1571
+ return iter([
1572
+ el.get('value')
1573
+ for el in self.group
1574
+ if 'checked' in el.attrib])
1575
+
1576
+ def add(self, value):
1577
+ for el in self.group:
1578
+ if el.get('value') == value:
1579
+ el.set('checked', '')
1580
+ break
1581
+ else:
1582
+ raise KeyError("No checkbox with value %r" % value)
1583
+
1584
+ def remove(self, value):
1585
+ for el in self.group:
1586
+ if el.get('value') == value:
1587
+ if 'checked' in el.attrib:
1588
+ del el.attrib['checked']
1589
+ else:
1590
+ raise KeyError(
1591
+ "The checkbox with value %r was already unchecked" % value)
1592
+ break
1593
+ else:
1594
+ raise KeyError(
1595
+ "No checkbox with value %r" % value)
1596
+
1597
+ def __repr__(self):
1598
+ return '<%s {%s} for checkboxes name=%r>' % (
1599
+ self.__class__.__name__,
1600
+ ', '.join([repr(v) for v in self]),
1601
+ self.group.name)
1602
+
1603
+
1604
+ class InputElement(InputMixin, HtmlElement):
1605
+ """
1606
+ Represents an ``<input>`` element.
1607
+
1608
+ You can get the type with ``.type`` (which is lower-cased and
1609
+ defaults to ``'text'``).
1610
+
1611
+ Also you can get and set the value with ``.value``
1612
+
1613
+ Checkboxes and radios have the attribute ``input.checkable ==
1614
+ True`` (for all others it is false) and a boolean attribute
1615
+ ``.checked``.
1616
+
1617
+ """
1618
+
1619
+ ## FIXME: I'm a little uncomfortable with the use of .checked
1620
+ @property
1621
+ def value(self):
1622
+ """
1623
+ Get/set the value of this element, using the ``value`` attribute.
1624
+
1625
+ Also, if this is a checkbox and it has no value, this defaults
1626
+ to ``'on'``. If it is a checkbox or radio that is not
1627
+ checked, this returns None.
1628
+ """
1629
+ if self.checkable:
1630
+ if self.checked:
1631
+ return self.get('value') or 'on'
1632
+ else:
1633
+ return None
1634
+ return self.get('value')
1635
+
1636
+ @value.setter
1637
+ def value(self, value):
1638
+ if self.checkable:
1639
+ if not value:
1640
+ self.checked = False
1641
+ else:
1642
+ self.checked = True
1643
+ if isinstance(value, str):
1644
+ self.set('value', value)
1645
+ else:
1646
+ self.set('value', value)
1647
+
1648
+ @value.deleter
1649
+ def value(self):
1650
+ if self.checkable:
1651
+ self.checked = False
1652
+ else:
1653
+ if 'value' in self.attrib:
1654
+ del self.attrib['value']
1655
+
1656
+ @property
1657
+ def type(self):
1658
+ """
1659
+ Return the type of this element (using the type attribute).
1660
+ """
1661
+ return self.get('type', 'text').lower()
1662
+
1663
+ @type.setter
1664
+ def type(self, value):
1665
+ self.set('type', value)
1666
+
1667
+ @property
1668
+ def checkable(self):
1669
+ """
1670
+ Boolean: can this element be checked?
1671
+ """
1672
+ return self.type in ('checkbox', 'radio')
1673
+
1674
+ @property
1675
+ def checked(self):
1676
+ """
1677
+ Boolean attribute to get/set the presence of the ``checked``
1678
+ attribute.
1679
+
1680
+ You can only use this on checkable input types.
1681
+ """
1682
+ if not self.checkable:
1683
+ raise AttributeError('Not a checkable input type')
1684
+ return 'checked' in self.attrib
1685
+
1686
+ @checked.setter
1687
+ def checked(self, value):
1688
+ if not self.checkable:
1689
+ raise AttributeError('Not a checkable input type')
1690
+ if value:
1691
+ self.set('checked', '')
1692
+ else:
1693
+ attrib = self.attrib
1694
+ if 'checked' in attrib:
1695
+ del attrib['checked']
1696
+
1697
+
1698
+ HtmlElementClassLookup._default_element_classes['input'] = InputElement
1699
+
1700
+
1701
+ class LabelElement(HtmlElement):
1702
+ """
1703
+ Represents a ``<label>`` element.
1704
+
1705
+ Label elements are linked to other elements with their ``for``
1706
+ attribute. You can access this element with ``label.for_element``.
1707
+ """
1708
+ @property
1709
+ def for_element(self):
1710
+ """
1711
+ Get/set the element this label points to. Return None if it
1712
+ can't be found.
1713
+ """
1714
+ id = self.get('for')
1715
+ if not id:
1716
+ return None
1717
+ return self.body.get_element_by_id(id)
1718
+
1719
+ @for_element.setter
1720
+ def for_element(self, other):
1721
+ id = other.get('id')
1722
+ if not id:
1723
+ raise TypeError(
1724
+ "Element %r has no id attribute" % other)
1725
+ self.set('for', id)
1726
+
1727
+ @for_element.deleter
1728
+ def for_element(self):
1729
+ attrib = self.attrib
1730
+ if 'id' in attrib:
1731
+ del attrib['id']
1732
+
1733
+
1734
+ HtmlElementClassLookup._default_element_classes['label'] = LabelElement
1735
+
1736
+
1737
+ ############################################################
1738
+ ## Serialization
1739
+ ############################################################
1740
+
1741
+ def html_to_xhtml(html):
1742
+ """Convert all tags in an HTML tree to XHTML by moving them to the
1743
+ XHTML namespace.
1744
+ """
1745
+ try:
1746
+ html = html.getroot()
1747
+ except AttributeError:
1748
+ pass
1749
+ prefix = "{%s}" % XHTML_NAMESPACE
1750
+ for el in html.iter(etree.Element):
1751
+ tag = el.tag
1752
+ if tag[0] != '{':
1753
+ el.tag = prefix + tag
1754
+
1755
+
1756
+ def xhtml_to_html(xhtml):
1757
+ """Convert all tags in an XHTML tree to HTML by removing their
1758
+ XHTML namespace.
1759
+ """
1760
+ try:
1761
+ xhtml = xhtml.getroot()
1762
+ except AttributeError:
1763
+ pass
1764
+ prefix = "{%s}" % XHTML_NAMESPACE
1765
+ prefix_len = len(prefix)
1766
+ for el in xhtml.iter(prefix + "*"):
1767
+ el.tag = el.tag[prefix_len:]
1768
+
1769
+
1770
+ # This isn't a general match, but it's a match for what libxml2
1771
+ # specifically serialises:
1772
+ __str_replace_meta_content_type = re.compile(
1773
+ r'<meta http-equiv="Content-Type"[^>]*>').sub
1774
+ __bytes_replace_meta_content_type = re.compile(
1775
+ br'<meta http-equiv="Content-Type"[^>]*>').sub
1776
+
1777
+
1778
+ def tostring(doc, pretty_print=False, include_meta_content_type=False,
1779
+ encoding=None, method="html", with_tail=True, doctype=None):
1780
+ """Return an HTML string representation of the document.
1781
+
1782
+ Note: if include_meta_content_type is true this will create a
1783
+ ``<meta http-equiv="Content-Type" ...>`` tag in the head;
1784
+ regardless of the value of include_meta_content_type any existing
1785
+ ``<meta http-equiv="Content-Type" ...>`` tag will be removed
1786
+
1787
+ The ``encoding`` argument controls the output encoding (defaults to
1788
+ ASCII, with &#...; character references for any characters outside
1789
+ of ASCII). Note that you can pass the name ``'unicode'`` as
1790
+ ``encoding`` argument to serialise to a Unicode string.
1791
+
1792
+ The ``method`` argument defines the output method. It defaults to
1793
+ 'html', but can also be 'xml' for xhtml output, or 'text' to
1794
+ serialise to plain text without markup.
1795
+
1796
+ To leave out the tail text of the top-level element that is being
1797
+ serialised, pass ``with_tail=False``.
1798
+
1799
+ The ``doctype`` option allows passing in a plain string that will
1800
+ be serialised before the XML tree. Note that passing in non
1801
+ well-formed content here will make the XML output non well-formed.
1802
+ Also, an existing doctype in the document tree will not be removed
1803
+ when serialising an ElementTree instance.
1804
+
1805
+ Example::
1806
+
1807
+ >>> from lxml import html
1808
+ >>> root = html.fragment_fromstring('<p>Hello<br>world!</p>')
1809
+
1810
+ >>> html.tostring(root)
1811
+ b'<p>Hello<br>world!</p>'
1812
+ >>> html.tostring(root, method='html')
1813
+ b'<p>Hello<br>world!</p>'
1814
+
1815
+ >>> html.tostring(root, method='xml')
1816
+ b'<p>Hello<br/>world!</p>'
1817
+
1818
+ >>> html.tostring(root, method='text')
1819
+ b'Helloworld!'
1820
+
1821
+ >>> html.tostring(root, method='text', encoding='unicode')
1822
+ u'Helloworld!'
1823
+
1824
+ >>> root = html.fragment_fromstring('<div><p>Hello<br>world!</p>TAIL</div>')
1825
+ >>> html.tostring(root[0], method='text', encoding='unicode')
1826
+ u'Helloworld!TAIL'
1827
+
1828
+ >>> html.tostring(root[0], method='text', encoding='unicode', with_tail=False)
1829
+ u'Helloworld!'
1830
+
1831
+ >>> doc = html.document_fromstring('<p>Hello<br>world!</p>')
1832
+ >>> html.tostring(doc, method='html', encoding='unicode')
1833
+ u'<html><body><p>Hello<br>world!</p></body></html>'
1834
+
1835
+ >>> print(html.tostring(doc, method='html', encoding='unicode',
1836
+ ... doctype='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'
1837
+ ... ' "http://www.w3.org/TR/html4/strict.dtd">'))
1838
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
1839
+ <html><body><p>Hello<br>world!</p></body></html>
1840
+ """
1841
+ html = etree.tostring(doc, method=method, pretty_print=pretty_print,
1842
+ encoding=encoding, with_tail=with_tail,
1843
+ doctype=doctype)
1844
+ if method == 'html' and not include_meta_content_type:
1845
+ if isinstance(html, str):
1846
+ html = __str_replace_meta_content_type('', html)
1847
+ else:
1848
+ html = __bytes_replace_meta_content_type(b'', html)
1849
+ return html
1850
+
1851
+
1852
+ tostring.__doc__ = __fix_docstring(tostring.__doc__)
1853
+
1854
+
1855
+ def open_in_browser(doc, encoding=None):
1856
+ """
1857
+ Open the HTML document in a web browser, saving it to a temporary
1858
+ file to open it. Note that this does not delete the file after
1859
+ use. This is mainly meant for debugging.
1860
+ """
1861
+ import os
1862
+ import webbrowser
1863
+ import tempfile
1864
+ if not isinstance(doc, etree._ElementTree):
1865
+ doc = etree.ElementTree(doc)
1866
+ handle, fn = tempfile.mkstemp(suffix='.html')
1867
+ f = os.fdopen(handle, 'wb')
1868
+ try:
1869
+ doc.write(f, method="html", encoding=encoding or doc.docinfo.encoding or "UTF-8")
1870
+ finally:
1871
+ # we leak the file itself here, but we should at least close it
1872
+ f.close()
1873
+ url = 'file://' + fn.replace(os.path.sep, '/')
1874
+ print(url)
1875
+ webbrowser.open(url)
1876
+
1877
+
1878
+ ################################################################################
1879
+ # configure Element class lookup
1880
+ ################################################################################
1881
+
1882
+ class HTMLParser(etree.HTMLParser):
1883
+ """An HTML parser that is configured to return lxml.html Element
1884
+ objects.
1885
+ """
1886
+ def __init__(self, **kwargs):
1887
+ super().__init__(**kwargs)
1888
+ self.set_element_class_lookup(HtmlElementClassLookup())
1889
+
1890
+
1891
+ class XHTMLParser(etree.XMLParser):
1892
+ """An XML parser that is configured to return lxml.html Element
1893
+ objects.
1894
+
1895
+ Note that this parser is not really XHTML aware unless you let it
1896
+ load a DTD that declares the HTML entities. To do this, make sure
1897
+ you have the XHTML DTDs installed in your catalogs, and create the
1898
+ parser like this::
1899
+
1900
+ >>> parser = XHTMLParser(load_dtd=True)
1901
+
1902
+ If you additionally want to validate the document, use this::
1903
+
1904
+ >>> parser = XHTMLParser(dtd_validation=True)
1905
+
1906
+ For catalog support, see http://www.xmlsoft.org/catalog.html.
1907
+ """
1908
+ def __init__(self, **kwargs):
1909
+ super().__init__(**kwargs)
1910
+ self.set_element_class_lookup(HtmlElementClassLookup())
1911
+
1912
+
1913
+ def Element(*args, **kw):
1914
+ """Create a new HTML Element.
1915
+
1916
+ This can also be used for XHTML documents.
1917
+ """
1918
+ v = html_parser.makeelement(*args, **kw)
1919
+ return v
1920
+
1921
+
1922
+ html_parser = HTMLParser()
1923
+ xhtml_parser = XHTMLParser()
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/ElementSoup.cpython-310.pyc ADDED
Binary file (527 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (56 kB). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_html5builder.cpython-310.pyc ADDED
Binary file (3.61 kB). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/clean.cpython-310.pyc ADDED
Binary file (558 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/defs.cpython-310.pyc ADDED
Binary file (2.83 kB). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/formfill.cpython-310.pyc ADDED
Binary file (7.39 kB). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/html5parser.cpython-310.pyc ADDED
Binary file (6.43 kB). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/usedoctest.cpython-310.pyc ADDED
Binary file (453 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/html/_diffcommand.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import optparse
2
+ import sys
3
+ import re
4
+ import os
5
+ from .diff import htmldiff
6
+
7
+ description = """\
8
+ """
9
+
10
+ parser = optparse.OptionParser(
11
+ usage="%prog [OPTIONS] FILE1 FILE2\n"
12
+ "%prog --annotate [OPTIONS] INFO1 FILE1 INFO2 FILE2 ...",
13
+ description=description,
14
+ )
15
+
16
+ parser.add_option(
17
+ '-o', '--output',
18
+ metavar="FILE",
19
+ dest="output",
20
+ default="-",
21
+ help="File to write the difference to",
22
+ )
23
+
24
+ parser.add_option(
25
+ '-a', '--annotation',
26
+ action="store_true",
27
+ dest="annotation",
28
+ help="Do an annotation")
29
+
30
+ def main(args=None):
31
+ if args is None:
32
+ args = sys.argv[1:]
33
+ options, args = parser.parse_args(args)
34
+ if options.annotation:
35
+ return annotate(options, args)
36
+ if len(args) != 2:
37
+ print('Error: you must give two files')
38
+ parser.print_help()
39
+ sys.exit(1)
40
+ file1, file2 = args
41
+ input1 = read_file(file1)
42
+ input2 = read_file(file2)
43
+ body1 = split_body(input1)[1]
44
+ pre, body2, post = split_body(input2)
45
+ result = htmldiff(body1, body2)
46
+ result = pre + result + post
47
+ if options.output == '-':
48
+ if not result.endswith('\n'):
49
+ result += '\n'
50
+ sys.stdout.write(result)
51
+ else:
52
+ with open(options.output, 'wb') as f:
53
+ f.write(result)
54
+
55
+ def read_file(filename):
56
+ if filename == '-':
57
+ c = sys.stdin.read()
58
+ elif not os.path.exists(filename):
59
+ raise OSError(
60
+ "Input file %s does not exist" % filename)
61
+ else:
62
+ with open(filename, 'rb') as f:
63
+ c = f.read()
64
+ return c
65
+
66
+ body_start_re = re.compile(
67
+ r"<body.*?>", re.I|re.S)
68
+ body_end_re = re.compile(
69
+ r"</body.*?>", re.I|re.S)
70
+
71
+ def split_body(html):
72
+ pre = post = ''
73
+ match = body_start_re.search(html)
74
+ if match:
75
+ pre = html[:match.end()]
76
+ html = html[match.end():]
77
+ match = body_end_re.search(html)
78
+ if match:
79
+ post = html[match.start():]
80
+ html = html[:match.start()]
81
+ return pre, html, post
82
+
83
+ def annotate(options, args):
84
+ print("Not yet implemented")
85
+ sys.exit(1)
86
+
llmeval-env/lib/python3.10/site-packages/lxml/html/_setmixin.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ try:
2
+ from collections.abc import MutableSet
3
+ except ImportError:
4
+ from collections.abc import MutableSet
5
+
6
+
7
+ class SetMixin(MutableSet):
8
+
9
+ """
10
+ Mix-in for sets. You must define __iter__, add, remove
11
+ """
12
+
13
+ def __len__(self):
14
+ length = 0
15
+ for item in self:
16
+ length += 1
17
+ return length
18
+
19
+ def __contains__(self, item):
20
+ for has_item in self:
21
+ if item == has_item:
22
+ return True
23
+ return False
24
+
25
+ issubset = MutableSet.__le__
26
+ issuperset = MutableSet.__ge__
27
+
28
+ union = MutableSet.__or__
29
+ intersection = MutableSet.__and__
30
+ difference = MutableSet.__sub__
31
+ symmetric_difference = MutableSet.__xor__
32
+
33
+ def copy(self):
34
+ return set(self)
35
+
36
+ def update(self, other):
37
+ self |= other
38
+
39
+ def intersection_update(self, other):
40
+ self &= other
41
+
42
+ def difference_update(self, other):
43
+ self -= other
44
+
45
+ def symmetric_difference_update(self, other):
46
+ self ^= other
47
+
48
+ def discard(self, item):
49
+ try:
50
+ self.remove(item)
51
+ except KeyError:
52
+ pass
53
+
54
+ @classmethod
55
+ def _from_iterable(cls, it):
56
+ return set(it)
llmeval-env/lib/python3.10/site-packages/lxml/html/builder.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # --------------------------------------------------------------------
2
+ # The ElementTree toolkit is
3
+ # Copyright (c) 1999-2004 by Fredrik Lundh
4
+ # --------------------------------------------------------------------
5
+
6
+ """
7
+ A set of HTML generator tags for building HTML documents.
8
+
9
+ Usage::
10
+
11
+ >>> from lxml.html.builder import *
12
+ >>> html = HTML(
13
+ ... HEAD( TITLE("Hello World") ),
14
+ ... BODY( CLASS("main"),
15
+ ... H1("Hello World !")
16
+ ... )
17
+ ... )
18
+
19
+ >>> import lxml.etree
20
+ >>> print lxml.etree.tostring(html, pretty_print=True)
21
+ <html>
22
+ <head>
23
+ <title>Hello World</title>
24
+ </head>
25
+ <body class="main">
26
+ <h1>Hello World !</h1>
27
+ </body>
28
+ </html>
29
+
30
+ """
31
+
32
+ from lxml.builder import ElementMaker
33
+ from lxml.html import html_parser
34
+
35
+ E = ElementMaker(makeelement=html_parser.makeelement)
36
+
37
+ # elements
38
+ A = E.a #: anchor
39
+ ABBR = E.abbr #: abbreviated form (e.g., WWW, HTTP, etc.)
40
+ ACRONYM = E.acronym #:
41
+ ADDRESS = E.address #: information on author
42
+ APPLET = E.applet #: Java applet (DEPRECATED)
43
+ AREA = E.area #: client-side image map area
44
+ B = E.b #: bold text style
45
+ BASE = E.base #: document base URI
46
+ BASEFONT = E.basefont #: base font size (DEPRECATED)
47
+ BDO = E.bdo #: I18N BiDi over-ride
48
+ BIG = E.big #: large text style
49
+ BLOCKQUOTE = E.blockquote #: long quotation
50
+ BODY = E.body #: document body
51
+ BR = E.br #: forced line break
52
+ BUTTON = E.button #: push button
53
+ CAPTION = E.caption #: table caption
54
+ CENTER = E.center #: shorthand for DIV align=center (DEPRECATED)
55
+ CITE = E.cite #: citation
56
+ CODE = E.code #: computer code fragment
57
+ COL = E.col #: table column
58
+ COLGROUP = E.colgroup #: table column group
59
+ DD = E.dd #: definition description
60
+ DEL = getattr(E, 'del') #: deleted text
61
+ DFN = E.dfn #: instance definition
62
+ DIR = E.dir #: directory list (DEPRECATED)
63
+ DIV = E.div #: generic language/style container
64
+ DL = E.dl #: definition list
65
+ DT = E.dt #: definition term
66
+ EM = E.em #: emphasis
67
+ FIELDSET = E.fieldset #: form control group
68
+ FONT = E.font #: local change to font (DEPRECATED)
69
+ FORM = E.form #: interactive form
70
+ FRAME = E.frame #: subwindow
71
+ FRAMESET = E.frameset #: window subdivision
72
+ H1 = E.h1 #: heading
73
+ H2 = E.h2 #: heading
74
+ H3 = E.h3 #: heading
75
+ H4 = E.h4 #: heading
76
+ H5 = E.h5 #: heading
77
+ H6 = E.h6 #: heading
78
+ HEAD = E.head #: document head
79
+ HR = E.hr #: horizontal rule
80
+ HTML = E.html #: document root element
81
+ I = E.i #: italic text style
82
+ IFRAME = E.iframe #: inline subwindow
83
+ IMG = E.img #: Embedded image
84
+ INPUT = E.input #: form control
85
+ INS = E.ins #: inserted text
86
+ ISINDEX = E.isindex #: single line prompt (DEPRECATED)
87
+ KBD = E.kbd #: text to be entered by the user
88
+ LABEL = E.label #: form field label text
89
+ LEGEND = E.legend #: fieldset legend
90
+ LI = E.li #: list item
91
+ LINK = E.link #: a media-independent link
92
+ MAP = E.map #: client-side image map
93
+ MENU = E.menu #: menu list (DEPRECATED)
94
+ META = E.meta #: generic metainformation
95
+ NOFRAMES = E.noframes #: alternate content container for non frame-based rendering
96
+ NOSCRIPT = E.noscript #: alternate content container for non script-based rendering
97
+ OBJECT = E.object #: generic embedded object
98
+ OL = E.ol #: ordered list
99
+ OPTGROUP = E.optgroup #: option group
100
+ OPTION = E.option #: selectable choice
101
+ P = E.p #: paragraph
102
+ PARAM = E.param #: named property value
103
+ PRE = E.pre #: preformatted text
104
+ Q = E.q #: short inline quotation
105
+ S = E.s #: strike-through text style (DEPRECATED)
106
+ SAMP = E.samp #: sample program output, scripts, etc.
107
+ SCRIPT = E.script #: script statements
108
+ SELECT = E.select #: option selector
109
+ SMALL = E.small #: small text style
110
+ SPAN = E.span #: generic language/style container
111
+ STRIKE = E.strike #: strike-through text (DEPRECATED)
112
+ STRONG = E.strong #: strong emphasis
113
+ STYLE = E.style #: style info
114
+ SUB = E.sub #: subscript
115
+ SUP = E.sup #: superscript
116
+ TABLE = E.table #:
117
+ TBODY = E.tbody #: table body
118
+ TD = E.td #: table data cell
119
+ TEXTAREA = E.textarea #: multi-line text field
120
+ TFOOT = E.tfoot #: table footer
121
+ TH = E.th #: table header cell
122
+ THEAD = E.thead #: table header
123
+ TITLE = E.title #: document title
124
+ TR = E.tr #: table row
125
+ TT = E.tt #: teletype or monospaced text style
126
+ U = E.u #: underlined text style (DEPRECATED)
127
+ UL = E.ul #: unordered list
128
+ VAR = E.var #: instance of a variable or program argument
129
+
130
+ # attributes (only reserved words are included here)
131
+ ATTR = dict
132
+ def CLASS(v): return {'class': v}
133
+ def FOR(v): return {'for': v}
llmeval-env/lib/python3.10/site-packages/lxml/html/defs.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FIXME: this should all be confirmed against what a DTD says
2
+ # (probably in a test; this may not match the DTD exactly, but we
3
+ # should document just how it differs).
4
+
5
+ """
6
+ Data taken from https://www.w3.org/TR/html401/index/elements.html
7
+ and https://www.w3.org/community/webed/wiki/HTML/New_HTML5_Elements
8
+ for html5_tags.
9
+ """
10
+
11
+ empty_tags = frozenset([
12
+ 'area', 'base', 'basefont', 'br', 'col', 'frame', 'hr',
13
+ 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source', 'track'])
14
+
15
+ deprecated_tags = frozenset([
16
+ 'applet', 'basefont', 'center', 'dir', 'font', 'isindex',
17
+ 'menu', 's', 'strike', 'u'])
18
+
19
+ # archive actually takes a space-separated list of URIs
20
+ link_attrs = frozenset([
21
+ 'action', 'archive', 'background', 'cite', 'classid',
22
+ 'codebase', 'data', 'href', 'longdesc', 'profile', 'src',
23
+ 'usemap',
24
+ # Not standard:
25
+ 'dynsrc', 'lowsrc',
26
+ # HTML5 formaction
27
+ 'formaction'
28
+ ])
29
+
30
+ # Not in the HTML 4 spec:
31
+ # onerror, onresize
32
+ event_attrs = frozenset([
33
+ 'onblur', 'onchange', 'onclick', 'ondblclick', 'onerror',
34
+ 'onfocus', 'onkeydown', 'onkeypress', 'onkeyup', 'onload',
35
+ 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover',
36
+ 'onmouseup', 'onreset', 'onresize', 'onselect', 'onsubmit',
37
+ 'onunload',
38
+ ])
39
+
40
+ safe_attrs = frozenset([
41
+ 'abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align',
42
+ 'alt', 'axis', 'border', 'cellpadding', 'cellspacing', 'char', 'charoff',
43
+ 'charset', 'checked', 'cite', 'class', 'clear', 'cols', 'colspan',
44
+ 'color', 'compact', 'coords', 'datetime', 'dir', 'disabled', 'enctype',
45
+ 'for', 'frame', 'headers', 'height', 'href', 'hreflang', 'hspace', 'id',
46
+ 'ismap', 'label', 'lang', 'longdesc', 'maxlength', 'media', 'method',
47
+ 'multiple', 'name', 'nohref', 'noshade', 'nowrap', 'prompt', 'readonly',
48
+ 'rel', 'rev', 'rows', 'rowspan', 'rules', 'scope', 'selected', 'shape',
49
+ 'size', 'span', 'src', 'start', 'summary', 'tabindex', 'target', 'title',
50
+ 'type', 'usemap', 'valign', 'value', 'vspace', 'width'])
51
+
52
+ # From http://htmlhelp.com/reference/html40/olist.html
53
+ top_level_tags = frozenset([
54
+ 'html', 'head', 'body', 'frameset',
55
+ ])
56
+
57
+ head_tags = frozenset([
58
+ 'base', 'isindex', 'link', 'meta', 'script', 'style', 'title',
59
+ ])
60
+
61
+ general_block_tags = frozenset([
62
+ 'address',
63
+ 'blockquote',
64
+ 'center',
65
+ 'del',
66
+ 'div',
67
+ 'h1',
68
+ 'h2',
69
+ 'h3',
70
+ 'h4',
71
+ 'h5',
72
+ 'h6',
73
+ 'hr',
74
+ 'ins',
75
+ 'isindex',
76
+ 'noscript',
77
+ 'p',
78
+ 'pre',
79
+ ])
80
+
81
+ list_tags = frozenset([
82
+ 'dir', 'dl', 'dt', 'dd', 'li', 'menu', 'ol', 'ul',
83
+ ])
84
+
85
+ table_tags = frozenset([
86
+ 'table', 'caption', 'colgroup', 'col',
87
+ 'thead', 'tfoot', 'tbody', 'tr', 'td', 'th',
88
+ ])
89
+
90
+ # just this one from
91
+ # http://www.georgehernandez.com/h/XComputers/HTML/2BlockLevel.htm
92
+ block_tags = general_block_tags | list_tags | table_tags | frozenset([
93
+ # Partial form tags
94
+ 'fieldset', 'form', 'legend', 'optgroup', 'option',
95
+ ])
96
+
97
+ form_tags = frozenset([
98
+ 'form', 'button', 'fieldset', 'legend', 'input', 'label',
99
+ 'select', 'optgroup', 'option', 'textarea',
100
+ ])
101
+
102
+ special_inline_tags = frozenset([
103
+ 'a', 'applet', 'basefont', 'bdo', 'br', 'embed', 'font', 'iframe',
104
+ 'img', 'map', 'area', 'object', 'param', 'q', 'script',
105
+ 'span', 'sub', 'sup',
106
+ ])
107
+
108
+ phrase_tags = frozenset([
109
+ 'abbr', 'acronym', 'cite', 'code', 'del', 'dfn', 'em',
110
+ 'ins', 'kbd', 'samp', 'strong', 'var',
111
+ ])
112
+
113
+ font_style_tags = frozenset([
114
+ 'b', 'big', 'i', 's', 'small', 'strike', 'tt', 'u',
115
+ ])
116
+
117
+ frame_tags = frozenset([
118
+ 'frameset', 'frame', 'noframes',
119
+ ])
120
+
121
+ html5_tags = frozenset([
122
+ 'article', 'aside', 'audio', 'canvas', 'command', 'datalist',
123
+ 'details', 'embed', 'figcaption', 'figure', 'footer', 'header',
124
+ 'hgroup', 'keygen', 'mark', 'math', 'meter', 'nav', 'output',
125
+ 'progress', 'rp', 'rt', 'ruby', 'section', 'source', 'summary',
126
+ 'svg', 'time', 'track', 'video', 'wbr'
127
+ ])
128
+
129
+ # These tags aren't standard
130
+ nonstandard_tags = frozenset(['blink', 'marquee'])
131
+
132
+
133
+ tags = (top_level_tags | head_tags | general_block_tags | list_tags
134
+ | table_tags | form_tags | special_inline_tags | phrase_tags
135
+ | font_style_tags | nonstandard_tags | html5_tags)
llmeval-env/lib/python3.10/site-packages/lxml/html/diff.py ADDED
@@ -0,0 +1,878 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # cython: language_level=3
2
+
3
+
4
+ import difflib
5
+ from lxml import etree
6
+ from lxml.html import fragment_fromstring
7
+ import re
8
+
9
+ __all__ = ['html_annotate', 'htmldiff']
10
+
11
+ try:
12
+ from html import escape as html_escape
13
+ except ImportError:
14
+ from cgi import escape as html_escape
15
+ try:
16
+ _unicode = unicode
17
+ except NameError:
18
+ # Python 3
19
+ _unicode = str
20
+ try:
21
+ basestring
22
+ except NameError:
23
+ # Python 3
24
+ basestring = str
25
+
26
+ ############################################################
27
+ ## Annotation
28
+ ############################################################
29
+
30
+ def default_markup(text, version):
31
+ return '<span title="%s">%s</span>' % (
32
+ html_escape(_unicode(version), 1), text)
33
+
34
+ def html_annotate(doclist, markup=default_markup):
35
+ """
36
+ doclist should be ordered from oldest to newest, like::
37
+
38
+ >>> version1 = 'Hello World'
39
+ >>> version2 = 'Goodbye World'
40
+ >>> print(html_annotate([(version1, 'version 1'),
41
+ ... (version2, 'version 2')]))
42
+ <span title="version 2">Goodbye</span> <span title="version 1">World</span>
43
+
44
+ The documents must be *fragments* (str/UTF8 or unicode), not
45
+ complete documents
46
+
47
+ The markup argument is a function to markup the spans of words.
48
+ This function is called like markup('Hello', 'version 2'), and
49
+ returns HTML. The first argument is text and never includes any
50
+ markup. The default uses a span with a title:
51
+
52
+ >>> print(default_markup('Some Text', 'by Joe'))
53
+ <span title="by Joe">Some Text</span>
54
+ """
55
+ # The basic strategy we have is to split the documents up into
56
+ # logical tokens (which are words with attached markup). We then
57
+ # do diffs of each of the versions to track when a token first
58
+ # appeared in the document; the annotation attached to the token
59
+ # is the version where it first appeared.
60
+ tokenlist = [tokenize_annotated(doc, version)
61
+ for doc, version in doclist]
62
+ cur_tokens = tokenlist[0]
63
+ for tokens in tokenlist[1:]:
64
+ html_annotate_merge_annotations(cur_tokens, tokens)
65
+ cur_tokens = tokens
66
+
67
+ # After we've tracked all the tokens, we can combine spans of text
68
+ # that are adjacent and have the same annotation
69
+ cur_tokens = compress_tokens(cur_tokens)
70
+ # And finally add markup
71
+ result = markup_serialize_tokens(cur_tokens, markup)
72
+ return ''.join(result).strip()
73
+
74
+ def tokenize_annotated(doc, annotation):
75
+ """Tokenize a document and add an annotation attribute to each token
76
+ """
77
+ tokens = tokenize(doc, include_hrefs=False)
78
+ for tok in tokens:
79
+ tok.annotation = annotation
80
+ return tokens
81
+
82
+ def html_annotate_merge_annotations(tokens_old, tokens_new):
83
+ """Merge the annotations from tokens_old into tokens_new, when the
84
+ tokens in the new document already existed in the old document.
85
+ """
86
+ s = InsensitiveSequenceMatcher(a=tokens_old, b=tokens_new)
87
+ commands = s.get_opcodes()
88
+
89
+ for command, i1, i2, j1, j2 in commands:
90
+ if command == 'equal':
91
+ eq_old = tokens_old[i1:i2]
92
+ eq_new = tokens_new[j1:j2]
93
+ copy_annotations(eq_old, eq_new)
94
+
95
+ def copy_annotations(src, dest):
96
+ """
97
+ Copy annotations from the tokens listed in src to the tokens in dest
98
+ """
99
+ assert len(src) == len(dest)
100
+ for src_tok, dest_tok in zip(src, dest):
101
+ dest_tok.annotation = src_tok.annotation
102
+
103
+ def compress_tokens(tokens):
104
+ """
105
+ Combine adjacent tokens when there is no HTML between the tokens,
106
+ and they share an annotation
107
+ """
108
+ result = [tokens[0]]
109
+ for tok in tokens[1:]:
110
+ if (not result[-1].post_tags and
111
+ not tok.pre_tags and
112
+ result[-1].annotation == tok.annotation):
113
+ compress_merge_back(result, tok)
114
+ else:
115
+ result.append(tok)
116
+ return result
117
+
118
+ def compress_merge_back(tokens, tok):
119
+ """ Merge tok into the last element of tokens (modifying the list of
120
+ tokens in-place). """
121
+ last = tokens[-1]
122
+ if type(last) is not token or type(tok) is not token:
123
+ tokens.append(tok)
124
+ else:
125
+ text = _unicode(last)
126
+ if last.trailing_whitespace:
127
+ text += last.trailing_whitespace
128
+ text += tok
129
+ merged = token(text,
130
+ pre_tags=last.pre_tags,
131
+ post_tags=tok.post_tags,
132
+ trailing_whitespace=tok.trailing_whitespace)
133
+ merged.annotation = last.annotation
134
+ tokens[-1] = merged
135
+
136
+ def markup_serialize_tokens(tokens, markup_func):
137
+ """
138
+ Serialize the list of tokens into a list of text chunks, calling
139
+ markup_func around text to add annotations.
140
+ """
141
+ for token in tokens:
142
+ yield from token.pre_tags
143
+ html = token.html()
144
+ html = markup_func(html, token.annotation)
145
+ if token.trailing_whitespace:
146
+ html += token.trailing_whitespace
147
+ yield html
148
+ yield from token.post_tags
149
+
150
+
151
+ ############################################################
152
+ ## HTML Diffs
153
+ ############################################################
154
+
155
+ def htmldiff(old_html, new_html):
156
+ ## FIXME: this should take parsed documents too, and use their body
157
+ ## or other content.
158
+ """ Do a diff of the old and new document. The documents are HTML
159
+ *fragments* (str/UTF8 or unicode), they are not complete documents
160
+ (i.e., no <html> tag).
161
+
162
+ Returns HTML with <ins> and <del> tags added around the
163
+ appropriate text.
164
+
165
+ Markup is generally ignored, with the markup from new_html
166
+ preserved, and possibly some markup from old_html (though it is
167
+ considered acceptable to lose some of the old markup). Only the
168
+ words in the HTML are diffed. The exception is <img> tags, which
169
+ are treated like words, and the href attribute of <a> tags, which
170
+ are noted inside the tag itself when there are changes.
171
+ """
172
+ old_html_tokens = tokenize(old_html)
173
+ new_html_tokens = tokenize(new_html)
174
+ result = htmldiff_tokens(old_html_tokens, new_html_tokens)
175
+ result = ''.join(result).strip()
176
+ return fixup_ins_del_tags(result)
177
+
178
+ def htmldiff_tokens(html1_tokens, html2_tokens):
179
+ """ Does a diff on the tokens themselves, returning a list of text
180
+ chunks (not tokens).
181
+ """
182
+ # There are several passes as we do the differences. The tokens
183
+ # isolate the portion of the content we care to diff; difflib does
184
+ # all the actual hard work at that point.
185
+ #
186
+ # Then we must create a valid document from pieces of both the old
187
+ # document and the new document. We generally prefer to take
188
+ # markup from the new document, and only do a best effort attempt
189
+ # to keep markup from the old document; anything that we can't
190
+ # resolve we throw away. Also we try to put the deletes as close
191
+ # to the location where we think they would have been -- because
192
+ # we are only keeping the markup from the new document, it can be
193
+ # fuzzy where in the new document the old text would have gone.
194
+ # Again we just do a best effort attempt.
195
+ s = InsensitiveSequenceMatcher(a=html1_tokens, b=html2_tokens)
196
+ commands = s.get_opcodes()
197
+ result = []
198
+ for command, i1, i2, j1, j2 in commands:
199
+ if command == 'equal':
200
+ result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
201
+ continue
202
+ if command == 'insert' or command == 'replace':
203
+ ins_tokens = expand_tokens(html2_tokens[j1:j2])
204
+ merge_insert(ins_tokens, result)
205
+ if command == 'delete' or command == 'replace':
206
+ del_tokens = expand_tokens(html1_tokens[i1:i2])
207
+ merge_delete(del_tokens, result)
208
+ # If deletes were inserted directly as <del> then we'd have an
209
+ # invalid document at this point. Instead we put in special
210
+ # markers, and when the complete diffed document has been created
211
+ # we try to move the deletes around and resolve any problems.
212
+ result = cleanup_delete(result)
213
+
214
+ return result
215
+
216
+ def expand_tokens(tokens, equal=False):
217
+ """Given a list of tokens, return a generator of the chunks of
218
+ text for the data in the tokens.
219
+ """
220
+ for token in tokens:
221
+ yield from token.pre_tags
222
+ if not equal or not token.hide_when_equal:
223
+ if token.trailing_whitespace:
224
+ yield token.html() + token.trailing_whitespace
225
+ else:
226
+ yield token.html()
227
+ yield from token.post_tags
228
+
229
+ def merge_insert(ins_chunks, doc):
230
+ """ doc is the already-handled document (as a list of text chunks);
231
+ here we add <ins>ins_chunks</ins> to the end of that. """
232
+ # Though we don't throw away unbalanced_start or unbalanced_end
233
+ # (we assume there is accompanying markup later or earlier in the
234
+ # document), we only put <ins> around the balanced portion.
235
+ unbalanced_start, balanced, unbalanced_end = split_unbalanced(ins_chunks)
236
+ doc.extend(unbalanced_start)
237
+ if doc and not doc[-1].endswith(' '):
238
+ # Fix up the case where the word before the insert didn't end with
239
+ # a space
240
+ doc[-1] += ' '
241
+ doc.append('<ins>')
242
+ if balanced and balanced[-1].endswith(' '):
243
+ # We move space outside of </ins>
244
+ balanced[-1] = balanced[-1][:-1]
245
+ doc.extend(balanced)
246
+ doc.append('</ins> ')
247
+ doc.extend(unbalanced_end)
248
+
249
+ # These are sentinels to represent the start and end of a <del>
250
+ # segment, until we do the cleanup phase to turn them into proper
251
+ # markup:
252
+ class DEL_START:
253
+ pass
254
+ class DEL_END:
255
+ pass
256
+
257
+ class NoDeletes(Exception):
258
+ """ Raised when the document no longer contains any pending deletes
259
+ (DEL_START/DEL_END) """
260
+
261
+ def merge_delete(del_chunks, doc):
262
+ """ Adds the text chunks in del_chunks to the document doc (another
263
+ list of text chunks) with marker to show it is a delete.
264
+ cleanup_delete later resolves these markers into <del> tags."""
265
+ doc.append(DEL_START)
266
+ doc.extend(del_chunks)
267
+ doc.append(DEL_END)
268
+
269
+ def cleanup_delete(chunks):
270
+ """ Cleans up any DEL_START/DEL_END markers in the document, replacing
271
+ them with <del></del>. To do this while keeping the document
272
+ valid, it may need to drop some tags (either start or end tags).
273
+
274
+ It may also move the del into adjacent tags to try to move it to a
275
+ similar location where it was originally located (e.g., moving a
276
+ delete into preceding <div> tag, if the del looks like (DEL_START,
277
+ 'Text</div>', DEL_END)"""
278
+ while 1:
279
+ # Find a pending DEL_START/DEL_END, splitting the document
280
+ # into stuff-preceding-DEL_START, stuff-inside, and
281
+ # stuff-following-DEL_END
282
+ try:
283
+ pre_delete, delete, post_delete = split_delete(chunks)
284
+ except NoDeletes:
285
+ # Nothing found, we've cleaned up the entire doc
286
+ break
287
+ # The stuff-inside-DEL_START/END may not be well balanced
288
+ # markup. First we figure out what unbalanced portions there are:
289
+ unbalanced_start, balanced, unbalanced_end = split_unbalanced(delete)
290
+ # Then we move the span forward and/or backward based on these
291
+ # unbalanced portions:
292
+ locate_unbalanced_start(unbalanced_start, pre_delete, post_delete)
293
+ locate_unbalanced_end(unbalanced_end, pre_delete, post_delete)
294
+ doc = pre_delete
295
+ if doc and not doc[-1].endswith(' '):
296
+ # Fix up case where the word before us didn't have a trailing space
297
+ doc[-1] += ' '
298
+ doc.append('<del>')
299
+ if balanced and balanced[-1].endswith(' '):
300
+ # We move space outside of </del>
301
+ balanced[-1] = balanced[-1][:-1]
302
+ doc.extend(balanced)
303
+ doc.append('</del> ')
304
+ doc.extend(post_delete)
305
+ chunks = doc
306
+ return chunks
307
+
308
+ def split_unbalanced(chunks):
309
+ """Return (unbalanced_start, balanced, unbalanced_end), where each is
310
+ a list of text and tag chunks.
311
+
312
+ unbalanced_start is a list of all the tags that are opened, but
313
+ not closed in this span. Similarly, unbalanced_end is a list of
314
+ tags that are closed but were not opened. Extracting these might
315
+ mean some reordering of the chunks."""
316
+ start = []
317
+ end = []
318
+ tag_stack = []
319
+ balanced = []
320
+ for chunk in chunks:
321
+ if not chunk.startswith('<'):
322
+ balanced.append(chunk)
323
+ continue
324
+ endtag = chunk[1] == '/'
325
+ name = chunk.split()[0].strip('<>/')
326
+ if name in empty_tags:
327
+ balanced.append(chunk)
328
+ continue
329
+ if endtag:
330
+ if tag_stack and tag_stack[-1][0] == name:
331
+ balanced.append(chunk)
332
+ name, pos, tag = tag_stack.pop()
333
+ balanced[pos] = tag
334
+ elif tag_stack:
335
+ start.extend([tag for name, pos, tag in tag_stack])
336
+ tag_stack = []
337
+ end.append(chunk)
338
+ else:
339
+ end.append(chunk)
340
+ else:
341
+ tag_stack.append((name, len(balanced), chunk))
342
+ balanced.append(None)
343
+ start.extend(
344
+ [chunk for name, pos, chunk in tag_stack])
345
+ balanced = [chunk for chunk in balanced if chunk is not None]
346
+ return start, balanced, end
347
+
348
+ def split_delete(chunks):
349
+ """ Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,
350
+ stuff_after_DEL_END). Returns the first case found (there may be
351
+ more DEL_STARTs in stuff_after_DEL_END). Raises NoDeletes if
352
+ there's no DEL_START found. """
353
+ try:
354
+ pos = chunks.index(DEL_START)
355
+ except ValueError:
356
+ raise NoDeletes
357
+ pos2 = chunks.index(DEL_END)
358
+ return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
359
+
360
+ def locate_unbalanced_start(unbalanced_start, pre_delete, post_delete):
361
+ """ pre_delete and post_delete implicitly point to a place in the
362
+ document (where the two were split). This moves that point (by
363
+ popping items from one and pushing them onto the other). It moves
364
+ the point to try to find a place where unbalanced_start applies.
365
+
366
+ As an example::
367
+
368
+ >>> unbalanced_start = ['<div>']
369
+ >>> doc = ['<p>', 'Text', '</p>', '<div>', 'More Text', '</div>']
370
+ >>> pre, post = doc[:3], doc[3:]
371
+ >>> pre, post
372
+ (['<p>', 'Text', '</p>'], ['<div>', 'More Text', '</div>'])
373
+ >>> locate_unbalanced_start(unbalanced_start, pre, post)
374
+ >>> pre, post
375
+ (['<p>', 'Text', '</p>', '<div>'], ['More Text', '</div>'])
376
+
377
+ As you can see, we moved the point so that the dangling <div> that
378
+ we found will be effectively replaced by the div in the original
379
+ document. If this doesn't work out, we just throw away
380
+ unbalanced_start without doing anything.
381
+ """
382
+ while 1:
383
+ if not unbalanced_start:
384
+ # We have totally succeeded in finding the position
385
+ break
386
+ finding = unbalanced_start[0]
387
+ finding_name = finding.split()[0].strip('<>')
388
+ if not post_delete:
389
+ break
390
+ next = post_delete[0]
391
+ if next is DEL_START or not next.startswith('<'):
392
+ # Reached a word, we can't move the delete text forward
393
+ break
394
+ if next[1] == '/':
395
+ # Reached a closing tag, can we go further? Maybe not...
396
+ break
397
+ name = next.split()[0].strip('<>')
398
+ if name == 'ins':
399
+ # Can't move into an insert
400
+ break
401
+ assert name != 'del', (
402
+ "Unexpected delete tag: %r" % next)
403
+ if name == finding_name:
404
+ unbalanced_start.pop(0)
405
+ pre_delete.append(post_delete.pop(0))
406
+ else:
407
+ # Found a tag that doesn't match
408
+ break
409
+
410
+ def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):
411
+ """ like locate_unbalanced_start, except handling end tags and
412
+ possibly moving the point earlier in the document. """
413
+ while 1:
414
+ if not unbalanced_end:
415
+ # Success
416
+ break
417
+ finding = unbalanced_end[-1]
418
+ finding_name = finding.split()[0].strip('<>/')
419
+ if not pre_delete:
420
+ break
421
+ next = pre_delete[-1]
422
+ if next is DEL_END or not next.startswith('</'):
423
+ # A word or a start tag
424
+ break
425
+ name = next.split()[0].strip('<>/')
426
+ if name == 'ins' or name == 'del':
427
+ # Can't move into an insert or delete
428
+ break
429
+ if name == finding_name:
430
+ unbalanced_end.pop()
431
+ post_delete.insert(0, pre_delete.pop())
432
+ else:
433
+ # Found a tag that doesn't match
434
+ break
435
+
436
+ class token(_unicode):
437
+ """ Represents a diffable token, generally a word that is displayed to
438
+ the user. Opening tags are attached to this token when they are
439
+ adjacent (pre_tags) and closing tags that follow the word
440
+ (post_tags). Some exceptions occur when there are empty tags
441
+ adjacent to a word, so there may be close tags in pre_tags, or
442
+ open tags in post_tags.
443
+
444
+ We also keep track of whether the word was originally followed by
445
+ whitespace, even though we do not want to treat the word as
446
+ equivalent to a similar word that does not have a trailing
447
+ space."""
448
+
449
+ # When this is true, the token will be eliminated from the
450
+ # displayed diff if no change has occurred:
451
+ hide_when_equal = False
452
+
453
+ def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):
454
+ obj = _unicode.__new__(cls, text)
455
+
456
+ if pre_tags is not None:
457
+ obj.pre_tags = pre_tags
458
+ else:
459
+ obj.pre_tags = []
460
+
461
+ if post_tags is not None:
462
+ obj.post_tags = post_tags
463
+ else:
464
+ obj.post_tags = []
465
+
466
+ obj.trailing_whitespace = trailing_whitespace
467
+
468
+ return obj
469
+
470
+ def __repr__(self):
471
+ return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,
472
+ self.post_tags, self.trailing_whitespace)
473
+
474
+ def html(self):
475
+ return _unicode(self)
476
+
477
+ class tag_token(token):
478
+
479
+ """ Represents a token that is actually a tag. Currently this is just
480
+ the <img> tag, which takes up visible space just like a word but
481
+ is only represented in a document by a tag. """
482
+
483
+ def __new__(cls, tag, data, html_repr, pre_tags=None,
484
+ post_tags=None, trailing_whitespace=""):
485
+ obj = token.__new__(cls, "%s: %s" % (type, data),
486
+ pre_tags=pre_tags,
487
+ post_tags=post_tags,
488
+ trailing_whitespace=trailing_whitespace)
489
+ obj.tag = tag
490
+ obj.data = data
491
+ obj.html_repr = html_repr
492
+ return obj
493
+
494
+ def __repr__(self):
495
+ return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
496
+ self.tag,
497
+ self.data,
498
+ self.html_repr,
499
+ self.pre_tags,
500
+ self.post_tags,
501
+ self.trailing_whitespace)
502
+ def html(self):
503
+ return self.html_repr
504
+
505
+ class href_token(token):
506
+
507
+ """ Represents the href in an anchor tag. Unlike other words, we only
508
+ show the href when it changes. """
509
+
510
+ hide_when_equal = True
511
+
512
+ def html(self):
513
+ return ' Link: %s' % self
514
+
515
+ def tokenize(html, include_hrefs=True):
516
+ """
517
+ Parse the given HTML and returns token objects (words with attached tags).
518
+
519
+ This parses only the content of a page; anything in the head is
520
+ ignored, and the <head> and <body> elements are themselves
521
+ optional. The content is then parsed by lxml, which ensures the
522
+ validity of the resulting parsed document (though lxml may make
523
+ incorrect guesses when the markup is particular bad).
524
+
525
+ <ins> and <del> tags are also eliminated from the document, as
526
+ that gets confusing.
527
+
528
+ If include_hrefs is true, then the href attribute of <a> tags is
529
+ included as a special kind of diffable token."""
530
+ if etree.iselement(html):
531
+ body_el = html
532
+ else:
533
+ body_el = parse_html(html, cleanup=True)
534
+ # Then we split the document into text chunks for each tag, word, and end tag:
535
+ chunks = flatten_el(body_el, skip_tag=True, include_hrefs=include_hrefs)
536
+ # Finally re-joining them into token objects:
537
+ return fixup_chunks(chunks)
538
+
539
+ def parse_html(html, cleanup=True):
540
+ """
541
+ Parses an HTML fragment, returning an lxml element. Note that the HTML will be
542
+ wrapped in a <div> tag that was not in the original document.
543
+
544
+ If cleanup is true, make sure there's no <head> or <body>, and get
545
+ rid of any <ins> and <del> tags.
546
+ """
547
+ if cleanup:
548
+ # This removes any extra markup or structure like <head>:
549
+ html = cleanup_html(html)
550
+ return fragment_fromstring(html, create_parent=True)
551
+
552
+ _body_re = re.compile(r'<body.*?>', re.I|re.S)
553
+ _end_body_re = re.compile(r'</body.*?>', re.I|re.S)
554
+ _ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
555
+
556
+ def cleanup_html(html):
557
+ """ This 'cleans' the HTML, meaning that any page structure is removed
558
+ (only the contents of <body> are used, if there is any <body).
559
+ Also <ins> and <del> tags are removed. """
560
+ match = _body_re.search(html)
561
+ if match:
562
+ html = html[match.end():]
563
+ match = _end_body_re.search(html)
564
+ if match:
565
+ html = html[:match.start()]
566
+ html = _ins_del_re.sub('', html)
567
+ return html
568
+
569
+
570
+ end_whitespace_re = re.compile(r'[ \t\n\r]$')
571
+
572
+ def split_trailing_whitespace(word):
573
+ """
574
+ This function takes a word, such as 'test\n\n' and returns ('test','\n\n')
575
+ """
576
+ stripped_length = len(word.rstrip())
577
+ return word[0:stripped_length], word[stripped_length:]
578
+
579
+
580
+ def fixup_chunks(chunks):
581
+ """
582
+ This function takes a list of chunks and produces a list of tokens.
583
+ """
584
+ tag_accum = []
585
+ cur_word = None
586
+ result = []
587
+ for chunk in chunks:
588
+ if isinstance(chunk, tuple):
589
+ if chunk[0] == 'img':
590
+ src = chunk[1]
591
+ tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
592
+ cur_word = tag_token('img', src, html_repr=tag,
593
+ pre_tags=tag_accum,
594
+ trailing_whitespace=trailing_whitespace)
595
+ tag_accum = []
596
+ result.append(cur_word)
597
+
598
+ elif chunk[0] == 'href':
599
+ href = chunk[1]
600
+ cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")
601
+ tag_accum = []
602
+ result.append(cur_word)
603
+ continue
604
+
605
+ if is_word(chunk):
606
+ chunk, trailing_whitespace = split_trailing_whitespace(chunk)
607
+ cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)
608
+ tag_accum = []
609
+ result.append(cur_word)
610
+
611
+ elif is_start_tag(chunk):
612
+ tag_accum.append(chunk)
613
+
614
+ elif is_end_tag(chunk):
615
+ if tag_accum:
616
+ tag_accum.append(chunk)
617
+ else:
618
+ assert cur_word, (
619
+ "Weird state, cur_word=%r, result=%r, chunks=%r of %r"
620
+ % (cur_word, result, chunk, chunks))
621
+ cur_word.post_tags.append(chunk)
622
+ else:
623
+ assert False
624
+
625
+ if not result:
626
+ return [token('', pre_tags=tag_accum)]
627
+ else:
628
+ result[-1].post_tags.extend(tag_accum)
629
+
630
+ return result
631
+
632
+
633
+ # All the tags in HTML that don't require end tags:
634
+ empty_tags = (
635
+ 'param', 'img', 'area', 'br', 'basefont', 'input',
636
+ 'base', 'meta', 'link', 'col')
637
+
638
+ block_level_tags = (
639
+ 'address',
640
+ 'blockquote',
641
+ 'center',
642
+ 'dir',
643
+ 'div',
644
+ 'dl',
645
+ 'fieldset',
646
+ 'form',
647
+ 'h1',
648
+ 'h2',
649
+ 'h3',
650
+ 'h4',
651
+ 'h5',
652
+ 'h6',
653
+ 'hr',
654
+ 'isindex',
655
+ 'menu',
656
+ 'noframes',
657
+ 'noscript',
658
+ 'ol',
659
+ 'p',
660
+ 'pre',
661
+ 'table',
662
+ 'ul',
663
+ )
664
+
665
+ block_level_container_tags = (
666
+ 'dd',
667
+ 'dt',
668
+ 'frameset',
669
+ 'li',
670
+ 'tbody',
671
+ 'td',
672
+ 'tfoot',
673
+ 'th',
674
+ 'thead',
675
+ 'tr',
676
+ )
677
+
678
+
679
+ def flatten_el(el, include_hrefs, skip_tag=False):
680
+ """ Takes an lxml element el, and generates all the text chunks for
681
+ that tag. Each start tag is a chunk, each word is a chunk, and each
682
+ end tag is a chunk.
683
+
684
+ If skip_tag is true, then the outermost container tag is
685
+ not returned (just its contents)."""
686
+ if not skip_tag:
687
+ if el.tag == 'img':
688
+ yield ('img', el.get('src'), start_tag(el))
689
+ else:
690
+ yield start_tag(el)
691
+ if el.tag in empty_tags and not el.text and not len(el) and not el.tail:
692
+ return
693
+ start_words = split_words(el.text)
694
+ for word in start_words:
695
+ yield html_escape(word)
696
+ for child in el:
697
+ yield from flatten_el(child, include_hrefs=include_hrefs)
698
+ if el.tag == 'a' and el.get('href') and include_hrefs:
699
+ yield ('href', el.get('href'))
700
+ if not skip_tag:
701
+ yield end_tag(el)
702
+ end_words = split_words(el.tail)
703
+ for word in end_words:
704
+ yield html_escape(word)
705
+
706
+ split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)
707
+
708
+ def split_words(text):
709
+ """ Splits some text into words. Includes trailing whitespace
710
+ on each word when appropriate. """
711
+ if not text or not text.strip():
712
+ return []
713
+
714
+ words = split_words_re.findall(text)
715
+ return words
716
+
717
+ start_whitespace_re = re.compile(r'^[ \t\n\r]')
718
+
719
+ def start_tag(el):
720
+ """
721
+ The text representation of the start tag for a tag.
722
+ """
723
+ return '<%s%s>' % (
724
+ el.tag, ''.join([' %s="%s"' % (name, html_escape(value, True))
725
+ for name, value in el.attrib.items()]))
726
+
727
+ def end_tag(el):
728
+ """ The text representation of an end tag for a tag. Includes
729
+ trailing whitespace when appropriate. """
730
+ if el.tail and start_whitespace_re.search(el.tail):
731
+ extra = ' '
732
+ else:
733
+ extra = ''
734
+ return '</%s>%s' % (el.tag, extra)
735
+
736
+ def is_word(tok):
737
+ return not tok.startswith('<')
738
+
739
+ def is_end_tag(tok):
740
+ return tok.startswith('</')
741
+
742
+ def is_start_tag(tok):
743
+ return tok.startswith('<') and not tok.startswith('</')
744
+
745
+ def fixup_ins_del_tags(html):
746
+ """ Given an html string, move any <ins> or <del> tags inside of any
747
+ block-level elements, e.g. transform <ins><p>word</p></ins> to
748
+ <p><ins>word</ins></p> """
749
+ doc = parse_html(html, cleanup=False)
750
+ _fixup_ins_del_tags(doc)
751
+ html = serialize_html_fragment(doc, skip_outer=True)
752
+ return html
753
+
754
+ def serialize_html_fragment(el, skip_outer=False):
755
+ """ Serialize a single lxml element as HTML. The serialized form
756
+ includes the elements tail.
757
+
758
+ If skip_outer is true, then don't serialize the outermost tag
759
+ """
760
+ assert not isinstance(el, basestring), (
761
+ "You should pass in an element, not a string like %r" % el)
762
+ html = etree.tostring(el, method="html", encoding=_unicode)
763
+ if skip_outer:
764
+ # Get rid of the extra starting tag:
765
+ html = html[html.find('>')+1:]
766
+ # Get rid of the extra end tag:
767
+ html = html[:html.rfind('<')]
768
+ return html.strip()
769
+ else:
770
+ return html
771
+
772
+ def _fixup_ins_del_tags(doc):
773
+ """fixup_ins_del_tags that works on an lxml document in-place
774
+ """
775
+ for tag in ['ins', 'del']:
776
+ for el in doc.xpath('descendant-or-self::%s' % tag):
777
+ if not _contains_block_level_tag(el):
778
+ continue
779
+ _move_el_inside_block(el, tag=tag)
780
+ el.drop_tag()
781
+ #_merge_element_contents(el)
782
+
783
+ def _contains_block_level_tag(el):
784
+ """True if the element contains any block-level elements, like <p>, <td>, etc.
785
+ """
786
+ if el.tag in block_level_tags or el.tag in block_level_container_tags:
787
+ return True
788
+ for child in el:
789
+ if _contains_block_level_tag(child):
790
+ return True
791
+ return False
792
+
793
+ def _move_el_inside_block(el, tag):
794
+ """ helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
795
+ and moves them inside any block-level tags. """
796
+ for child in el:
797
+ if _contains_block_level_tag(child):
798
+ break
799
+ else:
800
+ # No block-level tags in any child
801
+ children_tag = etree.Element(tag)
802
+ children_tag.text = el.text
803
+ el.text = None
804
+ children_tag.extend(list(el))
805
+ el[:] = [children_tag]
806
+ return
807
+ for child in list(el):
808
+ if _contains_block_level_tag(child):
809
+ _move_el_inside_block(child, tag)
810
+ if child.tail:
811
+ tail_tag = etree.Element(tag)
812
+ tail_tag.text = child.tail
813
+ child.tail = None
814
+ el.insert(el.index(child)+1, tail_tag)
815
+ else:
816
+ child_tag = etree.Element(tag)
817
+ el.replace(child, child_tag)
818
+ child_tag.append(child)
819
+ if el.text:
820
+ text_tag = etree.Element(tag)
821
+ text_tag.text = el.text
822
+ el.text = None
823
+ el.insert(0, text_tag)
824
+
825
+ def _merge_element_contents(el):
826
+ """
827
+ Removes an element, but merges its contents into its place, e.g.,
828
+ given <p>Hi <i>there!</i></p>, if you remove the <i> element you get
829
+ <p>Hi there!</p>
830
+ """
831
+ parent = el.getparent()
832
+ text = el.text or ''
833
+ if el.tail:
834
+ if not len(el):
835
+ text += el.tail
836
+ else:
837
+ if el[-1].tail:
838
+ el[-1].tail += el.tail
839
+ else:
840
+ el[-1].tail = el.tail
841
+ index = parent.index(el)
842
+ if text:
843
+ if index == 0:
844
+ previous = None
845
+ else:
846
+ previous = parent[index-1]
847
+ if previous is None:
848
+ if parent.text:
849
+ parent.text += text
850
+ else:
851
+ parent.text = text
852
+ else:
853
+ if previous.tail:
854
+ previous.tail += text
855
+ else:
856
+ previous.tail = text
857
+ parent[index:index+1] = el.getchildren()
858
+
859
+ class InsensitiveSequenceMatcher(difflib.SequenceMatcher):
860
+ """
861
+ Acts like SequenceMatcher, but tries not to find very small equal
862
+ blocks amidst large spans of changes
863
+ """
864
+
865
+ threshold = 2
866
+
867
+ def get_matching_blocks(self):
868
+ size = min(len(self.b), len(self.b))
869
+ threshold = min(self.threshold, size / 4)
870
+ actual = difflib.SequenceMatcher.get_matching_blocks(self)
871
+ return [item for item in actual
872
+ if item[2] > threshold
873
+ or not item[2]]
874
+
875
+ if __name__ == '__main__':
876
+ from lxml.html import _diffcommand
877
+ _diffcommand.main()
878
+
llmeval-env/lib/python3.10/site-packages/lxml/html/formfill.py ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lxml.etree import XPath, ElementBase
2
+ from lxml.html import fromstring, XHTML_NAMESPACE
3
+ from lxml.html import _forms_xpath, _options_xpath, _nons, _transform_result
4
+ from lxml.html import defs
5
+ import copy
6
+
7
+ try:
8
+ basestring
9
+ except NameError:
10
+ # Python 3
11
+ basestring = str
12
+
13
+ __all__ = ['FormNotFound', 'fill_form', 'fill_form_html',
14
+ 'insert_errors', 'insert_errors_html',
15
+ 'DefaultErrorCreator']
16
+
17
+ class FormNotFound(LookupError):
18
+ """
19
+ Raised when no form can be found
20
+ """
21
+
22
+ _form_name_xpath = XPath('descendant-or-self::form[name=$name]|descendant-or-self::x:form[name=$name]', namespaces={'x':XHTML_NAMESPACE})
23
+ _input_xpath = XPath('|'.join(['descendant-or-self::'+_tag for _tag in ('input','select','textarea','x:input','x:select','x:textarea')]),
24
+ namespaces={'x':XHTML_NAMESPACE})
25
+ _label_for_xpath = XPath('//label[@for=$for_id]|//x:label[@for=$for_id]',
26
+ namespaces={'x':XHTML_NAMESPACE})
27
+ _name_xpath = XPath('descendant-or-self::*[@name=$name]')
28
+
29
+ def fill_form(
30
+ el,
31
+ values,
32
+ form_id=None,
33
+ form_index=None,
34
+ ):
35
+ el = _find_form(el, form_id=form_id, form_index=form_index)
36
+ _fill_form(el, values)
37
+
38
+ def fill_form_html(html, values, form_id=None, form_index=None):
39
+ result_type = type(html)
40
+ if isinstance(html, basestring):
41
+ doc = fromstring(html)
42
+ else:
43
+ doc = copy.deepcopy(html)
44
+ fill_form(doc, values, form_id=form_id, form_index=form_index)
45
+ return _transform_result(result_type, doc)
46
+
47
+ def _fill_form(el, values):
48
+ counts = {}
49
+ if hasattr(values, 'mixed'):
50
+ # For Paste request parameters
51
+ values = values.mixed()
52
+ inputs = _input_xpath(el)
53
+ for input in inputs:
54
+ name = input.get('name')
55
+ if not name:
56
+ continue
57
+ if _takes_multiple(input):
58
+ value = values.get(name, [])
59
+ if not isinstance(value, (list, tuple)):
60
+ value = [value]
61
+ _fill_multiple(input, value)
62
+ elif name not in values:
63
+ continue
64
+ else:
65
+ index = counts.get(name, 0)
66
+ counts[name] = index + 1
67
+ value = values[name]
68
+ if isinstance(value, (list, tuple)):
69
+ try:
70
+ value = value[index]
71
+ except IndexError:
72
+ continue
73
+ elif index > 0:
74
+ continue
75
+ _fill_single(input, value)
76
+
77
+ def _takes_multiple(input):
78
+ if _nons(input.tag) == 'select' and input.get('multiple'):
79
+ # FIXME: multiple="0"?
80
+ return True
81
+ type = input.get('type', '').lower()
82
+ if type in ('radio', 'checkbox'):
83
+ return True
84
+ return False
85
+
86
+ def _fill_multiple(input, value):
87
+ type = input.get('type', '').lower()
88
+ if type == 'checkbox':
89
+ v = input.get('value')
90
+ if v is None:
91
+ if not value:
92
+ result = False
93
+ else:
94
+ result = value[0]
95
+ if isinstance(value, basestring):
96
+ # The only valid "on" value for an unnamed checkbox is 'on'
97
+ result = result == 'on'
98
+ _check(input, result)
99
+ else:
100
+ _check(input, v in value)
101
+ elif type == 'radio':
102
+ v = input.get('value')
103
+ _check(input, v in value)
104
+ else:
105
+ assert _nons(input.tag) == 'select'
106
+ for option in _options_xpath(input):
107
+ v = option.get('value')
108
+ if v is None:
109
+ # This seems to be the default, at least on IE
110
+ # FIXME: but I'm not sure
111
+ v = option.text_content()
112
+ _select(option, v in value)
113
+
114
+ def _check(el, check):
115
+ if check:
116
+ el.set('checked', '')
117
+ else:
118
+ if 'checked' in el.attrib:
119
+ del el.attrib['checked']
120
+
121
+ def _select(el, select):
122
+ if select:
123
+ el.set('selected', '')
124
+ else:
125
+ if 'selected' in el.attrib:
126
+ del el.attrib['selected']
127
+
128
+ def _fill_single(input, value):
129
+ if _nons(input.tag) == 'textarea':
130
+ input.text = value
131
+ else:
132
+ input.set('value', value)
133
+
134
+ def _find_form(el, form_id=None, form_index=None):
135
+ if form_id is None and form_index is None:
136
+ forms = _forms_xpath(el)
137
+ for form in forms:
138
+ return form
139
+ raise FormNotFound(
140
+ "No forms in page")
141
+ if form_id is not None:
142
+ form = el.get_element_by_id(form_id)
143
+ if form is not None:
144
+ return form
145
+ forms = _form_name_xpath(el, name=form_id)
146
+ if forms:
147
+ return forms[0]
148
+ else:
149
+ raise FormNotFound(
150
+ "No form with the name or id of %r (forms: %s)"
151
+ % (id, ', '.join(_find_form_ids(el))))
152
+ if form_index is not None:
153
+ forms = _forms_xpath(el)
154
+ try:
155
+ return forms[form_index]
156
+ except IndexError:
157
+ raise FormNotFound(
158
+ "There is no form with the index %r (%i forms found)"
159
+ % (form_index, len(forms)))
160
+
161
+ def _find_form_ids(el):
162
+ forms = _forms_xpath(el)
163
+ if not forms:
164
+ yield '(no forms)'
165
+ return
166
+ for index, form in enumerate(forms):
167
+ if form.get('id'):
168
+ if form.get('name'):
169
+ yield '%s or %s' % (form.get('id'),
170
+ form.get('name'))
171
+ else:
172
+ yield form.get('id')
173
+ elif form.get('name'):
174
+ yield form.get('name')
175
+ else:
176
+ yield '(unnamed form %s)' % index
177
+
178
+ ############################################################
179
+ ## Error filling
180
+ ############################################################
181
+
182
+ class DefaultErrorCreator:
183
+ insert_before = True
184
+ block_inside = True
185
+ error_container_tag = 'div'
186
+ error_message_class = 'error-message'
187
+ error_block_class = 'error-block'
188
+ default_message = "Invalid"
189
+
190
+ def __init__(self, **kw):
191
+ for name, value in kw.items():
192
+ if not hasattr(self, name):
193
+ raise TypeError(
194
+ "Unexpected keyword argument: %s" % name)
195
+ setattr(self, name, value)
196
+
197
+ def __call__(self, el, is_block, message):
198
+ error_el = el.makeelement(self.error_container_tag)
199
+ if self.error_message_class:
200
+ error_el.set('class', self.error_message_class)
201
+ if is_block and self.error_block_class:
202
+ error_el.set('class', error_el.get('class', '')+' '+self.error_block_class)
203
+ if message is None or message == '':
204
+ message = self.default_message
205
+ if isinstance(message, ElementBase):
206
+ error_el.append(message)
207
+ else:
208
+ assert isinstance(message, basestring), (
209
+ "Bad message; should be a string or element: %r" % message)
210
+ error_el.text = message or self.default_message
211
+ if is_block and self.block_inside:
212
+ if self.insert_before:
213
+ error_el.tail = el.text
214
+ el.text = None
215
+ el.insert(0, error_el)
216
+ else:
217
+ el.append(error_el)
218
+ else:
219
+ parent = el.getparent()
220
+ pos = parent.index(el)
221
+ if self.insert_before:
222
+ parent.insert(pos, error_el)
223
+ else:
224
+ error_el.tail = el.tail
225
+ el.tail = None
226
+ parent.insert(pos+1, error_el)
227
+
228
+ default_error_creator = DefaultErrorCreator()
229
+
230
+
231
+ def insert_errors(
232
+ el,
233
+ errors,
234
+ form_id=None,
235
+ form_index=None,
236
+ error_class="error",
237
+ error_creator=default_error_creator,
238
+ ):
239
+ el = _find_form(el, form_id=form_id, form_index=form_index)
240
+ for name, error in errors.items():
241
+ if error is None:
242
+ continue
243
+ for error_el, message in _find_elements_for_name(el, name, error):
244
+ assert isinstance(message, (basestring, type(None), ElementBase)), (
245
+ "Bad message: %r" % message)
246
+ _insert_error(error_el, message, error_class, error_creator)
247
+
248
+ def insert_errors_html(html, values, **kw):
249
+ result_type = type(html)
250
+ if isinstance(html, basestring):
251
+ doc = fromstring(html)
252
+ else:
253
+ doc = copy.deepcopy(html)
254
+ insert_errors(doc, values, **kw)
255
+ return _transform_result(result_type, doc)
256
+
257
+ def _insert_error(el, error, error_class, error_creator):
258
+ if _nons(el.tag) in defs.empty_tags or _nons(el.tag) == 'textarea':
259
+ is_block = False
260
+ else:
261
+ is_block = True
262
+ if _nons(el.tag) != 'form' and error_class:
263
+ _add_class(el, error_class)
264
+ if el.get('id'):
265
+ labels = _label_for_xpath(el, for_id=el.get('id'))
266
+ if labels:
267
+ for label in labels:
268
+ _add_class(label, error_class)
269
+ error_creator(el, is_block, error)
270
+
271
+ def _add_class(el, class_name):
272
+ if el.get('class'):
273
+ el.set('class', el.get('class')+' '+class_name)
274
+ else:
275
+ el.set('class', class_name)
276
+
277
+ def _find_elements_for_name(form, name, error):
278
+ if name is None:
279
+ # An error for the entire form
280
+ yield form, error
281
+ return
282
+ if name.startswith('#'):
283
+ # By id
284
+ el = form.get_element_by_id(name[1:])
285
+ if el is not None:
286
+ yield el, error
287
+ return
288
+ els = _name_xpath(form, name=name)
289
+ if not els:
290
+ # FIXME: should this raise an exception?
291
+ return
292
+ if not isinstance(error, (list, tuple)):
293
+ yield els[0], error
294
+ return
295
+ # FIXME: if error is longer than els, should it raise an error?
296
+ for el, err in zip(els, error):
297
+ if err is None:
298
+ continue
299
+ yield el, err
llmeval-env/lib/python3.10/site-packages/lxml/html/usedoctest.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Doctest module for HTML comparison.
2
+
3
+ Usage::
4
+
5
+ >>> import lxml.html.usedoctest
6
+ >>> # now do your HTML doctests ...
7
+
8
+ See `lxml.doctestcompare`.
9
+ """
10
+
11
+ from lxml import doctestcompare
12
+
13
+ doctestcompare.temp_install(html=True, del_module=__name__)
llmeval-env/lib/python3.10/site-packages/lxml/includes/__init__.pxd ADDED
File without changes
llmeval-env/lib/python3.10/site-packages/lxml/includes/__init__.py ADDED
File without changes
llmeval-env/lib/python3.10/site-packages/lxml/includes/c14n.pxd ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lxml.includes.tree cimport xmlDoc, xmlOutputBuffer, xmlChar
2
+ from lxml.includes.xpath cimport xmlNodeSet
3
+
4
+ cdef extern from "libxml/c14n.h" nogil:
5
+ cdef int xmlC14NDocDumpMemory(xmlDoc* doc,
6
+ xmlNodeSet* nodes,
7
+ int exclusive,
8
+ xmlChar** inclusive_ns_prefixes,
9
+ int with_comments,
10
+ xmlChar** doc_txt_ptr)
11
+
12
+ cdef int xmlC14NDocSave(xmlDoc* doc,
13
+ xmlNodeSet* nodes,
14
+ int exclusive,
15
+ xmlChar** inclusive_ns_prefixes,
16
+ int with_comments,
17
+ char* filename,
18
+ int compression)
19
+
20
+ cdef int xmlC14NDocSaveTo(xmlDoc* doc,
21
+ xmlNodeSet* nodes,
22
+ int exclusive,
23
+ xmlChar** inclusive_ns_prefixes,
24
+ int with_comments,
25
+ xmlOutputBuffer* buffer)
llmeval-env/lib/python3.10/site-packages/lxml/includes/config.pxd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ cdef extern from "etree_defs.h":
2
+ cdef bint ENABLE_THREADING
3
+ cdef bint ENABLE_SCHEMATRON
llmeval-env/lib/python3.10/site-packages/lxml/includes/dtdvalid.pxd ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lxml.includes cimport tree
2
+ from lxml.includes.tree cimport xmlDoc, xmlDtd
3
+
4
+ cdef extern from "libxml/valid.h" nogil:
5
+ ctypedef void (*xmlValidityErrorFunc)(void * ctx, const char * msg, ...) noexcept
6
+ ctypedef void (*xmlValidityWarningFunc)(void * ctx, const char * msg, ...) noexcept
7
+
8
+ ctypedef struct xmlValidCtxt:
9
+ void *userData
10
+ xmlValidityErrorFunc error
11
+ xmlValidityWarningFunc warning
12
+
13
+ cdef xmlValidCtxt* xmlNewValidCtxt()
14
+ cdef void xmlFreeValidCtxt(xmlValidCtxt* cur)
15
+
16
+ cdef int xmlValidateDtd(xmlValidCtxt* ctxt, xmlDoc* doc, xmlDtd* dtd)
17
+ cdef tree.xmlElement* xmlGetDtdElementDesc(
18
+ xmlDtd* dtd, tree.const_xmlChar* name)
llmeval-env/lib/python3.10/site-packages/lxml/includes/etree_defs.h ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef HAS_ETREE_DEFS_H
2
+ #define HAS_ETREE_DEFS_H
3
+
4
+ /* quick check for Python/libxml2/libxslt devel setup */
5
+ #include "Python.h"
6
+ #ifndef PY_VERSION_HEX
7
+ # error the development package of Python (header files etc.) is not installed correctly
8
+ #elif PY_VERSION_HEX < 0x03060000
9
+ # error this version of lxml requires Python 3.6 or later
10
+ #endif
11
+
12
+ #include "libxml/xmlversion.h"
13
+ #ifndef LIBXML_VERSION
14
+ # error the development package of libxml2 (header files etc.) is not installed correctly
15
+ #elif LIBXML_VERSION < 20700
16
+ # error minimum required version of libxml2 is 2.7.0
17
+ #endif
18
+
19
+ #include "libxslt/xsltconfig.h"
20
+ #ifndef LIBXSLT_VERSION
21
+ # error the development package of libxslt (header files etc.) is not installed correctly
22
+ #elif LIBXSLT_VERSION < 10123
23
+ # error minimum required version of libxslt is 1.1.23
24
+ #endif
25
+
26
+
27
+ /* v_arg functions */
28
+ #define va_int(ap) va_arg(ap, int)
29
+ #define va_charptr(ap) va_arg(ap, char *)
30
+
31
+ #ifdef PYPY_VERSION
32
+ # define IS_PYPY 1
33
+ #else
34
+ # define IS_PYPY 0
35
+ #endif
36
+
37
+ /* unused */
38
+ #define IS_PYTHON2 0
39
+ #define IS_PYTHON3 1
40
+ #undef LXML_UNICODE_STRINGS
41
+ #define LXML_UNICODE_STRINGS 1
42
+
43
+ #if !IS_PYPY
44
+ # define PyWeakref_LockObject(obj) (NULL)
45
+ #endif
46
+
47
+ /* Threading is not currently supported by PyPy */
48
+ #if IS_PYPY
49
+ # ifndef WITHOUT_THREADING
50
+ # define WITHOUT_THREADING
51
+ # endif
52
+ #endif
53
+
54
+ #if IS_PYPY
55
+ # ifndef PyUnicode_FromFormat
56
+ # define PyUnicode_FromFormat PyString_FromFormat
57
+ # endif
58
+ # if !defined(PyBytes_FromFormat)
59
+ # ifdef PyString_FromFormat
60
+ # define PyBytes_FromFormat PyString_FromFormat
61
+ # else
62
+ #include <stdarg.h>
63
+ static PyObject* PyBytes_FromFormat(const char* format, ...) {
64
+ PyObject *string;
65
+ va_list vargs;
66
+ #ifdef HAVE_STDARG_PROTOTYPES
67
+ va_start(vargs, format);
68
+ #else
69
+ va_start(vargs);
70
+ #endif
71
+ string = PyUnicode_FromFormatV(format, vargs);
72
+ va_end(vargs);
73
+ if (string && PyUnicode_Check(string)) {
74
+ PyObject *bstring = PyUnicode_AsUTF8String(string);
75
+ Py_DECREF(string);
76
+ string = bstring;
77
+ }
78
+ if (string && !PyBytes_CheckExact(string)) {
79
+ Py_DECREF(string);
80
+ string = NULL;
81
+ PyErr_SetString(PyExc_TypeError, "String formatting and encoding failed to return bytes object");
82
+ }
83
+ return string;
84
+ }
85
+ # endif
86
+ # endif
87
+ #endif
88
+
89
+ #if PY_VERSION_HEX >= 0x030B00A1
90
+ /* Python 3.12 doesn't have wstr Unicode strings any more. */
91
+ #undef PyUnicode_GET_DATA_SIZE
92
+ #define PyUnicode_GET_DATA_SIZE(ustr) (0)
93
+ #undef PyUnicode_AS_DATA
94
+ #define PyUnicode_AS_DATA(ustr) (NULL)
95
+ #undef PyUnicode_IS_READY
96
+ #define PyUnicode_IS_READY(ustr) (1)
97
+ #endif
98
+
99
+ #ifdef WITHOUT_THREADING
100
+ # undef PyEval_SaveThread
101
+ # define PyEval_SaveThread() (NULL)
102
+ # undef PyEval_RestoreThread
103
+ # define PyEval_RestoreThread(state) if (state); else {}
104
+ # undef PyGILState_Ensure
105
+ # define PyGILState_Ensure() (PyGILState_UNLOCKED)
106
+ # undef PyGILState_Release
107
+ # define PyGILState_Release(state) if (state); else {}
108
+ # undef Py_UNBLOCK_THREADS
109
+ # define Py_UNBLOCK_THREADS _save = NULL;
110
+ # undef Py_BLOCK_THREADS
111
+ # define Py_BLOCK_THREADS if (_save); else {}
112
+ #endif
113
+
114
+ #ifdef WITHOUT_THREADING
115
+ # define ENABLE_THREADING 0
116
+ #else
117
+ # define ENABLE_THREADING 1
118
+ #endif
119
+
120
+ #if LIBXML_VERSION < 20704
121
+ /* FIXME: hack to make new error reporting compile in old libxml2 versions */
122
+ # define xmlStructuredErrorContext NULL
123
+ # define xmlXIncludeProcessTreeFlagsData(n,o,d) xmlXIncludeProcessTreeFlags(n,o)
124
+ #endif
125
+
126
+ /* schematron was added in libxml2 2.6.21 */
127
+ #ifdef LIBXML_SCHEMATRON_ENABLED
128
+ # define ENABLE_SCHEMATRON 1
129
+ #else
130
+ # define ENABLE_SCHEMATRON 0
131
+ # define XML_SCHEMATRON_OUT_QUIET 0
132
+ # define XML_SCHEMATRON_OUT_XML 0
133
+ # define XML_SCHEMATRON_OUT_ERROR 0
134
+ typedef void xmlSchematron;
135
+ typedef void xmlSchematronParserCtxt;
136
+ typedef void xmlSchematronValidCtxt;
137
+ # define xmlSchematronNewDocParserCtxt(doc) NULL
138
+ # define xmlSchematronNewParserCtxt(file) NULL
139
+ # define xmlSchematronParse(ctxt) NULL
140
+ # define xmlSchematronFreeParserCtxt(ctxt)
141
+ # define xmlSchematronFree(schema)
142
+ # define xmlSchematronNewValidCtxt(schema, options) NULL
143
+ # define xmlSchematronValidateDoc(ctxt, doc) 0
144
+ # define xmlSchematronFreeValidCtxt(ctxt)
145
+ # define xmlSchematronSetValidStructuredErrors(ctxt, errorfunc, data)
146
+ #endif
147
+
148
+ #if LIBXML_VERSION < 20708
149
+ # define HTML_PARSE_NODEFDTD 4
150
+ #endif
151
+ #if LIBXML_VERSION < 20900
152
+ # define XML_PARSE_BIG_LINES 4194304
153
+ #endif
154
+
155
+ #include "libxml/tree.h"
156
+ #ifndef LIBXML2_NEW_BUFFER
157
+ typedef xmlBuffer xmlBuf;
158
+ # define xmlBufContent(buf) xmlBufferContent(buf)
159
+ # define xmlBufUse(buf) xmlBufferLength(buf)
160
+ #endif
161
+
162
+ /* libexslt 1.1.25+ support EXSLT functions in XPath */
163
+ #if LIBXSLT_VERSION < 10125
164
+ #define exsltDateXpathCtxtRegister(ctxt, prefix)
165
+ #define exsltSetsXpathCtxtRegister(ctxt, prefix)
166
+ #define exsltMathXpathCtxtRegister(ctxt, prefix)
167
+ #define exsltStrXpathCtxtRegister(ctxt, prefix)
168
+ #endif
169
+
170
+ #define LXML_GET_XSLT_ENCODING(result_var, style) XSLT_GET_IMPORT_PTR(result_var, style, encoding)
171
+
172
+ /* work around MSDEV 6.0 */
173
+ #if (_MSC_VER == 1200) && (WINVER < 0x0500)
174
+ long _ftol( double ); //defined by VC6 C libs
175
+ long _ftol2( double dblSource ) { return _ftol( dblSource ); }
176
+ #endif
177
+
178
+ #ifdef __GNUC__
179
+ /* Test for GCC > 2.95 */
180
+ #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
181
+ #define unlikely_condition(x) __builtin_expect((x), 0)
182
+ #else /* __GNUC__ > 2 ... */
183
+ #define unlikely_condition(x) (x)
184
+ #endif /* __GNUC__ > 2 ... */
185
+ #else /* __GNUC__ */
186
+ #define unlikely_condition(x) (x)
187
+ #endif /* __GNUC__ */
188
+
189
+ #ifndef Py_TYPE
190
+ #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
191
+ #endif
192
+
193
+ #define PY_NEW(T) \
194
+ (((PyTypeObject*)(T))->tp_new( \
195
+ (PyTypeObject*)(T), __pyx_empty_tuple, NULL))
196
+
197
+ #define _fqtypename(o) ((Py_TYPE(o))->tp_name)
198
+
199
+ #define lxml_malloc(count, item_size) \
200
+ (unlikely_condition((size_t)(count) > (size_t) (PY_SSIZE_T_MAX / item_size)) ? NULL : \
201
+ (PyMem_Malloc((count) * item_size)))
202
+
203
+ #define lxml_realloc(mem, count, item_size) \
204
+ (unlikely_condition((size_t)(count) > (size_t) (PY_SSIZE_T_MAX / item_size)) ? NULL : \
205
+ (PyMem_Realloc(mem, (count) * item_size)))
206
+
207
+ #define lxml_free(mem) PyMem_Free(mem)
208
+
209
+ #define _isString(obj) (PyUnicode_Check(obj) || PyBytes_Check(obj))
210
+
211
+ #define _isElement(c_node) \
212
+ (((c_node)->type == XML_ELEMENT_NODE) || \
213
+ ((c_node)->type == XML_COMMENT_NODE) || \
214
+ ((c_node)->type == XML_ENTITY_REF_NODE) || \
215
+ ((c_node)->type == XML_PI_NODE))
216
+
217
+ #define _isElementOrXInclude(c_node) \
218
+ (_isElement(c_node) || \
219
+ ((c_node)->type == XML_XINCLUDE_START) || \
220
+ ((c_node)->type == XML_XINCLUDE_END))
221
+
222
+ #define _getNs(c_node) \
223
+ (((c_node)->ns == 0) ? 0 : ((c_node)->ns->href))
224
+
225
+
226
+ #include "string.h"
227
+ static void* lxml_unpack_xmldoc_capsule(PyObject* capsule, int* is_owned) {
228
+ xmlDoc *c_doc;
229
+ void *context;
230
+ *is_owned = 0;
231
+ if (unlikely_condition(!PyCapsule_IsValid(capsule, (const char*)"libxml2:xmlDoc"))) {
232
+ PyErr_SetString(
233
+ PyExc_TypeError,
234
+ "Not a valid capsule. The capsule argument must be a capsule object with name libxml2:xmlDoc");
235
+ return NULL;
236
+ }
237
+ c_doc = (xmlDoc*) PyCapsule_GetPointer(capsule, (const char*)"libxml2:xmlDoc");
238
+ if (unlikely_condition(!c_doc)) return NULL;
239
+
240
+ if (unlikely_condition(c_doc->type != XML_DOCUMENT_NODE && c_doc->type != XML_HTML_DOCUMENT_NODE)) {
241
+ PyErr_Format(
242
+ PyExc_ValueError,
243
+ "Illegal document provided: expected XML or HTML, found %d", (int)c_doc->type);
244
+ return NULL;
245
+ }
246
+
247
+ context = PyCapsule_GetContext(capsule);
248
+ if (unlikely_condition(!context && PyErr_Occurred())) return NULL;
249
+ if (context && strcmp((const char*) context, "destructor:xmlFreeDoc") == 0) {
250
+ /* take ownership by setting destructor to NULL */
251
+ if (PyCapsule_SetDestructor(capsule, NULL) == 0) {
252
+ /* ownership transferred => invalidate capsule by clearing its name */
253
+ if (unlikely_condition(PyCapsule_SetName(capsule, NULL))) {
254
+ /* this should never happen since everything above succeeded */
255
+ xmlFreeDoc(c_doc);
256
+ return NULL;
257
+ }
258
+ *is_owned = 1;
259
+ }
260
+ }
261
+ return c_doc;
262
+ }
263
+
264
+ /* Macro pair implementation of a depth first tree walker
265
+ *
266
+ * Calls the code block between the BEGIN and END macros for all elements
267
+ * below c_tree_top (exclusively), starting at c_node (inclusively iff
268
+ * 'inclusive' is 1). The _ELEMENT_ variants will only stop on nodes
269
+ * that match _isElement(), the normal variant will stop on every node
270
+ * except text nodes.
271
+ *
272
+ * To traverse the node and all of its children and siblings in Pyrex, call
273
+ * cdef xmlNode* some_node
274
+ * BEGIN_FOR_EACH_ELEMENT_FROM(some_node.parent, some_node, 1)
275
+ * # do something with some_node
276
+ * END_FOR_EACH_ELEMENT_FROM(some_node)
277
+ *
278
+ * To traverse only the children and siblings of a node, call
279
+ * cdef xmlNode* some_node
280
+ * BEGIN_FOR_EACH_ELEMENT_FROM(some_node.parent, some_node, 0)
281
+ * # do something with some_node
282
+ * END_FOR_EACH_ELEMENT_FROM(some_node)
283
+ *
284
+ * To traverse only the children, do:
285
+ * cdef xmlNode* some_node
286
+ * some_node = parent_node.children
287
+ * BEGIN_FOR_EACH_ELEMENT_FROM(parent_node, some_node, 1)
288
+ * # do something with some_node
289
+ * END_FOR_EACH_ELEMENT_FROM(some_node)
290
+ *
291
+ * NOTE: 'some_node' MUST be a plain 'xmlNode*' !
292
+ *
293
+ * NOTE: parent modification during the walk can divert the iterator, but
294
+ * should not segfault !
295
+ */
296
+
297
+ #define _LX__ELEMENT_MATCH(c_node, only_elements) \
298
+ ((only_elements) ? (_isElement(c_node)) : 1)
299
+
300
+ #define _LX__ADVANCE_TO_NEXT(c_node, only_elements) \
301
+ while ((c_node != 0) && (!_LX__ELEMENT_MATCH(c_node, only_elements))) \
302
+ c_node = c_node->next;
303
+
304
+ #define _LX__TRAVERSE_TO_NEXT(c_stop_node, c_node, only_elements) \
305
+ { \
306
+ /* walk through children first */ \
307
+ xmlNode* _lx__next = c_node->children; \
308
+ if (_lx__next != 0) { \
309
+ if (c_node->type == XML_ENTITY_REF_NODE || c_node->type == XML_DTD_NODE) { \
310
+ _lx__next = 0; \
311
+ } else { \
312
+ _LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
313
+ } \
314
+ } \
315
+ if ((_lx__next == 0) && (c_node != c_stop_node)) { \
316
+ /* try siblings */ \
317
+ _lx__next = c_node->next; \
318
+ _LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
319
+ /* back off through parents */ \
320
+ while (_lx__next == 0) { \
321
+ c_node = c_node->parent; \
322
+ if (c_node == 0) \
323
+ break; \
324
+ if (c_node == c_stop_node) \
325
+ break; \
326
+ if ((only_elements) && !_isElement(c_node)) \
327
+ break; \
328
+ /* we already traversed the parents -> siblings */ \
329
+ _lx__next = c_node->next; \
330
+ _LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
331
+ } \
332
+ } \
333
+ c_node = _lx__next; \
334
+ }
335
+
336
+ #define _LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, only_elements) \
337
+ { \
338
+ if (c_node != 0) { \
339
+ const xmlNode* _lx__tree_top = (c_tree_top); \
340
+ const int _lx__only_elements = (only_elements); \
341
+ /* make sure we start at an element */ \
342
+ if (!_LX__ELEMENT_MATCH(c_node, _lx__only_elements)) { \
343
+ /* we skip the node, so 'inclusive' is irrelevant */ \
344
+ if (c_node == _lx__tree_top) \
345
+ c_node = 0; /* nothing to traverse */ \
346
+ else { \
347
+ c_node = c_node->next; \
348
+ _LX__ADVANCE_TO_NEXT(c_node, _lx__only_elements) \
349
+ } \
350
+ } else if (! (inclusive)) { \
351
+ /* skip the first node */ \
352
+ _LX__TRAVERSE_TO_NEXT(_lx__tree_top, c_node, _lx__only_elements) \
353
+ } \
354
+ \
355
+ /* now run the user code on the elements we find */ \
356
+ while (c_node != 0) { \
357
+ /* here goes the code to be run for each element */
358
+
359
+ #define _LX__END_FOR_EACH_FROM(c_node) \
360
+ _LX__TRAVERSE_TO_NEXT(_lx__tree_top, c_node, _lx__only_elements) \
361
+ } \
362
+ } \
363
+ }
364
+
365
+
366
+ #define BEGIN_FOR_EACH_ELEMENT_FROM(c_tree_top, c_node, inclusive) \
367
+ _LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, 1)
368
+
369
+ #define END_FOR_EACH_ELEMENT_FROM(c_node) \
370
+ _LX__END_FOR_EACH_FROM(c_node)
371
+
372
+ #define BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive) \
373
+ _LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, 0)
374
+
375
+ #define END_FOR_EACH_FROM(c_node) \
376
+ _LX__END_FOR_EACH_FROM(c_node)
377
+
378
+
379
+ #endif /* HAS_ETREE_DEFS_H */
llmeval-env/lib/python3.10/site-packages/lxml/includes/etreepublic.pxd ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # public Cython/C interface to lxml.etree
2
+
3
+ from lxml.includes cimport tree
4
+ from lxml.includes.tree cimport const_xmlChar
5
+
6
+ cdef extern from "lxml-version.h":
7
+ cdef char* LXML_VERSION_STRING
8
+
9
+ cdef extern from "etree_defs.h":
10
+ # test if c_node is considered an Element (i.e. Element, Comment, etc.)
11
+ cdef bint _isElement(tree.xmlNode* c_node) noexcept nogil
12
+
13
+ # return the namespace URI of the node or NULL
14
+ cdef const_xmlChar* _getNs(tree.xmlNode* node) noexcept nogil
15
+
16
+ # pair of macros for tree traversal
17
+ cdef void BEGIN_FOR_EACH_ELEMENT_FROM(tree.xmlNode* tree_top,
18
+ tree.xmlNode* start_node,
19
+ int start_node_inclusive) noexcept nogil
20
+ cdef void END_FOR_EACH_ELEMENT_FROM(tree.xmlNode* start_node) noexcept nogil
21
+
22
+ cdef extern from "etree_api.h":
23
+
24
+ # first function to call!
25
+ cdef int import_lxml__etree() except -1
26
+
27
+ ##########################################################################
28
+ # public ElementTree API classes
29
+
30
+ cdef class lxml.etree._Document [ object LxmlDocument ]:
31
+ cdef tree.xmlDoc* _c_doc
32
+
33
+ cdef class lxml.etree._Element [ object LxmlElement ]:
34
+ cdef _Document _doc
35
+ cdef tree.xmlNode* _c_node
36
+
37
+ cdef class lxml.etree.ElementBase(_Element) [ object LxmlElementBase ]:
38
+ pass
39
+
40
+ cdef class lxml.etree._ElementTree [ object LxmlElementTree ]:
41
+ cdef _Document _doc
42
+ cdef _Element _context_node
43
+
44
+ cdef class lxml.etree.ElementClassLookup [ object LxmlElementClassLookup ]:
45
+ cdef object (*_lookup_function)(object, _Document, tree.xmlNode*)
46
+
47
+ cdef class lxml.etree.FallbackElementClassLookup(ElementClassLookup) \
48
+ [ object LxmlFallbackElementClassLookup ]:
49
+ cdef ElementClassLookup fallback
50
+ cdef object (*_fallback_function)(object, _Document, tree.xmlNode*)
51
+
52
+ ##########################################################################
53
+ # creating Element objects
54
+
55
+ # create an Element for a C-node in the Document
56
+ cdef _Element elementFactory(_Document doc, tree.xmlNode* c_node)
57
+
58
+ # create an ElementTree for an Element
59
+ cdef _ElementTree elementTreeFactory(_Element context_node)
60
+
61
+ # create an ElementTree subclass for an Element
62
+ cdef _ElementTree newElementTree(_Element context_node, object subclass)
63
+
64
+ # create an ElementTree from an external document
65
+ cdef _ElementTree adoptExternalDocument(tree.xmlDoc* c_doc, parser, bint is_owned)
66
+
67
+ # create a new Element for an existing or new document (doc = None)
68
+ # builds Python object after setting text, tail, namespaces and attributes
69
+ cdef _Element makeElement(tag, _Document doc, parser,
70
+ text, tail, attrib, nsmap)
71
+
72
+ # create a new SubElement for an existing parent
73
+ # builds Python object after setting text, tail, namespaces and attributes
74
+ cdef _Element makeSubElement(_Element parent, tag, text, tail,
75
+ attrib, nsmap)
76
+
77
+ # deep copy a node to include it in the Document
78
+ cdef _Element deepcopyNodeToDocument(_Document doc, tree.xmlNode* c_root)
79
+
80
+ # set the internal lookup function for Element/Comment/PI classes
81
+ # use setElementClassLookupFunction(NULL, None) to reset it
82
+ # note that the lookup function *must always* return an _Element subclass!
83
+ cdef void setElementClassLookupFunction(
84
+ object (*function)(object, _Document, tree.xmlNode*), object state)
85
+
86
+ # lookup function that always returns the default Element class
87
+ # note that the first argument is expected to be None!
88
+ cdef object lookupDefaultElementClass(_1, _Document _2,
89
+ tree.xmlNode* c_node)
90
+
91
+ # lookup function for namespace/tag specific Element classes
92
+ # note that the first argument is expected to be None!
93
+ cdef object lookupNamespaceElementClass(_1, _Document _2,
94
+ tree.xmlNode* c_node)
95
+
96
+ # call the fallback lookup function of a FallbackElementClassLookup
97
+ cdef object callLookupFallback(FallbackElementClassLookup lookup,
98
+ _Document doc, tree.xmlNode* c_node)
99
+
100
+ ##########################################################################
101
+ # XML attribute access
102
+
103
+ # return an attribute value for a C attribute on a C element node
104
+ cdef unicode attributeValue(tree.xmlNode* c_element,
105
+ tree.xmlAttr* c_attrib_node)
106
+
107
+ # return the value of the attribute with 'ns' and 'name' (or None)
108
+ cdef unicode attributeValueFromNsName(tree.xmlNode* c_element,
109
+ const_xmlChar* c_ns, const_xmlChar* c_name)
110
+
111
+ # return the value of attribute "{ns}name", or the default value
112
+ cdef object getAttributeValue(_Element element, key, default)
113
+
114
+ # return an iterator over attribute names (1), values (2) or items (3)
115
+ # attributes must not be removed during iteration!
116
+ cdef object iterattributes(_Element element, int keysvalues)
117
+
118
+ # return the list of all attribute names (1), values (2) or items (3)
119
+ cdef list collectAttributes(tree.xmlNode* c_element, int keysvalues)
120
+
121
+ # set an attribute value on an element
122
+ # on failure, sets an exception and returns -1
123
+ cdef int setAttributeValue(_Element element, key, value) except -1
124
+
125
+ # delete an attribute
126
+ # on failure, sets an exception and returns -1
127
+ cdef int delAttribute(_Element element, key) except -1
128
+
129
+ # delete an attribute based on name and namespace URI
130
+ # returns -1 if the attribute was not found (no exception)
131
+ cdef int delAttributeFromNsName(tree.xmlNode* c_element,
132
+ const_xmlChar* c_href, const_xmlChar* c_name) noexcept
133
+
134
+ ##########################################################################
135
+ # XML node helper functions
136
+
137
+ # check if the element has at least one child
138
+ cdef bint hasChild(tree.xmlNode* c_node) noexcept nogil
139
+
140
+ # find child element number 'index' (supports negative indexes)
141
+ cdef tree.xmlNode* findChild(tree.xmlNode* c_node,
142
+ Py_ssize_t index) noexcept nogil
143
+
144
+ # find child element number 'index' starting at first one
145
+ cdef tree.xmlNode* findChildForwards(tree.xmlNode* c_node,
146
+ Py_ssize_t index) nogil
147
+
148
+ # find child element number 'index' starting at last one
149
+ cdef tree.xmlNode* findChildBackwards(tree.xmlNode* c_node,
150
+ Py_ssize_t index) nogil
151
+
152
+ # return next/previous sibling element of the node
153
+ cdef tree.xmlNode* nextElement(tree.xmlNode* c_node) nogil
154
+ cdef tree.xmlNode* previousElement(tree.xmlNode* c_node) nogil
155
+
156
+ ##########################################################################
157
+ # iterators (DEPRECATED API, don't use in new code!)
158
+
159
+ cdef class lxml.etree._ElementTagMatcher [ object LxmlElementTagMatcher ]:
160
+ cdef char* _href
161
+ cdef char* _name
162
+
163
+ # store "{ns}tag" (or None) filter for this matcher or element iterator
164
+ # ** unless _href *and* _name are set up 'by hand', this function *must*
165
+ # ** be called when subclassing the iterator below!
166
+ cdef void initTagMatch(_ElementTagMatcher matcher, tag)
167
+
168
+ cdef class lxml.etree._ElementIterator(_ElementTagMatcher) [
169
+ object LxmlElementIterator ]:
170
+ cdef _Element _node
171
+ cdef tree.xmlNode* (*_next_element)(tree.xmlNode*)
172
+
173
+ # store the initial node of the iterator if it matches the required tag
174
+ # or its next matching sibling if not
175
+ cdef void iteratorStoreNext(_ElementIterator iterator, _Element node)
176
+
177
+ ##########################################################################
178
+ # other helper functions
179
+
180
+ # check if a C node matches a tag name and namespace
181
+ # (NULL allowed for each => always matches)
182
+ cdef int tagMatches(tree.xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name)
183
+
184
+ # convert a UTF-8 char* to a Python unicode string
185
+ cdef unicode pyunicode(const_xmlChar* s)
186
+
187
+ # convert the string to UTF-8 using the normal lxml.etree semantics
188
+ cdef bytes utf8(object s)
189
+
190
+ # split a tag into a (URI, name) tuple, return None as URI for '{}tag'
191
+ cdef tuple getNsTag(object tag)
192
+
193
+ # split a tag into a (URI, name) tuple, return b'' as URI for '{}tag'
194
+ cdef tuple getNsTagWithEmptyNs(object tag)
195
+
196
+ # get the "{ns}tag" string for a C node
197
+ cdef unicode namespacedName(tree.xmlNode* c_node)
198
+
199
+ # get the "{ns}tag" string for a href/tagname pair (c_ns may be NULL)
200
+ cdef unicode namespacedNameFromNsName(const_xmlChar* c_ns, const_xmlChar* c_tag)
201
+
202
+ # check if the node has a text value (which may be '')
203
+ cdef bint hasText(tree.xmlNode* c_node) nogil
204
+
205
+ # check if the node has a tail value (which may be '')
206
+ cdef bint hasTail(tree.xmlNode* c_node) nogil
207
+
208
+ # get the text content of an element (or None)
209
+ cdef unicode textOf(tree.xmlNode* c_node)
210
+
211
+ # get the tail content of an element (or None)
212
+ cdef unicode tailOf(tree.xmlNode* c_node)
213
+
214
+ # set the text value of an element
215
+ cdef int setNodeText(tree.xmlNode* c_node, text) except -1
216
+
217
+ # set the tail text value of an element
218
+ cdef int setTailText(tree.xmlNode* c_node, text) except -1
219
+
220
+ # append an element to the children of a parent element
221
+ # deprecated: don't use, does not propagate exceptions!
222
+ # use appendChildToElement() instead
223
+ cdef void appendChild(_Element parent, _Element child)
224
+
225
+ # added in lxml 3.3 as a safe replacement for appendChild()
226
+ # return -1 for exception, 0 for ok
227
+ cdef int appendChildToElement(_Element parent, _Element child) except -1
228
+
229
+ # recursively lookup a namespace in element or ancestors, or create it
230
+ cdef tree.xmlNs* findOrBuildNodeNsPrefix(
231
+ _Document doc, tree.xmlNode* c_node, const_xmlChar* href, const_xmlChar* prefix)
232
+
233
+ # find the Document of an Element, ElementTree or Document (itself!)
234
+ cdef _Document documentOrRaise(object input)
235
+
236
+ # find the root Element of an Element (itself!), ElementTree or Document
237
+ cdef _Element rootNodeOrRaise(object input)
llmeval-env/lib/python3.10/site-packages/lxml/includes/htmlparser.pxd ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from libc.string cimport const_char
2
+
3
+ from lxml.includes.tree cimport xmlDoc
4
+ from lxml.includes.tree cimport xmlInputReadCallback, xmlInputCloseCallback
5
+ from lxml.includes.xmlparser cimport xmlParserCtxt, xmlSAXHandler, xmlSAXHandlerV1
6
+
7
+ cdef extern from "libxml/HTMLparser.h" nogil:
8
+ ctypedef enum htmlParserOption:
9
+ HTML_PARSE_NOERROR # suppress error reports
10
+ HTML_PARSE_NOWARNING # suppress warning reports
11
+ HTML_PARSE_PEDANTIC # pedantic error reporting
12
+ HTML_PARSE_NOBLANKS # remove blank nodes
13
+ HTML_PARSE_NONET # Forbid network access
14
+ # libxml2 2.6.21+ only:
15
+ HTML_PARSE_RECOVER # Relaxed parsing
16
+ HTML_PARSE_COMPACT # compact small text nodes
17
+ # libxml2 2.7.7+ only:
18
+ HTML_PARSE_NOIMPLIED # Do not add implied html/body... elements
19
+ # libxml2 2.7.8+ only:
20
+ HTML_PARSE_NODEFDTD # do not default a doctype if not found
21
+ # libxml2 2.8.0+ only:
22
+ XML_PARSE_IGNORE_ENC # ignore internal document encoding hint
23
+
24
+ xmlSAXHandlerV1 htmlDefaultSAXHandler
25
+
26
+ cdef xmlParserCtxt* htmlCreateMemoryParserCtxt(
27
+ char* buffer, int size)
28
+ cdef xmlParserCtxt* htmlCreateFileParserCtxt(
29
+ char* filename, char* encoding)
30
+ cdef xmlParserCtxt* htmlCreatePushParserCtxt(xmlSAXHandler* sax,
31
+ void* user_data,
32
+ char* chunk, int size,
33
+ char* filename, int enc)
34
+ cdef void htmlFreeParserCtxt(xmlParserCtxt* ctxt)
35
+ cdef void htmlCtxtReset(xmlParserCtxt* ctxt)
36
+ cdef int htmlCtxtUseOptions(xmlParserCtxt* ctxt, int options)
37
+ cdef int htmlParseDocument(xmlParserCtxt* ctxt)
38
+ cdef int htmlParseChunk(xmlParserCtxt* ctxt,
39
+ char* chunk, int size, int terminate)
40
+
41
+ cdef xmlDoc* htmlCtxtReadFile(xmlParserCtxt* ctxt,
42
+ char* filename, const_char* encoding,
43
+ int options)
44
+ cdef xmlDoc* htmlCtxtReadDoc(xmlParserCtxt* ctxt,
45
+ char* buffer, char* URL, const_char* encoding,
46
+ int options)
47
+ cdef xmlDoc* htmlCtxtReadIO(xmlParserCtxt* ctxt,
48
+ xmlInputReadCallback ioread,
49
+ xmlInputCloseCallback ioclose,
50
+ void* ioctx,
51
+ char* URL, const_char* encoding,
52
+ int options)
53
+ cdef xmlDoc* htmlCtxtReadMemory(xmlParserCtxt* ctxt,
54
+ char* buffer, int size,
55
+ char* filename, const_char* encoding,
56
+ int options)
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/HTMLparser.h ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for an HTML 4.0 non-verifying parser
3
+ * Description: this module implements an HTML 4.0 non-verifying parser
4
+ * with API compatible with the XML parser ones. It should
5
+ * be able to parse "real world" HTML, even if severely
6
+ * broken from a specification point of view.
7
+ *
8
+ * Copy: See Copyright for the status of this software.
9
+ *
10
+ * Author: Daniel Veillard
11
+ */
12
+
13
+ #ifndef __HTML_PARSER_H__
14
+ #define __HTML_PARSER_H__
15
+ #include <libxml/xmlversion.h>
16
+ #include <libxml/parser.h>
17
+
18
+ #ifdef LIBXML_HTML_ENABLED
19
+
20
+ #ifdef __cplusplus
21
+ extern "C" {
22
+ #endif
23
+
24
+ /*
25
+ * Most of the back-end structures from XML and HTML are shared.
26
+ */
27
+ typedef xmlParserCtxt htmlParserCtxt;
28
+ typedef xmlParserCtxtPtr htmlParserCtxtPtr;
29
+ typedef xmlParserNodeInfo htmlParserNodeInfo;
30
+ typedef xmlSAXHandler htmlSAXHandler;
31
+ typedef xmlSAXHandlerPtr htmlSAXHandlerPtr;
32
+ typedef xmlParserInput htmlParserInput;
33
+ typedef xmlParserInputPtr htmlParserInputPtr;
34
+ typedef xmlDocPtr htmlDocPtr;
35
+ typedef xmlNodePtr htmlNodePtr;
36
+
37
+ /*
38
+ * Internal description of an HTML element, representing HTML 4.01
39
+ * and XHTML 1.0 (which share the same structure).
40
+ */
41
+ typedef struct _htmlElemDesc htmlElemDesc;
42
+ typedef htmlElemDesc *htmlElemDescPtr;
43
+ struct _htmlElemDesc {
44
+ const char *name; /* The tag name */
45
+ char startTag; /* Whether the start tag can be implied */
46
+ char endTag; /* Whether the end tag can be implied */
47
+ char saveEndTag; /* Whether the end tag should be saved */
48
+ char empty; /* Is this an empty element ? */
49
+ char depr; /* Is this a deprecated element ? */
50
+ char dtd; /* 1: only in Loose DTD, 2: only Frameset one */
51
+ char isinline; /* is this a block 0 or inline 1 element */
52
+ const char *desc; /* the description */
53
+
54
+ /* NRK Jan.2003
55
+ * New fields encapsulating HTML structure
56
+ *
57
+ * Bugs:
58
+ * This is a very limited representation. It fails to tell us when
59
+ * an element *requires* subelements (we only have whether they're
60
+ * allowed or not), and it doesn't tell us where CDATA and PCDATA
61
+ * are allowed. Some element relationships are not fully represented:
62
+ * these are flagged with the word MODIFIER
63
+ */
64
+ const char** subelts; /* allowed sub-elements of this element */
65
+ const char* defaultsubelt; /* subelement for suggested auto-repair
66
+ if necessary or NULL */
67
+ const char** attrs_opt; /* Optional Attributes */
68
+ const char** attrs_depr; /* Additional deprecated attributes */
69
+ const char** attrs_req; /* Required attributes */
70
+ };
71
+
72
+ /*
73
+ * Internal description of an HTML entity.
74
+ */
75
+ typedef struct _htmlEntityDesc htmlEntityDesc;
76
+ typedef htmlEntityDesc *htmlEntityDescPtr;
77
+ struct _htmlEntityDesc {
78
+ unsigned int value; /* the UNICODE value for the character */
79
+ const char *name; /* The entity name */
80
+ const char *desc; /* the description */
81
+ };
82
+
83
+ /** DOC_DISABLE */
84
+ #ifdef LIBXML_SAX1_ENABLED
85
+ #define XML_GLOBALS_HTML \
86
+ XML_OP(htmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
87
+ #else
88
+ #define XML_GLOBALS_HTML
89
+ #endif
90
+
91
+ #define XML_OP XML_DECLARE_GLOBAL
92
+ XML_GLOBALS_HTML
93
+ #undef XML_OP
94
+
95
+ #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
96
+ #define htmlDefaultSAXHandler XML_GLOBAL_MACRO(htmlDefaultSAXHandler)
97
+ #endif
98
+ /** DOC_ENABLE */
99
+
100
+ /*
101
+ * There is only few public functions.
102
+ */
103
+ XML_DEPRECATED
104
+ XMLPUBFUN void
105
+ htmlInitAutoClose (void);
106
+ XMLPUBFUN const htmlElemDesc *
107
+ htmlTagLookup (const xmlChar *tag);
108
+ XMLPUBFUN const htmlEntityDesc *
109
+ htmlEntityLookup(const xmlChar *name);
110
+ XMLPUBFUN const htmlEntityDesc *
111
+ htmlEntityValueLookup(unsigned int value);
112
+
113
+ XMLPUBFUN int
114
+ htmlIsAutoClosed(htmlDocPtr doc,
115
+ htmlNodePtr elem);
116
+ XMLPUBFUN int
117
+ htmlAutoCloseTag(htmlDocPtr doc,
118
+ const xmlChar *name,
119
+ htmlNodePtr elem);
120
+ XML_DEPRECATED
121
+ XMLPUBFUN const htmlEntityDesc *
122
+ htmlParseEntityRef(htmlParserCtxtPtr ctxt,
123
+ const xmlChar **str);
124
+ XML_DEPRECATED
125
+ XMLPUBFUN int
126
+ htmlParseCharRef(htmlParserCtxtPtr ctxt);
127
+ XML_DEPRECATED
128
+ XMLPUBFUN void
129
+ htmlParseElement(htmlParserCtxtPtr ctxt);
130
+
131
+ XMLPUBFUN htmlParserCtxtPtr
132
+ htmlNewParserCtxt(void);
133
+ XMLPUBFUN htmlParserCtxtPtr
134
+ htmlNewSAXParserCtxt(const htmlSAXHandler *sax,
135
+ void *userData);
136
+
137
+ XMLPUBFUN htmlParserCtxtPtr
138
+ htmlCreateMemoryParserCtxt(const char *buffer,
139
+ int size);
140
+
141
+ XMLPUBFUN int
142
+ htmlParseDocument(htmlParserCtxtPtr ctxt);
143
+ XML_DEPRECATED
144
+ XMLPUBFUN htmlDocPtr
145
+ htmlSAXParseDoc (const xmlChar *cur,
146
+ const char *encoding,
147
+ htmlSAXHandlerPtr sax,
148
+ void *userData);
149
+ XMLPUBFUN htmlDocPtr
150
+ htmlParseDoc (const xmlChar *cur,
151
+ const char *encoding);
152
+ XMLPUBFUN htmlParserCtxtPtr
153
+ htmlCreateFileParserCtxt(const char *filename,
154
+ const char *encoding);
155
+ XML_DEPRECATED
156
+ XMLPUBFUN htmlDocPtr
157
+ htmlSAXParseFile(const char *filename,
158
+ const char *encoding,
159
+ htmlSAXHandlerPtr sax,
160
+ void *userData);
161
+ XMLPUBFUN htmlDocPtr
162
+ htmlParseFile (const char *filename,
163
+ const char *encoding);
164
+ XMLPUBFUN int
165
+ UTF8ToHtml (unsigned char *out,
166
+ int *outlen,
167
+ const unsigned char *in,
168
+ int *inlen);
169
+ XMLPUBFUN int
170
+ htmlEncodeEntities(unsigned char *out,
171
+ int *outlen,
172
+ const unsigned char *in,
173
+ int *inlen, int quoteChar);
174
+ XMLPUBFUN int
175
+ htmlIsScriptAttribute(const xmlChar *name);
176
+ XMLPUBFUN int
177
+ htmlHandleOmittedElem(int val);
178
+
179
+ #ifdef LIBXML_PUSH_ENABLED
180
+ /**
181
+ * Interfaces for the Push mode.
182
+ */
183
+ XMLPUBFUN htmlParserCtxtPtr
184
+ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
185
+ void *user_data,
186
+ const char *chunk,
187
+ int size,
188
+ const char *filename,
189
+ xmlCharEncoding enc);
190
+ XMLPUBFUN int
191
+ htmlParseChunk (htmlParserCtxtPtr ctxt,
192
+ const char *chunk,
193
+ int size,
194
+ int terminate);
195
+ #endif /* LIBXML_PUSH_ENABLED */
196
+
197
+ XMLPUBFUN void
198
+ htmlFreeParserCtxt (htmlParserCtxtPtr ctxt);
199
+
200
+ /*
201
+ * New set of simpler/more flexible APIs
202
+ */
203
+ /**
204
+ * xmlParserOption:
205
+ *
206
+ * This is the set of XML parser options that can be passed down
207
+ * to the xmlReadDoc() and similar calls.
208
+ */
209
+ typedef enum {
210
+ HTML_PARSE_RECOVER = 1<<0, /* Relaxed parsing */
211
+ HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */
212
+ HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */
213
+ HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */
214
+ HTML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
215
+ HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
216
+ HTML_PARSE_NONET = 1<<11,/* Forbid network access */
217
+ HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */
218
+ HTML_PARSE_COMPACT = 1<<16,/* compact small text nodes */
219
+ HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */
220
+ } htmlParserOption;
221
+
222
+ XMLPUBFUN void
223
+ htmlCtxtReset (htmlParserCtxtPtr ctxt);
224
+ XMLPUBFUN int
225
+ htmlCtxtUseOptions (htmlParserCtxtPtr ctxt,
226
+ int options);
227
+ XMLPUBFUN htmlDocPtr
228
+ htmlReadDoc (const xmlChar *cur,
229
+ const char *URL,
230
+ const char *encoding,
231
+ int options);
232
+ XMLPUBFUN htmlDocPtr
233
+ htmlReadFile (const char *URL,
234
+ const char *encoding,
235
+ int options);
236
+ XMLPUBFUN htmlDocPtr
237
+ htmlReadMemory (const char *buffer,
238
+ int size,
239
+ const char *URL,
240
+ const char *encoding,
241
+ int options);
242
+ XMLPUBFUN htmlDocPtr
243
+ htmlReadFd (int fd,
244
+ const char *URL,
245
+ const char *encoding,
246
+ int options);
247
+ XMLPUBFUN htmlDocPtr
248
+ htmlReadIO (xmlInputReadCallback ioread,
249
+ xmlInputCloseCallback ioclose,
250
+ void *ioctx,
251
+ const char *URL,
252
+ const char *encoding,
253
+ int options);
254
+ XMLPUBFUN htmlDocPtr
255
+ htmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
256
+ const xmlChar *cur,
257
+ const char *URL,
258
+ const char *encoding,
259
+ int options);
260
+ XMLPUBFUN htmlDocPtr
261
+ htmlCtxtReadFile (xmlParserCtxtPtr ctxt,
262
+ const char *filename,
263
+ const char *encoding,
264
+ int options);
265
+ XMLPUBFUN htmlDocPtr
266
+ htmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
267
+ const char *buffer,
268
+ int size,
269
+ const char *URL,
270
+ const char *encoding,
271
+ int options);
272
+ XMLPUBFUN htmlDocPtr
273
+ htmlCtxtReadFd (xmlParserCtxtPtr ctxt,
274
+ int fd,
275
+ const char *URL,
276
+ const char *encoding,
277
+ int options);
278
+ XMLPUBFUN htmlDocPtr
279
+ htmlCtxtReadIO (xmlParserCtxtPtr ctxt,
280
+ xmlInputReadCallback ioread,
281
+ xmlInputCloseCallback ioclose,
282
+ void *ioctx,
283
+ const char *URL,
284
+ const char *encoding,
285
+ int options);
286
+
287
+ /* NRK/Jan2003: further knowledge of HTML structure
288
+ */
289
+ typedef enum {
290
+ HTML_NA = 0 , /* something we don't check at all */
291
+ HTML_INVALID = 0x1 ,
292
+ HTML_DEPRECATED = 0x2 ,
293
+ HTML_VALID = 0x4 ,
294
+ HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */
295
+ } htmlStatus ;
296
+
297
+ /* Using htmlElemDesc rather than name here, to emphasise the fact
298
+ that otherwise there's a lookup overhead
299
+ */
300
+ XMLPUBFUN htmlStatus htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ;
301
+ XMLPUBFUN int htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ;
302
+ XMLPUBFUN htmlStatus htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ;
303
+ XMLPUBFUN htmlStatus htmlNodeStatus(const htmlNodePtr, int) ;
304
+ /**
305
+ * htmlDefaultSubelement:
306
+ * @elt: HTML element
307
+ *
308
+ * Returns the default subelement for this element
309
+ */
310
+ #define htmlDefaultSubelement(elt) elt->defaultsubelt
311
+ /**
312
+ * htmlElementAllowedHereDesc:
313
+ * @parent: HTML parent element
314
+ * @elt: HTML element
315
+ *
316
+ * Checks whether an HTML element description may be a
317
+ * direct child of the specified element.
318
+ *
319
+ * Returns 1 if allowed; 0 otherwise.
320
+ */
321
+ #define htmlElementAllowedHereDesc(parent,elt) \
322
+ htmlElementAllowedHere((parent), (elt)->name)
323
+ /**
324
+ * htmlRequiredAttrs:
325
+ * @elt: HTML element
326
+ *
327
+ * Returns the attributes required for the specified element.
328
+ */
329
+ #define htmlRequiredAttrs(elt) (elt)->attrs_req
330
+
331
+
332
+ #ifdef __cplusplus
333
+ }
334
+ #endif
335
+
336
+ #else /* LIBXML_HTML_ENABLED */
337
+
338
+ /** DOC_DISABLE */
339
+ #define XML_GLOBALS_HTML
340
+ /** DOC_ENABLE */
341
+
342
+ #endif /* LIBXML_HTML_ENABLED */
343
+ #endif /* __HTML_PARSER_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/HTMLtree.h ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: specific APIs to process HTML tree, especially serialization
3
+ * Description: this module implements a few function needed to process
4
+ * tree in an HTML specific way.
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+ #ifndef __HTML_TREE_H__
12
+ #define __HTML_TREE_H__
13
+
14
+ #include <stdio.h>
15
+ #include <libxml/xmlversion.h>
16
+ #include <libxml/tree.h>
17
+ #include <libxml/HTMLparser.h>
18
+
19
+ #ifdef LIBXML_HTML_ENABLED
20
+
21
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif
24
+
25
+
26
+ /**
27
+ * HTML_TEXT_NODE:
28
+ *
29
+ * Macro. A text node in a HTML document is really implemented
30
+ * the same way as a text node in an XML document.
31
+ */
32
+ #define HTML_TEXT_NODE XML_TEXT_NODE
33
+ /**
34
+ * HTML_ENTITY_REF_NODE:
35
+ *
36
+ * Macro. An entity reference in a HTML document is really implemented
37
+ * the same way as an entity reference in an XML document.
38
+ */
39
+ #define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE
40
+ /**
41
+ * HTML_COMMENT_NODE:
42
+ *
43
+ * Macro. A comment in a HTML document is really implemented
44
+ * the same way as a comment in an XML document.
45
+ */
46
+ #define HTML_COMMENT_NODE XML_COMMENT_NODE
47
+ /**
48
+ * HTML_PRESERVE_NODE:
49
+ *
50
+ * Macro. A preserved node in a HTML document is really implemented
51
+ * the same way as a CDATA section in an XML document.
52
+ */
53
+ #define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE
54
+ /**
55
+ * HTML_PI_NODE:
56
+ *
57
+ * Macro. A processing instruction in a HTML document is really implemented
58
+ * the same way as a processing instruction in an XML document.
59
+ */
60
+ #define HTML_PI_NODE XML_PI_NODE
61
+
62
+ XMLPUBFUN htmlDocPtr
63
+ htmlNewDoc (const xmlChar *URI,
64
+ const xmlChar *ExternalID);
65
+ XMLPUBFUN htmlDocPtr
66
+ htmlNewDocNoDtD (const xmlChar *URI,
67
+ const xmlChar *ExternalID);
68
+ XMLPUBFUN const xmlChar *
69
+ htmlGetMetaEncoding (htmlDocPtr doc);
70
+ XMLPUBFUN int
71
+ htmlSetMetaEncoding (htmlDocPtr doc,
72
+ const xmlChar *encoding);
73
+ #ifdef LIBXML_OUTPUT_ENABLED
74
+ XMLPUBFUN void
75
+ htmlDocDumpMemory (xmlDocPtr cur,
76
+ xmlChar **mem,
77
+ int *size);
78
+ XMLPUBFUN void
79
+ htmlDocDumpMemoryFormat (xmlDocPtr cur,
80
+ xmlChar **mem,
81
+ int *size,
82
+ int format);
83
+ XMLPUBFUN int
84
+ htmlDocDump (FILE *f,
85
+ xmlDocPtr cur);
86
+ XMLPUBFUN int
87
+ htmlSaveFile (const char *filename,
88
+ xmlDocPtr cur);
89
+ XMLPUBFUN int
90
+ htmlNodeDump (xmlBufferPtr buf,
91
+ xmlDocPtr doc,
92
+ xmlNodePtr cur);
93
+ XMLPUBFUN void
94
+ htmlNodeDumpFile (FILE *out,
95
+ xmlDocPtr doc,
96
+ xmlNodePtr cur);
97
+ XMLPUBFUN int
98
+ htmlNodeDumpFileFormat (FILE *out,
99
+ xmlDocPtr doc,
100
+ xmlNodePtr cur,
101
+ const char *encoding,
102
+ int format);
103
+ XMLPUBFUN int
104
+ htmlSaveFileEnc (const char *filename,
105
+ xmlDocPtr cur,
106
+ const char *encoding);
107
+ XMLPUBFUN int
108
+ htmlSaveFileFormat (const char *filename,
109
+ xmlDocPtr cur,
110
+ const char *encoding,
111
+ int format);
112
+
113
+ XMLPUBFUN void
114
+ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf,
115
+ xmlDocPtr doc,
116
+ xmlNodePtr cur,
117
+ const char *encoding,
118
+ int format);
119
+ XMLPUBFUN void
120
+ htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
121
+ xmlDocPtr cur,
122
+ const char *encoding);
123
+ XMLPUBFUN void
124
+ htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf,
125
+ xmlDocPtr cur,
126
+ const char *encoding,
127
+ int format);
128
+ XMLPUBFUN void
129
+ htmlNodeDumpOutput (xmlOutputBufferPtr buf,
130
+ xmlDocPtr doc,
131
+ xmlNodePtr cur,
132
+ const char *encoding);
133
+
134
+ #endif /* LIBXML_OUTPUT_ENABLED */
135
+
136
+ XMLPUBFUN int
137
+ htmlIsBooleanAttr (const xmlChar *name);
138
+
139
+
140
+ #ifdef __cplusplus
141
+ }
142
+ #endif
143
+
144
+ #endif /* LIBXML_HTML_ENABLED */
145
+
146
+ #endif /* __HTML_TREE_H__ */
147
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/dict.h ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: string dictionary
3
+ * Description: dictionary of reusable strings, just used to avoid allocation
4
+ * and freeing operations.
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+ #ifndef __XML_DICT_H__
12
+ #define __XML_DICT_H__
13
+
14
+ #include <stddef.h>
15
+ #include <libxml/xmlversion.h>
16
+ #include <libxml/xmlstring.h>
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ /*
23
+ * The dictionary.
24
+ */
25
+ typedef struct _xmlDict xmlDict;
26
+ typedef xmlDict *xmlDictPtr;
27
+
28
+ /*
29
+ * Initializer
30
+ */
31
+ XML_DEPRECATED
32
+ XMLPUBFUN int xmlInitializeDict(void);
33
+
34
+ /*
35
+ * Constructor and destructor.
36
+ */
37
+ XMLPUBFUN xmlDictPtr
38
+ xmlDictCreate (void);
39
+ XMLPUBFUN size_t
40
+ xmlDictSetLimit (xmlDictPtr dict,
41
+ size_t limit);
42
+ XMLPUBFUN size_t
43
+ xmlDictGetUsage (xmlDictPtr dict);
44
+ XMLPUBFUN xmlDictPtr
45
+ xmlDictCreateSub(xmlDictPtr sub);
46
+ XMLPUBFUN int
47
+ xmlDictReference(xmlDictPtr dict);
48
+ XMLPUBFUN void
49
+ xmlDictFree (xmlDictPtr dict);
50
+
51
+ /*
52
+ * Lookup of entry in the dictionary.
53
+ */
54
+ XMLPUBFUN const xmlChar *
55
+ xmlDictLookup (xmlDictPtr dict,
56
+ const xmlChar *name,
57
+ int len);
58
+ XMLPUBFUN const xmlChar *
59
+ xmlDictExists (xmlDictPtr dict,
60
+ const xmlChar *name,
61
+ int len);
62
+ XMLPUBFUN const xmlChar *
63
+ xmlDictQLookup (xmlDictPtr dict,
64
+ const xmlChar *prefix,
65
+ const xmlChar *name);
66
+ XMLPUBFUN int
67
+ xmlDictOwns (xmlDictPtr dict,
68
+ const xmlChar *str);
69
+ XMLPUBFUN int
70
+ xmlDictSize (xmlDictPtr dict);
71
+
72
+ /*
73
+ * Cleanup function
74
+ */
75
+ XML_DEPRECATED
76
+ XMLPUBFUN void
77
+ xmlDictCleanup (void);
78
+
79
+ #ifdef __cplusplus
80
+ }
81
+ #endif
82
+ #endif /* ! __XML_DICT_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/encoding.h ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the encoding conversion functions
3
+ * Description: interface for the encoding conversion functions needed for
4
+ * XML basic encoding and iconv() support.
5
+ *
6
+ * Related specs are
7
+ * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies
8
+ * [ISO-10646] UTF-8 and UTF-16 in Annexes
9
+ * [ISO-8859-1] ISO Latin-1 characters codes.
10
+ * [UNICODE] The Unicode Consortium, "The Unicode Standard --
11
+ * Worldwide Character Encoding -- Version 1.0", Addison-
12
+ * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is
13
+ * described in Unicode Technical Report #4.
14
+ * [US-ASCII] Coded Character Set--7-bit American Standard Code for
15
+ * Information Interchange, ANSI X3.4-1986.
16
+ *
17
+ * Copy: See Copyright for the status of this software.
18
+ *
19
+ * Author: Daniel Veillard
20
+ */
21
+
22
+ #ifndef __XML_CHAR_ENCODING_H__
23
+ #define __XML_CHAR_ENCODING_H__
24
+
25
+ #include <libxml/xmlversion.h>
26
+
27
+ #ifdef LIBXML_ICONV_ENABLED
28
+ #include <iconv.h>
29
+ #endif
30
+
31
+ #ifdef __cplusplus
32
+ extern "C" {
33
+ #endif
34
+
35
+ typedef enum {
36
+ XML_ENC_ERR_SUCCESS = 0,
37
+ XML_ENC_ERR_SPACE = -1,
38
+ XML_ENC_ERR_INPUT = -2,
39
+ XML_ENC_ERR_PARTIAL = -3,
40
+ XML_ENC_ERR_INTERNAL = -4,
41
+ XML_ENC_ERR_MEMORY = -5
42
+ } xmlCharEncError;
43
+
44
+ /*
45
+ * xmlCharEncoding:
46
+ *
47
+ * Predefined values for some standard encodings.
48
+ * Libxml does not do beforehand translation on UTF8 and ISOLatinX.
49
+ * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default.
50
+ *
51
+ * Anything else would have to be translated to UTF8 before being
52
+ * given to the parser itself. The BOM for UTF16 and the encoding
53
+ * declaration are looked at and a converter is looked for at that
54
+ * point. If not found the parser stops here as asked by the XML REC. A
55
+ * converter can be registered by the user using xmlRegisterCharEncodingHandler
56
+ * but the current form doesn't allow stateful transcoding (a serious
57
+ * problem agreed !). If iconv has been found it will be used
58
+ * automatically and allow stateful transcoding, the simplest is then
59
+ * to be sure to enable iconv and to provide iconv libs for the encoding
60
+ * support needed.
61
+ *
62
+ * Note that the generic "UTF-16" is not a predefined value. Instead, only
63
+ * the specific UTF-16LE and UTF-16BE are present.
64
+ */
65
+ typedef enum {
66
+ XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
67
+ XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
68
+ XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
69
+ XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
70
+ XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
71
+ XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
72
+ XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
73
+ XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
74
+ XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
75
+ XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
76
+ XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
77
+ XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
78
+ XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
79
+ XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
80
+ XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
81
+ XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
82
+ XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
83
+ XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
84
+ XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
85
+ XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
86
+ XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
87
+ XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
88
+ XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
89
+ XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
90
+ } xmlCharEncoding;
91
+
92
+ /**
93
+ * xmlCharEncodingInputFunc:
94
+ * @out: a pointer to an array of bytes to store the UTF-8 result
95
+ * @outlen: the length of @out
96
+ * @in: a pointer to an array of chars in the original encoding
97
+ * @inlen: the length of @in
98
+ *
99
+ * Take a block of chars in the original encoding and try to convert
100
+ * it to an UTF-8 block of chars out.
101
+ *
102
+ * Returns the number of bytes written, -1 if lack of space, or -2
103
+ * if the transcoding failed.
104
+ * The value of @inlen after return is the number of octets consumed
105
+ * if the return value is positive, else unpredictiable.
106
+ * The value of @outlen after return is the number of octets consumed.
107
+ */
108
+ typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
109
+ const unsigned char *in, int *inlen);
110
+
111
+
112
+ /**
113
+ * xmlCharEncodingOutputFunc:
114
+ * @out: a pointer to an array of bytes to store the result
115
+ * @outlen: the length of @out
116
+ * @in: a pointer to an array of UTF-8 chars
117
+ * @inlen: the length of @in
118
+ *
119
+ * Take a block of UTF-8 chars in and try to convert it to another
120
+ * encoding.
121
+ * Note: a first call designed to produce heading info is called with
122
+ * in = NULL. If stateful this should also initialize the encoder state.
123
+ *
124
+ * Returns the number of bytes written, -1 if lack of space, or -2
125
+ * if the transcoding failed.
126
+ * The value of @inlen after return is the number of octets consumed
127
+ * if the return value is positive, else unpredictiable.
128
+ * The value of @outlen after return is the number of octets produced.
129
+ */
130
+ typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
131
+ const unsigned char *in, int *inlen);
132
+
133
+
134
+ /*
135
+ * Block defining the handlers for non UTF-8 encodings.
136
+ * If iconv is supported, there are two extra fields.
137
+ */
138
+ typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
139
+ typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
140
+ struct _xmlCharEncodingHandler {
141
+ char *name;
142
+ xmlCharEncodingInputFunc input;
143
+ xmlCharEncodingOutputFunc output;
144
+ #ifdef LIBXML_ICONV_ENABLED
145
+ iconv_t iconv_in;
146
+ iconv_t iconv_out;
147
+ #endif /* LIBXML_ICONV_ENABLED */
148
+ #ifdef LIBXML_ICU_ENABLED
149
+ struct _uconv_t *uconv_in;
150
+ struct _uconv_t *uconv_out;
151
+ #endif /* LIBXML_ICU_ENABLED */
152
+ };
153
+
154
+ /*
155
+ * Interfaces for encoding handlers.
156
+ */
157
+ XML_DEPRECATED
158
+ XMLPUBFUN void
159
+ xmlInitCharEncodingHandlers (void);
160
+ XML_DEPRECATED
161
+ XMLPUBFUN void
162
+ xmlCleanupCharEncodingHandlers (void);
163
+ XMLPUBFUN void
164
+ xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
165
+ XMLPUBFUN xmlCharEncodingHandlerPtr
166
+ xmlGetCharEncodingHandler (xmlCharEncoding enc);
167
+ XMLPUBFUN xmlCharEncodingHandlerPtr
168
+ xmlFindCharEncodingHandler (const char *name);
169
+ XMLPUBFUN xmlCharEncodingHandlerPtr
170
+ xmlNewCharEncodingHandler (const char *name,
171
+ xmlCharEncodingInputFunc input,
172
+ xmlCharEncodingOutputFunc output);
173
+
174
+ /*
175
+ * Interfaces for encoding names and aliases.
176
+ */
177
+ XMLPUBFUN int
178
+ xmlAddEncodingAlias (const char *name,
179
+ const char *alias);
180
+ XMLPUBFUN int
181
+ xmlDelEncodingAlias (const char *alias);
182
+ XMLPUBFUN const char *
183
+ xmlGetEncodingAlias (const char *alias);
184
+ XMLPUBFUN void
185
+ xmlCleanupEncodingAliases (void);
186
+ XMLPUBFUN xmlCharEncoding
187
+ xmlParseCharEncoding (const char *name);
188
+ XMLPUBFUN const char *
189
+ xmlGetCharEncodingName (xmlCharEncoding enc);
190
+
191
+ /*
192
+ * Interfaces directly used by the parsers.
193
+ */
194
+ XMLPUBFUN xmlCharEncoding
195
+ xmlDetectCharEncoding (const unsigned char *in,
196
+ int len);
197
+
198
+ struct _xmlBuffer;
199
+ XMLPUBFUN int
200
+ xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
201
+ struct _xmlBuffer *out,
202
+ struct _xmlBuffer *in);
203
+
204
+ XMLPUBFUN int
205
+ xmlCharEncInFunc (xmlCharEncodingHandler *handler,
206
+ struct _xmlBuffer *out,
207
+ struct _xmlBuffer *in);
208
+ XML_DEPRECATED
209
+ XMLPUBFUN int
210
+ xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
211
+ struct _xmlBuffer *out,
212
+ struct _xmlBuffer *in);
213
+ XMLPUBFUN int
214
+ xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
215
+
216
+ /*
217
+ * Export a few useful functions
218
+ */
219
+ #ifdef LIBXML_OUTPUT_ENABLED
220
+ XMLPUBFUN int
221
+ UTF8Toisolat1 (unsigned char *out,
222
+ int *outlen,
223
+ const unsigned char *in,
224
+ int *inlen);
225
+ #endif /* LIBXML_OUTPUT_ENABLED */
226
+ XMLPUBFUN int
227
+ isolat1ToUTF8 (unsigned char *out,
228
+ int *outlen,
229
+ const unsigned char *in,
230
+ int *inlen);
231
+ #ifdef __cplusplus
232
+ }
233
+ #endif
234
+
235
+ #endif /* __XML_CHAR_ENCODING_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/globals.h ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for all global variables of the library
3
+ * Description: Deprecated, don't use
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ */
7
+
8
+ #ifndef __XML_GLOBALS_H
9
+ #define __XML_GLOBALS_H
10
+
11
+ #include <libxml/xmlversion.h>
12
+
13
+ /*
14
+ * This file was required to access global variables until version v2.12.0.
15
+ *
16
+ * These includes are for backward compatibility.
17
+ */
18
+ #include <libxml/HTMLparser.h>
19
+ #include <libxml/parser.h>
20
+ #include <libxml/xmlerror.h>
21
+ #include <libxml/xmlIO.h>
22
+ #include <libxml/xmlsave.h>
23
+ #include <libxml/threads.h>
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ typedef struct _xmlGlobalState xmlGlobalState;
30
+ typedef xmlGlobalState *xmlGlobalStatePtr;
31
+
32
+ XML_DEPRECATED XMLPUBFUN void
33
+ xmlInitializeGlobalState(xmlGlobalStatePtr gs);
34
+ XML_DEPRECATED XMLPUBFUN
35
+ xmlGlobalStatePtr xmlGetGlobalState(void);
36
+
37
+ #ifdef __cplusplus
38
+ }
39
+ #endif
40
+
41
+ #endif /* __XML_GLOBALS_H */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/parser.h ADDED
@@ -0,0 +1,1384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: the core parser module
3
+ * Description: Interfaces, constants and types related to the XML parser
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Daniel Veillard
8
+ */
9
+
10
+ #ifndef __XML_PARSER_H__
11
+ #define __XML_PARSER_H__
12
+
13
+ #include <libxml/xmlversion.h>
14
+ #define XML_TREE_INTERNALS
15
+ #include <libxml/tree.h>
16
+ #undef XML_TREE_INTERNALS
17
+ #include <libxml/dict.h>
18
+ #include <libxml/hash.h>
19
+ #include <libxml/valid.h>
20
+ #include <libxml/entities.h>
21
+ #include <libxml/xmlerror.h>
22
+ #include <libxml/xmlstring.h>
23
+ #include <libxml/xmlmemory.h>
24
+ #include <libxml/encoding.h>
25
+ #include <libxml/xmlIO.h>
26
+ /* for compatibility */
27
+ #include <libxml/SAX2.h>
28
+ #include <libxml/threads.h>
29
+
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+
34
+ /**
35
+ * XML_DEFAULT_VERSION:
36
+ *
37
+ * The default version of XML used: 1.0
38
+ */
39
+ #define XML_DEFAULT_VERSION "1.0"
40
+
41
+ /**
42
+ * xmlParserInput:
43
+ *
44
+ * An xmlParserInput is an input flow for the XML processor.
45
+ * Each entity parsed is associated an xmlParserInput (except the
46
+ * few predefined ones). This is the case both for internal entities
47
+ * - in which case the flow is already completely in memory - or
48
+ * external entities - in which case we use the buf structure for
49
+ * progressive reading and I18N conversions to the internal UTF-8 format.
50
+ */
51
+
52
+ /**
53
+ * xmlParserInputDeallocate:
54
+ * @str: the string to deallocate
55
+ *
56
+ * Callback for freeing some parser input allocations.
57
+ */
58
+ typedef void (* xmlParserInputDeallocate)(xmlChar *str);
59
+
60
+ struct _xmlParserInput {
61
+ /* Input buffer */
62
+ xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
63
+
64
+ const char *filename; /* The file analyzed, if any */
65
+ const char *directory; /* the directory/base of the file */
66
+ const xmlChar *base; /* Base of the array to parse */
67
+ const xmlChar *cur; /* Current char being parsed */
68
+ const xmlChar *end; /* end of the array to parse */
69
+ int length; /* length if known */
70
+ int line; /* Current line */
71
+ int col; /* Current column */
72
+ unsigned long consumed; /* How many xmlChars already consumed */
73
+ xmlParserInputDeallocate free; /* function to deallocate the base */
74
+ const xmlChar *encoding; /* unused */
75
+ const xmlChar *version; /* the version string for entity */
76
+ int flags; /* Flags */
77
+ int id; /* an unique identifier for the entity */
78
+ unsigned long parentConsumed; /* consumed bytes from parents */
79
+ xmlEntityPtr entity; /* entity, if any */
80
+ };
81
+
82
+ /**
83
+ * xmlParserNodeInfo:
84
+ *
85
+ * The parser can be asked to collect Node information, i.e. at what
86
+ * place in the file they were detected.
87
+ * NOTE: This is off by default and not very well tested.
88
+ */
89
+ typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
90
+ typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
91
+
92
+ struct _xmlParserNodeInfo {
93
+ const struct _xmlNode* node;
94
+ /* Position & line # that text that created the node begins & ends on */
95
+ unsigned long begin_pos;
96
+ unsigned long begin_line;
97
+ unsigned long end_pos;
98
+ unsigned long end_line;
99
+ };
100
+
101
+ typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
102
+ typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
103
+ struct _xmlParserNodeInfoSeq {
104
+ unsigned long maximum;
105
+ unsigned long length;
106
+ xmlParserNodeInfo* buffer;
107
+ };
108
+
109
+ /**
110
+ * xmlParserInputState:
111
+ *
112
+ * The parser is now working also as a state based parser.
113
+ * The recursive one use the state info for entities processing.
114
+ */
115
+ typedef enum {
116
+ XML_PARSER_EOF = -1, /* nothing is to be parsed */
117
+ XML_PARSER_START = 0, /* nothing has been parsed */
118
+ XML_PARSER_MISC, /* Misc* before int subset */
119
+ XML_PARSER_PI, /* Within a processing instruction */
120
+ XML_PARSER_DTD, /* within some DTD content */
121
+ XML_PARSER_PROLOG, /* Misc* after internal subset */
122
+ XML_PARSER_COMMENT, /* within a comment */
123
+ XML_PARSER_START_TAG, /* within a start tag */
124
+ XML_PARSER_CONTENT, /* within the content */
125
+ XML_PARSER_CDATA_SECTION, /* within a CDATA section */
126
+ XML_PARSER_END_TAG, /* within a closing tag */
127
+ XML_PARSER_ENTITY_DECL, /* within an entity declaration */
128
+ XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
129
+ XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
130
+ XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
131
+ XML_PARSER_EPILOG, /* the Misc* after the last end tag */
132
+ XML_PARSER_IGNORE, /* within an IGNORED section */
133
+ XML_PARSER_PUBLIC_LITERAL, /* within a PUBLIC value */
134
+ XML_PARSER_XML_DECL /* before XML decl (but after BOM) */
135
+ } xmlParserInputState;
136
+
137
+ /**
138
+ * XML_DETECT_IDS:
139
+ *
140
+ * Bit in the loadsubset context field to tell to do ID/REFs lookups.
141
+ * Use it to initialize xmlLoadExtDtdDefaultValue.
142
+ */
143
+ #define XML_DETECT_IDS 2
144
+
145
+ /**
146
+ * XML_COMPLETE_ATTRS:
147
+ *
148
+ * Bit in the loadsubset context field to tell to do complete the
149
+ * elements attributes lists with the ones defaulted from the DTDs.
150
+ * Use it to initialize xmlLoadExtDtdDefaultValue.
151
+ */
152
+ #define XML_COMPLETE_ATTRS 4
153
+
154
+ /**
155
+ * XML_SKIP_IDS:
156
+ *
157
+ * Bit in the loadsubset context field to tell to not do ID/REFs registration.
158
+ * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
159
+ */
160
+ #define XML_SKIP_IDS 8
161
+
162
+ /**
163
+ * xmlParserMode:
164
+ *
165
+ * A parser can operate in various modes
166
+ */
167
+ typedef enum {
168
+ XML_PARSE_UNKNOWN = 0,
169
+ XML_PARSE_DOM = 1,
170
+ XML_PARSE_SAX = 2,
171
+ XML_PARSE_PUSH_DOM = 3,
172
+ XML_PARSE_PUSH_SAX = 4,
173
+ XML_PARSE_READER = 5
174
+ } xmlParserMode;
175
+
176
+ typedef struct _xmlStartTag xmlStartTag;
177
+ typedef struct _xmlParserNsData xmlParserNsData;
178
+ typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
179
+
180
+ /**
181
+ * xmlParserCtxt:
182
+ *
183
+ * The parser context.
184
+ * NOTE This doesn't completely define the parser state, the (current ?)
185
+ * design of the parser uses recursive function calls since this allow
186
+ * and easy mapping from the production rules of the specification
187
+ * to the actual code. The drawback is that the actual function call
188
+ * also reflect the parser state. However most of the parsing routines
189
+ * takes as the only argument the parser context pointer, so migrating
190
+ * to a state based parser for progressive parsing shouldn't be too hard.
191
+ */
192
+ struct _xmlParserCtxt {
193
+ struct _xmlSAXHandler *sax; /* The SAX handler */
194
+ void *userData; /* For SAX interface only, used by DOM build */
195
+ xmlDocPtr myDoc; /* the document being built */
196
+ int wellFormed; /* is the document well formed */
197
+ int replaceEntities; /* shall we replace entities ? */
198
+ const xmlChar *version; /* the XML version string */
199
+ const xmlChar *encoding; /* the declared encoding, if any */
200
+ int standalone; /* standalone document */
201
+ int html; /* an HTML(1) document
202
+ * 3 is HTML after <head>
203
+ * 10 is HTML after <body>
204
+ */
205
+
206
+ /* Input stream stack */
207
+ xmlParserInputPtr input; /* Current input stream */
208
+ int inputNr; /* Number of current input streams */
209
+ int inputMax; /* Max number of input streams */
210
+ xmlParserInputPtr *inputTab; /* stack of inputs */
211
+
212
+ /* Node analysis stack only used for DOM building */
213
+ xmlNodePtr node; /* Current parsed Node */
214
+ int nodeNr; /* Depth of the parsing stack */
215
+ int nodeMax; /* Max depth of the parsing stack */
216
+ xmlNodePtr *nodeTab; /* array of nodes */
217
+
218
+ int record_info; /* Whether node info should be kept */
219
+ xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
220
+
221
+ int errNo; /* error code */
222
+
223
+ int hasExternalSubset; /* reference and external subset */
224
+ int hasPErefs; /* the internal subset has PE refs */
225
+ int external; /* are we parsing an external entity */
226
+
227
+ int valid; /* is the document valid */
228
+ int validate; /* shall we try to validate ? */
229
+ xmlValidCtxt vctxt; /* The validity context */
230
+
231
+ xmlParserInputState instate; /* current type of input */
232
+ int token; /* next char look-ahead */
233
+
234
+ char *directory; /* the data directory */
235
+
236
+ /* Node name stack */
237
+ const xmlChar *name; /* Current parsed Node */
238
+ int nameNr; /* Depth of the parsing stack */
239
+ int nameMax; /* Max depth of the parsing stack */
240
+ const xmlChar * *nameTab; /* array of nodes */
241
+
242
+ long nbChars; /* unused */
243
+ long checkIndex; /* used by progressive parsing lookup */
244
+ int keepBlanks; /* ugly but ... */
245
+ int disableSAX; /* SAX callbacks are disabled */
246
+ int inSubset; /* Parsing is in int 1/ext 2 subset */
247
+ const xmlChar * intSubName; /* name of subset */
248
+ xmlChar * extSubURI; /* URI of external subset */
249
+ xmlChar * extSubSystem; /* SYSTEM ID of external subset */
250
+
251
+ /* xml:space values */
252
+ int * space; /* Should the parser preserve spaces */
253
+ int spaceNr; /* Depth of the parsing stack */
254
+ int spaceMax; /* Max depth of the parsing stack */
255
+ int * spaceTab; /* array of space infos */
256
+
257
+ int depth; /* to prevent entity substitution loops */
258
+ xmlParserInputPtr entity; /* used to check entities boundaries */
259
+ int charset; /* unused */
260
+ int nodelen; /* Those two fields are there to */
261
+ int nodemem; /* Speed up large node parsing */
262
+ int pedantic; /* signal pedantic warnings */
263
+ void *_private; /* For user data, libxml won't touch it */
264
+
265
+ int loadsubset; /* should the external subset be loaded */
266
+ int linenumbers; /* set line number in element content */
267
+ void *catalogs; /* document's own catalog */
268
+ int recovery; /* run in recovery mode */
269
+ int progressive; /* is this a progressive parsing */
270
+ xmlDictPtr dict; /* dictionary for the parser */
271
+ const xmlChar * *atts; /* array for the attributes callbacks */
272
+ int maxatts; /* the size of the array */
273
+ int docdict; /* use strings from dict to build tree */
274
+
275
+ /*
276
+ * pre-interned strings
277
+ */
278
+ const xmlChar *str_xml;
279
+ const xmlChar *str_xmlns;
280
+ const xmlChar *str_xml_ns;
281
+
282
+ /*
283
+ * Everything below is used only by the new SAX mode
284
+ */
285
+ int sax2; /* operating in the new SAX mode */
286
+ int nsNr; /* the number of inherited namespaces */
287
+ int nsMax; /* the size of the arrays */
288
+ const xmlChar * *nsTab; /* the array of prefix/namespace name */
289
+ unsigned *attallocs; /* which attribute were allocated */
290
+ xmlStartTag *pushTab; /* array of data for push */
291
+ xmlHashTablePtr attsDefault; /* defaulted attributes if any */
292
+ xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
293
+ int nsWellFormed; /* is the document XML Namespace okay */
294
+ int options; /* Extra options */
295
+
296
+ /*
297
+ * Those fields are needed only for streaming parsing so far
298
+ */
299
+ int dictNames; /* Use dictionary names for the tree */
300
+ int freeElemsNr; /* number of freed element nodes */
301
+ xmlNodePtr freeElems; /* List of freed element nodes */
302
+ int freeAttrsNr; /* number of freed attributes nodes */
303
+ xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
304
+
305
+ /*
306
+ * the complete error information for the last error.
307
+ */
308
+ xmlError lastError;
309
+ xmlParserMode parseMode; /* the parser mode */
310
+ unsigned long nbentities; /* unused */
311
+ unsigned long sizeentities; /* size of parsed entities */
312
+
313
+ /* for use by HTML non-recursive parser */
314
+ xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */
315
+ int nodeInfoNr; /* Depth of the parsing stack */
316
+ int nodeInfoMax; /* Max depth of the parsing stack */
317
+ xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */
318
+
319
+ int input_id; /* we need to label inputs */
320
+ unsigned long sizeentcopy; /* volume of entity copy */
321
+
322
+ int endCheckState; /* quote state for push parser */
323
+ unsigned short nbErrors; /* number of errors */
324
+ unsigned short nbWarnings; /* number of warnings */
325
+ unsigned maxAmpl; /* maximum amplification factor */
326
+
327
+ xmlParserNsData *nsdb; /* namespace database */
328
+ unsigned attrHashMax; /* allocated size */
329
+ xmlAttrHashBucket *attrHash; /* atttribute hash table */
330
+ };
331
+
332
+ /**
333
+ * xmlSAXLocator:
334
+ *
335
+ * A SAX Locator.
336
+ */
337
+ struct _xmlSAXLocator {
338
+ const xmlChar *(*getPublicId)(void *ctx);
339
+ const xmlChar *(*getSystemId)(void *ctx);
340
+ int (*getLineNumber)(void *ctx);
341
+ int (*getColumnNumber)(void *ctx);
342
+ };
343
+
344
+ /**
345
+ * xmlSAXHandler:
346
+ *
347
+ * A SAX handler is bunch of callbacks called by the parser when processing
348
+ * of the input generate data or structure information.
349
+ */
350
+
351
+ /**
352
+ * resolveEntitySAXFunc:
353
+ * @ctx: the user data (XML parser context)
354
+ * @publicId: The public ID of the entity
355
+ * @systemId: The system ID of the entity
356
+ *
357
+ * Callback:
358
+ * The entity loader, to control the loading of external entities,
359
+ * the application can either:
360
+ * - override this resolveEntity() callback in the SAX block
361
+ * - or better use the xmlSetExternalEntityLoader() function to
362
+ * set up it's own entity resolution routine
363
+ *
364
+ * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
365
+ */
366
+ typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
367
+ const xmlChar *publicId,
368
+ const xmlChar *systemId);
369
+ /**
370
+ * internalSubsetSAXFunc:
371
+ * @ctx: the user data (XML parser context)
372
+ * @name: the root element name
373
+ * @ExternalID: the external ID
374
+ * @SystemID: the SYSTEM ID (e.g. filename or URL)
375
+ *
376
+ * Callback on internal subset declaration.
377
+ */
378
+ typedef void (*internalSubsetSAXFunc) (void *ctx,
379
+ const xmlChar *name,
380
+ const xmlChar *ExternalID,
381
+ const xmlChar *SystemID);
382
+ /**
383
+ * externalSubsetSAXFunc:
384
+ * @ctx: the user data (XML parser context)
385
+ * @name: the root element name
386
+ * @ExternalID: the external ID
387
+ * @SystemID: the SYSTEM ID (e.g. filename or URL)
388
+ *
389
+ * Callback on external subset declaration.
390
+ */
391
+ typedef void (*externalSubsetSAXFunc) (void *ctx,
392
+ const xmlChar *name,
393
+ const xmlChar *ExternalID,
394
+ const xmlChar *SystemID);
395
+ /**
396
+ * getEntitySAXFunc:
397
+ * @ctx: the user data (XML parser context)
398
+ * @name: The entity name
399
+ *
400
+ * Get an entity by name.
401
+ *
402
+ * Returns the xmlEntityPtr if found.
403
+ */
404
+ typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
405
+ const xmlChar *name);
406
+ /**
407
+ * getParameterEntitySAXFunc:
408
+ * @ctx: the user data (XML parser context)
409
+ * @name: The entity name
410
+ *
411
+ * Get a parameter entity by name.
412
+ *
413
+ * Returns the xmlEntityPtr if found.
414
+ */
415
+ typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
416
+ const xmlChar *name);
417
+ /**
418
+ * entityDeclSAXFunc:
419
+ * @ctx: the user data (XML parser context)
420
+ * @name: the entity name
421
+ * @type: the entity type
422
+ * @publicId: The public ID of the entity
423
+ * @systemId: The system ID of the entity
424
+ * @content: the entity value (without processing).
425
+ *
426
+ * An entity definition has been parsed.
427
+ */
428
+ typedef void (*entityDeclSAXFunc) (void *ctx,
429
+ const xmlChar *name,
430
+ int type,
431
+ const xmlChar *publicId,
432
+ const xmlChar *systemId,
433
+ xmlChar *content);
434
+ /**
435
+ * notationDeclSAXFunc:
436
+ * @ctx: the user data (XML parser context)
437
+ * @name: The name of the notation
438
+ * @publicId: The public ID of the entity
439
+ * @systemId: The system ID of the entity
440
+ *
441
+ * What to do when a notation declaration has been parsed.
442
+ */
443
+ typedef void (*notationDeclSAXFunc)(void *ctx,
444
+ const xmlChar *name,
445
+ const xmlChar *publicId,
446
+ const xmlChar *systemId);
447
+ /**
448
+ * attributeDeclSAXFunc:
449
+ * @ctx: the user data (XML parser context)
450
+ * @elem: the name of the element
451
+ * @fullname: the attribute name
452
+ * @type: the attribute type
453
+ * @def: the type of default value
454
+ * @defaultValue: the attribute default value
455
+ * @tree: the tree of enumerated value set
456
+ *
457
+ * An attribute definition has been parsed.
458
+ */
459
+ typedef void (*attributeDeclSAXFunc)(void *ctx,
460
+ const xmlChar *elem,
461
+ const xmlChar *fullname,
462
+ int type,
463
+ int def,
464
+ const xmlChar *defaultValue,
465
+ xmlEnumerationPtr tree);
466
+ /**
467
+ * elementDeclSAXFunc:
468
+ * @ctx: the user data (XML parser context)
469
+ * @name: the element name
470
+ * @type: the element type
471
+ * @content: the element value tree
472
+ *
473
+ * An element definition has been parsed.
474
+ */
475
+ typedef void (*elementDeclSAXFunc)(void *ctx,
476
+ const xmlChar *name,
477
+ int type,
478
+ xmlElementContentPtr content);
479
+ /**
480
+ * unparsedEntityDeclSAXFunc:
481
+ * @ctx: the user data (XML parser context)
482
+ * @name: The name of the entity
483
+ * @publicId: The public ID of the entity
484
+ * @systemId: The system ID of the entity
485
+ * @notationName: the name of the notation
486
+ *
487
+ * What to do when an unparsed entity declaration is parsed.
488
+ */
489
+ typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
490
+ const xmlChar *name,
491
+ const xmlChar *publicId,
492
+ const xmlChar *systemId,
493
+ const xmlChar *notationName);
494
+ /**
495
+ * setDocumentLocatorSAXFunc:
496
+ * @ctx: the user data (XML parser context)
497
+ * @loc: A SAX Locator
498
+ *
499
+ * Receive the document locator at startup, actually xmlDefaultSAXLocator.
500
+ * Everything is available on the context, so this is useless in our case.
501
+ */
502
+ typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
503
+ xmlSAXLocatorPtr loc);
504
+ /**
505
+ * startDocumentSAXFunc:
506
+ * @ctx: the user data (XML parser context)
507
+ *
508
+ * Called when the document start being processed.
509
+ */
510
+ typedef void (*startDocumentSAXFunc) (void *ctx);
511
+ /**
512
+ * endDocumentSAXFunc:
513
+ * @ctx: the user data (XML parser context)
514
+ *
515
+ * Called when the document end has been detected.
516
+ */
517
+ typedef void (*endDocumentSAXFunc) (void *ctx);
518
+ /**
519
+ * startElementSAXFunc:
520
+ * @ctx: the user data (XML parser context)
521
+ * @name: The element name, including namespace prefix
522
+ * @atts: An array of name/value attributes pairs, NULL terminated
523
+ *
524
+ * Called when an opening tag has been processed.
525
+ */
526
+ typedef void (*startElementSAXFunc) (void *ctx,
527
+ const xmlChar *name,
528
+ const xmlChar **atts);
529
+ /**
530
+ * endElementSAXFunc:
531
+ * @ctx: the user data (XML parser context)
532
+ * @name: The element name
533
+ *
534
+ * Called when the end of an element has been detected.
535
+ */
536
+ typedef void (*endElementSAXFunc) (void *ctx,
537
+ const xmlChar *name);
538
+ /**
539
+ * attributeSAXFunc:
540
+ * @ctx: the user data (XML parser context)
541
+ * @name: The attribute name, including namespace prefix
542
+ * @value: The attribute value
543
+ *
544
+ * Handle an attribute that has been read by the parser.
545
+ * The default handling is to convert the attribute into an
546
+ * DOM subtree and past it in a new xmlAttr element added to
547
+ * the element.
548
+ */
549
+ typedef void (*attributeSAXFunc) (void *ctx,
550
+ const xmlChar *name,
551
+ const xmlChar *value);
552
+ /**
553
+ * referenceSAXFunc:
554
+ * @ctx: the user data (XML parser context)
555
+ * @name: The entity name
556
+ *
557
+ * Called when an entity reference is detected.
558
+ */
559
+ typedef void (*referenceSAXFunc) (void *ctx,
560
+ const xmlChar *name);
561
+ /**
562
+ * charactersSAXFunc:
563
+ * @ctx: the user data (XML parser context)
564
+ * @ch: a xmlChar string
565
+ * @len: the number of xmlChar
566
+ *
567
+ * Receiving some chars from the parser.
568
+ */
569
+ typedef void (*charactersSAXFunc) (void *ctx,
570
+ const xmlChar *ch,
571
+ int len);
572
+ /**
573
+ * ignorableWhitespaceSAXFunc:
574
+ * @ctx: the user data (XML parser context)
575
+ * @ch: a xmlChar string
576
+ * @len: the number of xmlChar
577
+ *
578
+ * Receiving some ignorable whitespaces from the parser.
579
+ * UNUSED: by default the DOM building will use characters.
580
+ */
581
+ typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
582
+ const xmlChar *ch,
583
+ int len);
584
+ /**
585
+ * processingInstructionSAXFunc:
586
+ * @ctx: the user data (XML parser context)
587
+ * @target: the target name
588
+ * @data: the PI data's
589
+ *
590
+ * A processing instruction has been parsed.
591
+ */
592
+ typedef void (*processingInstructionSAXFunc) (void *ctx,
593
+ const xmlChar *target,
594
+ const xmlChar *data);
595
+ /**
596
+ * commentSAXFunc:
597
+ * @ctx: the user data (XML parser context)
598
+ * @value: the comment content
599
+ *
600
+ * A comment has been parsed.
601
+ */
602
+ typedef void (*commentSAXFunc) (void *ctx,
603
+ const xmlChar *value);
604
+ /**
605
+ * cdataBlockSAXFunc:
606
+ * @ctx: the user data (XML parser context)
607
+ * @value: The pcdata content
608
+ * @len: the block length
609
+ *
610
+ * Called when a pcdata block has been parsed.
611
+ */
612
+ typedef void (*cdataBlockSAXFunc) (
613
+ void *ctx,
614
+ const xmlChar *value,
615
+ int len);
616
+ /**
617
+ * warningSAXFunc:
618
+ * @ctx: an XML parser context
619
+ * @msg: the message to display/transmit
620
+ * @...: extra parameters for the message display
621
+ *
622
+ * Display and format a warning messages, callback.
623
+ */
624
+ typedef void (*warningSAXFunc) (void *ctx,
625
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
626
+ /**
627
+ * errorSAXFunc:
628
+ * @ctx: an XML parser context
629
+ * @msg: the message to display/transmit
630
+ * @...: extra parameters for the message display
631
+ *
632
+ * Display and format an error messages, callback.
633
+ */
634
+ typedef void (*errorSAXFunc) (void *ctx,
635
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
636
+ /**
637
+ * fatalErrorSAXFunc:
638
+ * @ctx: an XML parser context
639
+ * @msg: the message to display/transmit
640
+ * @...: extra parameters for the message display
641
+ *
642
+ * Display and format fatal error messages, callback.
643
+ * Note: so far fatalError() SAX callbacks are not used, error()
644
+ * get all the callbacks for errors.
645
+ */
646
+ typedef void (*fatalErrorSAXFunc) (void *ctx,
647
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
648
+ /**
649
+ * isStandaloneSAXFunc:
650
+ * @ctx: the user data (XML parser context)
651
+ *
652
+ * Is this document tagged standalone?
653
+ *
654
+ * Returns 1 if true
655
+ */
656
+ typedef int (*isStandaloneSAXFunc) (void *ctx);
657
+ /**
658
+ * hasInternalSubsetSAXFunc:
659
+ * @ctx: the user data (XML parser context)
660
+ *
661
+ * Does this document has an internal subset.
662
+ *
663
+ * Returns 1 if true
664
+ */
665
+ typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
666
+
667
+ /**
668
+ * hasExternalSubsetSAXFunc:
669
+ * @ctx: the user data (XML parser context)
670
+ *
671
+ * Does this document has an external subset?
672
+ *
673
+ * Returns 1 if true
674
+ */
675
+ typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
676
+
677
+ /************************************************************************
678
+ * *
679
+ * The SAX version 2 API extensions *
680
+ * *
681
+ ************************************************************************/
682
+ /**
683
+ * XML_SAX2_MAGIC:
684
+ *
685
+ * Special constant found in SAX2 blocks initialized fields
686
+ */
687
+ #define XML_SAX2_MAGIC 0xDEEDBEAF
688
+
689
+ /**
690
+ * startElementNsSAX2Func:
691
+ * @ctx: the user data (XML parser context)
692
+ * @localname: the local name of the element
693
+ * @prefix: the element namespace prefix if available
694
+ * @URI: the element namespace name if available
695
+ * @nb_namespaces: number of namespace definitions on that node
696
+ * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
697
+ * @nb_attributes: the number of attributes on that node
698
+ * @nb_defaulted: the number of defaulted attributes. The defaulted
699
+ * ones are at the end of the array
700
+ * @attributes: pointer to the array of (localname/prefix/URI/value/end)
701
+ * attribute values.
702
+ *
703
+ * SAX2 callback when an element start has been detected by the parser.
704
+ * It provides the namespace information for the element, as well as
705
+ * the new namespace declarations on the element.
706
+ */
707
+
708
+ typedef void (*startElementNsSAX2Func) (void *ctx,
709
+ const xmlChar *localname,
710
+ const xmlChar *prefix,
711
+ const xmlChar *URI,
712
+ int nb_namespaces,
713
+ const xmlChar **namespaces,
714
+ int nb_attributes,
715
+ int nb_defaulted,
716
+ const xmlChar **attributes);
717
+
718
+ /**
719
+ * endElementNsSAX2Func:
720
+ * @ctx: the user data (XML parser context)
721
+ * @localname: the local name of the element
722
+ * @prefix: the element namespace prefix if available
723
+ * @URI: the element namespace name if available
724
+ *
725
+ * SAX2 callback when an element end has been detected by the parser.
726
+ * It provides the namespace information for the element.
727
+ */
728
+
729
+ typedef void (*endElementNsSAX2Func) (void *ctx,
730
+ const xmlChar *localname,
731
+ const xmlChar *prefix,
732
+ const xmlChar *URI);
733
+
734
+
735
+ struct _xmlSAXHandler {
736
+ internalSubsetSAXFunc internalSubset;
737
+ isStandaloneSAXFunc isStandalone;
738
+ hasInternalSubsetSAXFunc hasInternalSubset;
739
+ hasExternalSubsetSAXFunc hasExternalSubset;
740
+ resolveEntitySAXFunc resolveEntity;
741
+ getEntitySAXFunc getEntity;
742
+ entityDeclSAXFunc entityDecl;
743
+ notationDeclSAXFunc notationDecl;
744
+ attributeDeclSAXFunc attributeDecl;
745
+ elementDeclSAXFunc elementDecl;
746
+ unparsedEntityDeclSAXFunc unparsedEntityDecl;
747
+ setDocumentLocatorSAXFunc setDocumentLocator;
748
+ startDocumentSAXFunc startDocument;
749
+ endDocumentSAXFunc endDocument;
750
+ /*
751
+ * `startElement` and `endElement` are only used by the legacy SAX1
752
+ * interface and should not be used in new software. If you really
753
+ * have to enable SAX1, the preferred way is set the `initialized`
754
+ * member to 1 instead of XML_SAX2_MAGIC.
755
+ *
756
+ * For backward compatibility, it's also possible to set the
757
+ * `startElementNs` and `endElementNs` handlers to NULL.
758
+ *
759
+ * You can also set the XML_PARSE_SAX1 parser option, but versions
760
+ * older than 2.12.0 will probably crash if this option is provided
761
+ * together with custom SAX callbacks.
762
+ */
763
+ startElementSAXFunc startElement;
764
+ endElementSAXFunc endElement;
765
+ referenceSAXFunc reference;
766
+ charactersSAXFunc characters;
767
+ ignorableWhitespaceSAXFunc ignorableWhitespace;
768
+ processingInstructionSAXFunc processingInstruction;
769
+ commentSAXFunc comment;
770
+ warningSAXFunc warning;
771
+ errorSAXFunc error;
772
+ fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
773
+ getParameterEntitySAXFunc getParameterEntity;
774
+ cdataBlockSAXFunc cdataBlock;
775
+ externalSubsetSAXFunc externalSubset;
776
+ /*
777
+ * `initialized` should always be set to XML_SAX2_MAGIC to enable the
778
+ * modern SAX2 interface.
779
+ */
780
+ unsigned int initialized;
781
+ /*
782
+ * The following members are only used by the SAX2 interface.
783
+ */
784
+ void *_private;
785
+ startElementNsSAX2Func startElementNs;
786
+ endElementNsSAX2Func endElementNs;
787
+ xmlStructuredErrorFunc serror;
788
+ };
789
+
790
+ /*
791
+ * SAX Version 1
792
+ */
793
+ typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
794
+ typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
795
+ struct _xmlSAXHandlerV1 {
796
+ internalSubsetSAXFunc internalSubset;
797
+ isStandaloneSAXFunc isStandalone;
798
+ hasInternalSubsetSAXFunc hasInternalSubset;
799
+ hasExternalSubsetSAXFunc hasExternalSubset;
800
+ resolveEntitySAXFunc resolveEntity;
801
+ getEntitySAXFunc getEntity;
802
+ entityDeclSAXFunc entityDecl;
803
+ notationDeclSAXFunc notationDecl;
804
+ attributeDeclSAXFunc attributeDecl;
805
+ elementDeclSAXFunc elementDecl;
806
+ unparsedEntityDeclSAXFunc unparsedEntityDecl;
807
+ setDocumentLocatorSAXFunc setDocumentLocator;
808
+ startDocumentSAXFunc startDocument;
809
+ endDocumentSAXFunc endDocument;
810
+ startElementSAXFunc startElement;
811
+ endElementSAXFunc endElement;
812
+ referenceSAXFunc reference;
813
+ charactersSAXFunc characters;
814
+ ignorableWhitespaceSAXFunc ignorableWhitespace;
815
+ processingInstructionSAXFunc processingInstruction;
816
+ commentSAXFunc comment;
817
+ warningSAXFunc warning;
818
+ errorSAXFunc error;
819
+ fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
820
+ getParameterEntitySAXFunc getParameterEntity;
821
+ cdataBlockSAXFunc cdataBlock;
822
+ externalSubsetSAXFunc externalSubset;
823
+ unsigned int initialized;
824
+ };
825
+
826
+
827
+ /**
828
+ * xmlExternalEntityLoader:
829
+ * @URL: The System ID of the resource requested
830
+ * @ID: The Public ID of the resource requested
831
+ * @context: the XML parser context
832
+ *
833
+ * External entity loaders types.
834
+ *
835
+ * Returns the entity input parser.
836
+ */
837
+ typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
838
+ const char *ID,
839
+ xmlParserCtxtPtr context);
840
+
841
+ /*
842
+ * Variables
843
+ */
844
+
845
+ XMLPUBVAR const char *const xmlParserVersion;
846
+ #ifdef LIBXML_THREAD_ENABLED
847
+ /* backward compatibility */
848
+ XMLPUBFUN const char *const *__xmlParserVersion(void);
849
+ #endif
850
+
851
+ /** DOC_DISABLE */
852
+ #define XML_GLOBALS_PARSER_CORE \
853
+ XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
854
+ XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
855
+ XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
856
+ XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
857
+ XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
858
+ XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
859
+ XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
860
+ XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
861
+ XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
862
+ XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
863
+
864
+ #ifdef LIBXML_OUTPUT_ENABLED
865
+ #define XML_GLOBALS_PARSER_OUTPUT \
866
+ XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \
867
+ XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \
868
+ XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)
869
+ #else
870
+ #define XML_GLOBALS_PARSER_OUTPUT
871
+ #endif
872
+
873
+ #ifdef LIBXML_SAX1_ENABLED
874
+ #define XML_GLOBALS_PARSER_SAX1 \
875
+ XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
876
+ #else
877
+ #define XML_GLOBALS_PARSER_SAX1
878
+ #endif
879
+
880
+ #define XML_GLOBALS_PARSER \
881
+ XML_GLOBALS_PARSER_CORE \
882
+ XML_GLOBALS_PARSER_OUTPUT \
883
+ XML_GLOBALS_PARSER_SAX1
884
+
885
+ #define XML_OP XML_DECLARE_GLOBAL
886
+ XML_GLOBALS_PARSER
887
+ #undef XML_OP
888
+
889
+ #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
890
+ #define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)
891
+ #define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler)
892
+ #define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator)
893
+ #define xmlDoValidityCheckingDefaultValue \
894
+ XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
895
+ #define xmlGetWarningsDefaultValue \
896
+ XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
897
+ #define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
898
+ #define xmlLineNumbersDefaultValue \
899
+ XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
900
+ #define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
901
+ #define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)
902
+ #define xmlPedanticParserDefaultValue \
903
+ XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
904
+ #define xmlSubstituteEntitiesDefaultValue \
905
+ XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
906
+ #ifdef LIBXML_OUTPUT_ENABLED
907
+ #define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
908
+ #define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
909
+ #define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
910
+ #endif
911
+ #endif
912
+ /** DOC_ENABLE */
913
+
914
+ /*
915
+ * Init/Cleanup
916
+ */
917
+ XMLPUBFUN void
918
+ xmlInitParser (void);
919
+ XMLPUBFUN void
920
+ xmlCleanupParser (void);
921
+ XML_DEPRECATED
922
+ XMLPUBFUN void
923
+ xmlInitGlobals (void);
924
+ XML_DEPRECATED
925
+ XMLPUBFUN void
926
+ xmlCleanupGlobals (void);
927
+
928
+ /*
929
+ * Input functions
930
+ */
931
+ XML_DEPRECATED
932
+ XMLPUBFUN int
933
+ xmlParserInputRead (xmlParserInputPtr in,
934
+ int len);
935
+ XML_DEPRECATED
936
+ XMLPUBFUN int
937
+ xmlParserInputGrow (xmlParserInputPtr in,
938
+ int len);
939
+
940
+ /*
941
+ * Basic parsing Interfaces
942
+ */
943
+ #ifdef LIBXML_SAX1_ENABLED
944
+ XMLPUBFUN xmlDocPtr
945
+ xmlParseDoc (const xmlChar *cur);
946
+ XMLPUBFUN xmlDocPtr
947
+ xmlParseFile (const char *filename);
948
+ XMLPUBFUN xmlDocPtr
949
+ xmlParseMemory (const char *buffer,
950
+ int size);
951
+ #endif /* LIBXML_SAX1_ENABLED */
952
+ XML_DEPRECATED XMLPUBFUN int
953
+ xmlSubstituteEntitiesDefault(int val);
954
+ XML_DEPRECATED XMLPUBFUN int
955
+ xmlThrDefSubstituteEntitiesDefaultValue(int v);
956
+ XML_DEPRECATED XMLPUBFUN int
957
+ xmlKeepBlanksDefault (int val);
958
+ XML_DEPRECATED XMLPUBFUN int
959
+ xmlThrDefKeepBlanksDefaultValue(int v);
960
+ XMLPUBFUN void
961
+ xmlStopParser (xmlParserCtxtPtr ctxt);
962
+ XML_DEPRECATED XMLPUBFUN int
963
+ xmlPedanticParserDefault(int val);
964
+ XML_DEPRECATED XMLPUBFUN int
965
+ xmlThrDefPedanticParserDefaultValue(int v);
966
+ XML_DEPRECATED XMLPUBFUN int
967
+ xmlLineNumbersDefault (int val);
968
+ XML_DEPRECATED XMLPUBFUN int
969
+ xmlThrDefLineNumbersDefaultValue(int v);
970
+ XML_DEPRECATED XMLPUBFUN int
971
+ xmlThrDefDoValidityCheckingDefaultValue(int v);
972
+ XML_DEPRECATED XMLPUBFUN int
973
+ xmlThrDefGetWarningsDefaultValue(int v);
974
+ XML_DEPRECATED XMLPUBFUN int
975
+ xmlThrDefLoadExtDtdDefaultValue(int v);
976
+ XML_DEPRECATED XMLPUBFUN int
977
+ xmlThrDefParserDebugEntities(int v);
978
+
979
+ #ifdef LIBXML_SAX1_ENABLED
980
+ /*
981
+ * Recovery mode
982
+ */
983
+ XML_DEPRECATED
984
+ XMLPUBFUN xmlDocPtr
985
+ xmlRecoverDoc (const xmlChar *cur);
986
+ XML_DEPRECATED
987
+ XMLPUBFUN xmlDocPtr
988
+ xmlRecoverMemory (const char *buffer,
989
+ int size);
990
+ XML_DEPRECATED
991
+ XMLPUBFUN xmlDocPtr
992
+ xmlRecoverFile (const char *filename);
993
+ #endif /* LIBXML_SAX1_ENABLED */
994
+
995
+ /*
996
+ * Less common routines and SAX interfaces
997
+ */
998
+ XMLPUBFUN int
999
+ xmlParseDocument (xmlParserCtxtPtr ctxt);
1000
+ XMLPUBFUN int
1001
+ xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
1002
+ #ifdef LIBXML_SAX1_ENABLED
1003
+ XML_DEPRECATED
1004
+ XMLPUBFUN int
1005
+ xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
1006
+ void *user_data,
1007
+ const char *filename);
1008
+ XML_DEPRECATED
1009
+ XMLPUBFUN int
1010
+ xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
1011
+ void *user_data,
1012
+ const char *buffer,
1013
+ int size);
1014
+ XML_DEPRECATED
1015
+ XMLPUBFUN xmlDocPtr
1016
+ xmlSAXParseDoc (xmlSAXHandlerPtr sax,
1017
+ const xmlChar *cur,
1018
+ int recovery);
1019
+ XML_DEPRECATED
1020
+ XMLPUBFUN xmlDocPtr
1021
+ xmlSAXParseMemory (xmlSAXHandlerPtr sax,
1022
+ const char *buffer,
1023
+ int size,
1024
+ int recovery);
1025
+ XML_DEPRECATED
1026
+ XMLPUBFUN xmlDocPtr
1027
+ xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
1028
+ const char *buffer,
1029
+ int size,
1030
+ int recovery,
1031
+ void *data);
1032
+ XML_DEPRECATED
1033
+ XMLPUBFUN xmlDocPtr
1034
+ xmlSAXParseFile (xmlSAXHandlerPtr sax,
1035
+ const char *filename,
1036
+ int recovery);
1037
+ XML_DEPRECATED
1038
+ XMLPUBFUN xmlDocPtr
1039
+ xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
1040
+ const char *filename,
1041
+ int recovery,
1042
+ void *data);
1043
+ XML_DEPRECATED
1044
+ XMLPUBFUN xmlDocPtr
1045
+ xmlSAXParseEntity (xmlSAXHandlerPtr sax,
1046
+ const char *filename);
1047
+ XML_DEPRECATED
1048
+ XMLPUBFUN xmlDocPtr
1049
+ xmlParseEntity (const char *filename);
1050
+ #endif /* LIBXML_SAX1_ENABLED */
1051
+
1052
+ #ifdef LIBXML_VALID_ENABLED
1053
+ XML_DEPRECATED
1054
+ XMLPUBFUN xmlDtdPtr
1055
+ xmlSAXParseDTD (xmlSAXHandlerPtr sax,
1056
+ const xmlChar *ExternalID,
1057
+ const xmlChar *SystemID);
1058
+ XMLPUBFUN xmlDtdPtr
1059
+ xmlParseDTD (const xmlChar *ExternalID,
1060
+ const xmlChar *SystemID);
1061
+ XMLPUBFUN xmlDtdPtr
1062
+ xmlIOParseDTD (xmlSAXHandlerPtr sax,
1063
+ xmlParserInputBufferPtr input,
1064
+ xmlCharEncoding enc);
1065
+ #endif /* LIBXML_VALID_ENABLE */
1066
+ #ifdef LIBXML_SAX1_ENABLED
1067
+ XMLPUBFUN int
1068
+ xmlParseBalancedChunkMemory(xmlDocPtr doc,
1069
+ xmlSAXHandlerPtr sax,
1070
+ void *user_data,
1071
+ int depth,
1072
+ const xmlChar *string,
1073
+ xmlNodePtr *lst);
1074
+ #endif /* LIBXML_SAX1_ENABLED */
1075
+ XMLPUBFUN xmlParserErrors
1076
+ xmlParseInNodeContext (xmlNodePtr node,
1077
+ const char *data,
1078
+ int datalen,
1079
+ int options,
1080
+ xmlNodePtr *lst);
1081
+ #ifdef LIBXML_SAX1_ENABLED
1082
+ XMLPUBFUN int
1083
+ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
1084
+ xmlSAXHandlerPtr sax,
1085
+ void *user_data,
1086
+ int depth,
1087
+ const xmlChar *string,
1088
+ xmlNodePtr *lst,
1089
+ int recover);
1090
+ XML_DEPRECATED
1091
+ XMLPUBFUN int
1092
+ xmlParseExternalEntity (xmlDocPtr doc,
1093
+ xmlSAXHandlerPtr sax,
1094
+ void *user_data,
1095
+ int depth,
1096
+ const xmlChar *URL,
1097
+ const xmlChar *ID,
1098
+ xmlNodePtr *lst);
1099
+ #endif /* LIBXML_SAX1_ENABLED */
1100
+ XMLPUBFUN int
1101
+ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
1102
+ const xmlChar *URL,
1103
+ const xmlChar *ID,
1104
+ xmlNodePtr *lst);
1105
+
1106
+ /*
1107
+ * Parser contexts handling.
1108
+ */
1109
+ XMLPUBFUN xmlParserCtxtPtr
1110
+ xmlNewParserCtxt (void);
1111
+ XMLPUBFUN xmlParserCtxtPtr
1112
+ xmlNewSAXParserCtxt (const xmlSAXHandler *sax,
1113
+ void *userData);
1114
+ XMLPUBFUN int
1115
+ xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
1116
+ XMLPUBFUN void
1117
+ xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
1118
+ XMLPUBFUN void
1119
+ xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
1120
+ #ifdef LIBXML_SAX1_ENABLED
1121
+ XML_DEPRECATED
1122
+ XMLPUBFUN void
1123
+ xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
1124
+ const xmlChar* buffer,
1125
+ const char *filename);
1126
+ #endif /* LIBXML_SAX1_ENABLED */
1127
+ XMLPUBFUN xmlParserCtxtPtr
1128
+ xmlCreateDocParserCtxt (const xmlChar *cur);
1129
+
1130
+ #ifdef LIBXML_LEGACY_ENABLED
1131
+ /*
1132
+ * Reading/setting optional parsing features.
1133
+ */
1134
+ XML_DEPRECATED
1135
+ XMLPUBFUN int
1136
+ xmlGetFeaturesList (int *len,
1137
+ const char **result);
1138
+ XML_DEPRECATED
1139
+ XMLPUBFUN int
1140
+ xmlGetFeature (xmlParserCtxtPtr ctxt,
1141
+ const char *name,
1142
+ void *result);
1143
+ XML_DEPRECATED
1144
+ XMLPUBFUN int
1145
+ xmlSetFeature (xmlParserCtxtPtr ctxt,
1146
+ const char *name,
1147
+ void *value);
1148
+ #endif /* LIBXML_LEGACY_ENABLED */
1149
+
1150
+ #ifdef LIBXML_PUSH_ENABLED
1151
+ /*
1152
+ * Interfaces for the Push mode.
1153
+ */
1154
+ XMLPUBFUN xmlParserCtxtPtr
1155
+ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1156
+ void *user_data,
1157
+ const char *chunk,
1158
+ int size,
1159
+ const char *filename);
1160
+ XMLPUBFUN int
1161
+ xmlParseChunk (xmlParserCtxtPtr ctxt,
1162
+ const char *chunk,
1163
+ int size,
1164
+ int terminate);
1165
+ #endif /* LIBXML_PUSH_ENABLED */
1166
+
1167
+ /*
1168
+ * Special I/O mode.
1169
+ */
1170
+
1171
+ XMLPUBFUN xmlParserCtxtPtr
1172
+ xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
1173
+ void *user_data,
1174
+ xmlInputReadCallback ioread,
1175
+ xmlInputCloseCallback ioclose,
1176
+ void *ioctx,
1177
+ xmlCharEncoding enc);
1178
+
1179
+ XMLPUBFUN xmlParserInputPtr
1180
+ xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
1181
+ xmlParserInputBufferPtr input,
1182
+ xmlCharEncoding enc);
1183
+
1184
+ /*
1185
+ * Node infos.
1186
+ */
1187
+ XMLPUBFUN const xmlParserNodeInfo*
1188
+ xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1189
+ const xmlNodePtr node);
1190
+ XMLPUBFUN void
1191
+ xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1192
+ XMLPUBFUN void
1193
+ xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1194
+ XMLPUBFUN unsigned long
1195
+ xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
1196
+ const xmlNodePtr node);
1197
+ XMLPUBFUN void
1198
+ xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
1199
+ const xmlParserNodeInfoPtr info);
1200
+
1201
+ /*
1202
+ * External entities handling actually implemented in xmlIO.
1203
+ */
1204
+
1205
+ XMLPUBFUN void
1206
+ xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1207
+ XMLPUBFUN xmlExternalEntityLoader
1208
+ xmlGetExternalEntityLoader(void);
1209
+ XMLPUBFUN xmlParserInputPtr
1210
+ xmlLoadExternalEntity (const char *URL,
1211
+ const char *ID,
1212
+ xmlParserCtxtPtr ctxt);
1213
+
1214
+ /*
1215
+ * Index lookup, actually implemented in the encoding module
1216
+ */
1217
+ XMLPUBFUN long
1218
+ xmlByteConsumed (xmlParserCtxtPtr ctxt);
1219
+
1220
+ /*
1221
+ * New set of simpler/more flexible APIs
1222
+ */
1223
+ /**
1224
+ * xmlParserOption:
1225
+ *
1226
+ * This is the set of XML parser options that can be passed down
1227
+ * to the xmlReadDoc() and similar calls.
1228
+ */
1229
+ typedef enum {
1230
+ XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1231
+ XML_PARSE_NOENT = 1<<1, /* substitute entities */
1232
+ XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1233
+ XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1234
+ XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1235
+ XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1236
+ XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1237
+ XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1238
+ XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1239
+ XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1240
+ XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */
1241
+ XML_PARSE_NONET = 1<<11,/* Forbid network access */
1242
+ XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */
1243
+ XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1244
+ XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
1245
+ XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
1246
+ XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of
1247
+ the tree allowed afterwards (will possibly
1248
+ crash if you try to modify the tree) */
1249
+ XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
1250
+ XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
1251
+ XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */
1252
+ XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */
1253
+ XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
1254
+ XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
1255
+ } xmlParserOption;
1256
+
1257
+ XMLPUBFUN void
1258
+ xmlCtxtReset (xmlParserCtxtPtr ctxt);
1259
+ XMLPUBFUN int
1260
+ xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1261
+ const char *chunk,
1262
+ int size,
1263
+ const char *filename,
1264
+ const char *encoding);
1265
+ XMLPUBFUN int
1266
+ xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1267
+ int options);
1268
+ XMLPUBFUN void
1269
+ xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
1270
+ unsigned maxAmpl);
1271
+ XMLPUBFUN xmlDocPtr
1272
+ xmlReadDoc (const xmlChar *cur,
1273
+ const char *URL,
1274
+ const char *encoding,
1275
+ int options);
1276
+ XMLPUBFUN xmlDocPtr
1277
+ xmlReadFile (const char *URL,
1278
+ const char *encoding,
1279
+ int options);
1280
+ XMLPUBFUN xmlDocPtr
1281
+ xmlReadMemory (const char *buffer,
1282
+ int size,
1283
+ const char *URL,
1284
+ const char *encoding,
1285
+ int options);
1286
+ XMLPUBFUN xmlDocPtr
1287
+ xmlReadFd (int fd,
1288
+ const char *URL,
1289
+ const char *encoding,
1290
+ int options);
1291
+ XMLPUBFUN xmlDocPtr
1292
+ xmlReadIO (xmlInputReadCallback ioread,
1293
+ xmlInputCloseCallback ioclose,
1294
+ void *ioctx,
1295
+ const char *URL,
1296
+ const char *encoding,
1297
+ int options);
1298
+ XMLPUBFUN xmlDocPtr
1299
+ xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1300
+ const xmlChar *cur,
1301
+ const char *URL,
1302
+ const char *encoding,
1303
+ int options);
1304
+ XMLPUBFUN xmlDocPtr
1305
+ xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1306
+ const char *filename,
1307
+ const char *encoding,
1308
+ int options);
1309
+ XMLPUBFUN xmlDocPtr
1310
+ xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1311
+ const char *buffer,
1312
+ int size,
1313
+ const char *URL,
1314
+ const char *encoding,
1315
+ int options);
1316
+ XMLPUBFUN xmlDocPtr
1317
+ xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1318
+ int fd,
1319
+ const char *URL,
1320
+ const char *encoding,
1321
+ int options);
1322
+ XMLPUBFUN xmlDocPtr
1323
+ xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1324
+ xmlInputReadCallback ioread,
1325
+ xmlInputCloseCallback ioclose,
1326
+ void *ioctx,
1327
+ const char *URL,
1328
+ const char *encoding,
1329
+ int options);
1330
+
1331
+ /*
1332
+ * Library wide options
1333
+ */
1334
+ /**
1335
+ * xmlFeature:
1336
+ *
1337
+ * Used to examine the existence of features that can be enabled
1338
+ * or disabled at compile-time.
1339
+ * They used to be called XML_FEATURE_xxx but this clashed with Expat
1340
+ */
1341
+ typedef enum {
1342
+ XML_WITH_THREAD = 1,
1343
+ XML_WITH_TREE = 2,
1344
+ XML_WITH_OUTPUT = 3,
1345
+ XML_WITH_PUSH = 4,
1346
+ XML_WITH_READER = 5,
1347
+ XML_WITH_PATTERN = 6,
1348
+ XML_WITH_WRITER = 7,
1349
+ XML_WITH_SAX1 = 8,
1350
+ XML_WITH_FTP = 9,
1351
+ XML_WITH_HTTP = 10,
1352
+ XML_WITH_VALID = 11,
1353
+ XML_WITH_HTML = 12,
1354
+ XML_WITH_LEGACY = 13,
1355
+ XML_WITH_C14N = 14,
1356
+ XML_WITH_CATALOG = 15,
1357
+ XML_WITH_XPATH = 16,
1358
+ XML_WITH_XPTR = 17,
1359
+ XML_WITH_XINCLUDE = 18,
1360
+ XML_WITH_ICONV = 19,
1361
+ XML_WITH_ISO8859X = 20,
1362
+ XML_WITH_UNICODE = 21,
1363
+ XML_WITH_REGEXP = 22,
1364
+ XML_WITH_AUTOMATA = 23,
1365
+ XML_WITH_EXPR = 24,
1366
+ XML_WITH_SCHEMAS = 25,
1367
+ XML_WITH_SCHEMATRON = 26,
1368
+ XML_WITH_MODULES = 27,
1369
+ XML_WITH_DEBUG = 28,
1370
+ XML_WITH_DEBUG_MEM = 29,
1371
+ XML_WITH_DEBUG_RUN = 30,
1372
+ XML_WITH_ZLIB = 31,
1373
+ XML_WITH_ICU = 32,
1374
+ XML_WITH_LZMA = 33,
1375
+ XML_WITH_NONE = 99999 /* just to be sure of allocation size */
1376
+ } xmlFeature;
1377
+
1378
+ XMLPUBFUN int
1379
+ xmlHasFeature (xmlFeature feature);
1380
+
1381
+ #ifdef __cplusplus
1382
+ }
1383
+ #endif
1384
+ #endif /* __XML_PARSER_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/parserInternals.h ADDED
@@ -0,0 +1,663 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: internals routines and limits exported by the parser.
3
+ * Description: this module exports a number of internal parsing routines
4
+ * they are not really all intended for applications but
5
+ * can prove useful doing low level processing.
6
+ *
7
+ * Copy: See Copyright for the status of this software.
8
+ *
9
+ * Author: Daniel Veillard
10
+ */
11
+
12
+ #ifndef __XML_PARSER_INTERNALS_H__
13
+ #define __XML_PARSER_INTERNALS_H__
14
+
15
+ #include <libxml/xmlversion.h>
16
+ #include <libxml/parser.h>
17
+ #include <libxml/HTMLparser.h>
18
+ #include <libxml/chvalid.h>
19
+ #include <libxml/SAX2.h>
20
+
21
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif
24
+
25
+ /**
26
+ * xmlParserMaxDepth:
27
+ *
28
+ * arbitrary depth limit for the XML documents that we allow to
29
+ * process. This is not a limitation of the parser but a safety
30
+ * boundary feature, use XML_PARSE_HUGE option to override it.
31
+ */
32
+ XMLPUBVAR unsigned int xmlParserMaxDepth;
33
+
34
+ /**
35
+ * XML_MAX_TEXT_LENGTH:
36
+ *
37
+ * Maximum size allowed for a single text node when building a tree.
38
+ * This is not a limitation of the parser but a safety boundary feature,
39
+ * use XML_PARSE_HUGE option to override it.
40
+ * Introduced in 2.9.0
41
+ */
42
+ #define XML_MAX_TEXT_LENGTH 10000000
43
+
44
+ /**
45
+ * XML_MAX_HUGE_LENGTH:
46
+ *
47
+ * Maximum size allowed when XML_PARSE_HUGE is set.
48
+ */
49
+ #define XML_MAX_HUGE_LENGTH 1000000000
50
+
51
+ /**
52
+ * XML_MAX_NAME_LENGTH:
53
+ *
54
+ * Maximum size allowed for a markup identifier.
55
+ * This is not a limitation of the parser but a safety boundary feature,
56
+ * use XML_PARSE_HUGE option to override it.
57
+ * Note that with the use of parsing dictionaries overriding the limit
58
+ * may result in more runtime memory usage in face of "unfriendly' content
59
+ * Introduced in 2.9.0
60
+ */
61
+ #define XML_MAX_NAME_LENGTH 50000
62
+
63
+ /**
64
+ * XML_MAX_DICTIONARY_LIMIT:
65
+ *
66
+ * Maximum size allowed by the parser for a dictionary by default
67
+ * This is not a limitation of the parser but a safety boundary feature,
68
+ * use XML_PARSE_HUGE option to override it.
69
+ * Introduced in 2.9.0
70
+ */
71
+ #define XML_MAX_DICTIONARY_LIMIT 10000000
72
+
73
+ /**
74
+ * XML_MAX_LOOKUP_LIMIT:
75
+ *
76
+ * Maximum size allowed by the parser for ahead lookup
77
+ * This is an upper boundary enforced by the parser to avoid bad
78
+ * behaviour on "unfriendly' content
79
+ * Introduced in 2.9.0
80
+ */
81
+ #define XML_MAX_LOOKUP_LIMIT 10000000
82
+
83
+ /**
84
+ * XML_MAX_NAMELEN:
85
+ *
86
+ * Identifiers can be longer, but this will be more costly
87
+ * at runtime.
88
+ */
89
+ #define XML_MAX_NAMELEN 100
90
+
91
+ /**
92
+ * INPUT_CHUNK:
93
+ *
94
+ * The parser tries to always have that amount of input ready.
95
+ * One of the point is providing context when reporting errors.
96
+ */
97
+ #define INPUT_CHUNK 250
98
+
99
+ /************************************************************************
100
+ * *
101
+ * UNICODE version of the macros. *
102
+ * *
103
+ ************************************************************************/
104
+ /**
105
+ * IS_BYTE_CHAR:
106
+ * @c: an byte value (int)
107
+ *
108
+ * Macro to check the following production in the XML spec:
109
+ *
110
+ * [2] Char ::= #x9 | #xA | #xD | [#x20...]
111
+ * any byte character in the accepted range
112
+ */
113
+ #define IS_BYTE_CHAR(c) xmlIsChar_ch(c)
114
+
115
+ /**
116
+ * IS_CHAR:
117
+ * @c: an UNICODE value (int)
118
+ *
119
+ * Macro to check the following production in the XML spec:
120
+ *
121
+ * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
122
+ * | [#x10000-#x10FFFF]
123
+ * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
124
+ */
125
+ #define IS_CHAR(c) xmlIsCharQ(c)
126
+
127
+ /**
128
+ * IS_CHAR_CH:
129
+ * @c: an xmlChar (usually an unsigned char)
130
+ *
131
+ * Behaves like IS_CHAR on single-byte value
132
+ */
133
+ #define IS_CHAR_CH(c) xmlIsChar_ch(c)
134
+
135
+ /**
136
+ * IS_BLANK:
137
+ * @c: an UNICODE value (int)
138
+ *
139
+ * Macro to check the following production in the XML spec:
140
+ *
141
+ * [3] S ::= (#x20 | #x9 | #xD | #xA)+
142
+ */
143
+ #define IS_BLANK(c) xmlIsBlankQ(c)
144
+
145
+ /**
146
+ * IS_BLANK_CH:
147
+ * @c: an xmlChar value (normally unsigned char)
148
+ *
149
+ * Behaviour same as IS_BLANK
150
+ */
151
+ #define IS_BLANK_CH(c) xmlIsBlank_ch(c)
152
+
153
+ /**
154
+ * IS_BASECHAR:
155
+ * @c: an UNICODE value (int)
156
+ *
157
+ * Macro to check the following production in the XML spec:
158
+ *
159
+ * [85] BaseChar ::= ... long list see REC ...
160
+ */
161
+ #define IS_BASECHAR(c) xmlIsBaseCharQ(c)
162
+
163
+ /**
164
+ * IS_DIGIT:
165
+ * @c: an UNICODE value (int)
166
+ *
167
+ * Macro to check the following production in the XML spec:
168
+ *
169
+ * [88] Digit ::= ... long list see REC ...
170
+ */
171
+ #define IS_DIGIT(c) xmlIsDigitQ(c)
172
+
173
+ /**
174
+ * IS_DIGIT_CH:
175
+ * @c: an xmlChar value (usually an unsigned char)
176
+ *
177
+ * Behaves like IS_DIGIT but with a single byte argument
178
+ */
179
+ #define IS_DIGIT_CH(c) xmlIsDigit_ch(c)
180
+
181
+ /**
182
+ * IS_COMBINING:
183
+ * @c: an UNICODE value (int)
184
+ *
185
+ * Macro to check the following production in the XML spec:
186
+ *
187
+ * [87] CombiningChar ::= ... long list see REC ...
188
+ */
189
+ #define IS_COMBINING(c) xmlIsCombiningQ(c)
190
+
191
+ /**
192
+ * IS_COMBINING_CH:
193
+ * @c: an xmlChar (usually an unsigned char)
194
+ *
195
+ * Always false (all combining chars > 0xff)
196
+ */
197
+ #define IS_COMBINING_CH(c) 0
198
+
199
+ /**
200
+ * IS_EXTENDER:
201
+ * @c: an UNICODE value (int)
202
+ *
203
+ * Macro to check the following production in the XML spec:
204
+ *
205
+ *
206
+ * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
207
+ * #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |
208
+ * [#x309D-#x309E] | [#x30FC-#x30FE]
209
+ */
210
+ #define IS_EXTENDER(c) xmlIsExtenderQ(c)
211
+
212
+ /**
213
+ * IS_EXTENDER_CH:
214
+ * @c: an xmlChar value (usually an unsigned char)
215
+ *
216
+ * Behaves like IS_EXTENDER but with a single-byte argument
217
+ */
218
+ #define IS_EXTENDER_CH(c) xmlIsExtender_ch(c)
219
+
220
+ /**
221
+ * IS_IDEOGRAPHIC:
222
+ * @c: an UNICODE value (int)
223
+ *
224
+ * Macro to check the following production in the XML spec:
225
+ *
226
+ *
227
+ * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
228
+ */
229
+ #define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c)
230
+
231
+ /**
232
+ * IS_LETTER:
233
+ * @c: an UNICODE value (int)
234
+ *
235
+ * Macro to check the following production in the XML spec:
236
+ *
237
+ *
238
+ * [84] Letter ::= BaseChar | Ideographic
239
+ */
240
+ #define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
241
+
242
+ /**
243
+ * IS_LETTER_CH:
244
+ * @c: an xmlChar value (normally unsigned char)
245
+ *
246
+ * Macro behaves like IS_LETTER, but only check base chars
247
+ *
248
+ */
249
+ #define IS_LETTER_CH(c) xmlIsBaseChar_ch(c)
250
+
251
+ /**
252
+ * IS_ASCII_LETTER:
253
+ * @c: an xmlChar value
254
+ *
255
+ * Macro to check [a-zA-Z]
256
+ *
257
+ */
258
+ #define IS_ASCII_LETTER(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \
259
+ ((0x61 <= (c)) && ((c) <= 0x7a)))
260
+
261
+ /**
262
+ * IS_ASCII_DIGIT:
263
+ * @c: an xmlChar value
264
+ *
265
+ * Macro to check [0-9]
266
+ *
267
+ */
268
+ #define IS_ASCII_DIGIT(c) ((0x30 <= (c)) && ((c) <= 0x39))
269
+
270
+ /**
271
+ * IS_PUBIDCHAR:
272
+ * @c: an UNICODE value (int)
273
+ *
274
+ * Macro to check the following production in the XML spec:
275
+ *
276
+ *
277
+ * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
278
+ */
279
+ #define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c)
280
+
281
+ /**
282
+ * IS_PUBIDCHAR_CH:
283
+ * @c: an xmlChar value (normally unsigned char)
284
+ *
285
+ * Same as IS_PUBIDCHAR but for single-byte value
286
+ */
287
+ #define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c)
288
+
289
+ /**
290
+ * Global variables used for predefined strings.
291
+ */
292
+ XMLPUBVAR const xmlChar xmlStringText[];
293
+ XMLPUBVAR const xmlChar xmlStringTextNoenc[];
294
+ XMLPUBVAR const xmlChar xmlStringComment[];
295
+
296
+ /*
297
+ * Function to finish the work of the macros where needed.
298
+ */
299
+ XMLPUBFUN int xmlIsLetter (int c);
300
+
301
+ /**
302
+ * Parser context.
303
+ */
304
+ XMLPUBFUN xmlParserCtxtPtr
305
+ xmlCreateFileParserCtxt (const char *filename);
306
+ XMLPUBFUN xmlParserCtxtPtr
307
+ xmlCreateURLParserCtxt (const char *filename,
308
+ int options);
309
+ XMLPUBFUN xmlParserCtxtPtr
310
+ xmlCreateMemoryParserCtxt(const char *buffer,
311
+ int size);
312
+ XMLPUBFUN xmlParserCtxtPtr
313
+ xmlCreateEntityParserCtxt(const xmlChar *URL,
314
+ const xmlChar *ID,
315
+ const xmlChar *base);
316
+ XMLPUBFUN int
317
+ xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
318
+ xmlCharEncoding enc);
319
+ XMLPUBFUN int
320
+ xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
321
+ xmlCharEncodingHandlerPtr handler);
322
+ XML_DEPRECATED
323
+ XMLPUBFUN int
324
+ xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt,
325
+ xmlParserInputPtr input,
326
+ xmlCharEncodingHandlerPtr handler);
327
+
328
+ /**
329
+ * Input Streams.
330
+ */
331
+ XMLPUBFUN xmlParserInputPtr
332
+ xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
333
+ const xmlChar *buffer);
334
+ XML_DEPRECATED
335
+ XMLPUBFUN xmlParserInputPtr
336
+ xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
337
+ xmlEntityPtr entity);
338
+ XMLPUBFUN int
339
+ xmlPushInput (xmlParserCtxtPtr ctxt,
340
+ xmlParserInputPtr input);
341
+ XMLPUBFUN xmlChar
342
+ xmlPopInput (xmlParserCtxtPtr ctxt);
343
+ XMLPUBFUN void
344
+ xmlFreeInputStream (xmlParserInputPtr input);
345
+ XMLPUBFUN xmlParserInputPtr
346
+ xmlNewInputFromFile (xmlParserCtxtPtr ctxt,
347
+ const char *filename);
348
+ XMLPUBFUN xmlParserInputPtr
349
+ xmlNewInputStream (xmlParserCtxtPtr ctxt);
350
+
351
+ /**
352
+ * Namespaces.
353
+ */
354
+ XMLPUBFUN xmlChar *
355
+ xmlSplitQName (xmlParserCtxtPtr ctxt,
356
+ const xmlChar *name,
357
+ xmlChar **prefix);
358
+
359
+ /**
360
+ * Generic production rules.
361
+ */
362
+ XML_DEPRECATED
363
+ XMLPUBFUN const xmlChar *
364
+ xmlParseName (xmlParserCtxtPtr ctxt);
365
+ XML_DEPRECATED
366
+ XMLPUBFUN xmlChar *
367
+ xmlParseNmtoken (xmlParserCtxtPtr ctxt);
368
+ XML_DEPRECATED
369
+ XMLPUBFUN xmlChar *
370
+ xmlParseEntityValue (xmlParserCtxtPtr ctxt,
371
+ xmlChar **orig);
372
+ XML_DEPRECATED
373
+ XMLPUBFUN xmlChar *
374
+ xmlParseAttValue (xmlParserCtxtPtr ctxt);
375
+ XML_DEPRECATED
376
+ XMLPUBFUN xmlChar *
377
+ xmlParseSystemLiteral (xmlParserCtxtPtr ctxt);
378
+ XML_DEPRECATED
379
+ XMLPUBFUN xmlChar *
380
+ xmlParsePubidLiteral (xmlParserCtxtPtr ctxt);
381
+ XML_DEPRECATED
382
+ XMLPUBFUN void
383
+ xmlParseCharData (xmlParserCtxtPtr ctxt,
384
+ int cdata);
385
+ XML_DEPRECATED
386
+ XMLPUBFUN xmlChar *
387
+ xmlParseExternalID (xmlParserCtxtPtr ctxt,
388
+ xmlChar **publicID,
389
+ int strict);
390
+ XML_DEPRECATED
391
+ XMLPUBFUN void
392
+ xmlParseComment (xmlParserCtxtPtr ctxt);
393
+ XML_DEPRECATED
394
+ XMLPUBFUN const xmlChar *
395
+ xmlParsePITarget (xmlParserCtxtPtr ctxt);
396
+ XML_DEPRECATED
397
+ XMLPUBFUN void
398
+ xmlParsePI (xmlParserCtxtPtr ctxt);
399
+ XML_DEPRECATED
400
+ XMLPUBFUN void
401
+ xmlParseNotationDecl (xmlParserCtxtPtr ctxt);
402
+ XML_DEPRECATED
403
+ XMLPUBFUN void
404
+ xmlParseEntityDecl (xmlParserCtxtPtr ctxt);
405
+ XML_DEPRECATED
406
+ XMLPUBFUN int
407
+ xmlParseDefaultDecl (xmlParserCtxtPtr ctxt,
408
+ xmlChar **value);
409
+ XML_DEPRECATED
410
+ XMLPUBFUN xmlEnumerationPtr
411
+ xmlParseNotationType (xmlParserCtxtPtr ctxt);
412
+ XML_DEPRECATED
413
+ XMLPUBFUN xmlEnumerationPtr
414
+ xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
415
+ XML_DEPRECATED
416
+ XMLPUBFUN int
417
+ xmlParseEnumeratedType (xmlParserCtxtPtr ctxt,
418
+ xmlEnumerationPtr *tree);
419
+ XML_DEPRECATED
420
+ XMLPUBFUN int
421
+ xmlParseAttributeType (xmlParserCtxtPtr ctxt,
422
+ xmlEnumerationPtr *tree);
423
+ XML_DEPRECATED
424
+ XMLPUBFUN void
425
+ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
426
+ XML_DEPRECATED
427
+ XMLPUBFUN xmlElementContentPtr
428
+ xmlParseElementMixedContentDecl
429
+ (xmlParserCtxtPtr ctxt,
430
+ int inputchk);
431
+ XML_DEPRECATED
432
+ XMLPUBFUN xmlElementContentPtr
433
+ xmlParseElementChildrenContentDecl
434
+ (xmlParserCtxtPtr ctxt,
435
+ int inputchk);
436
+ XML_DEPRECATED
437
+ XMLPUBFUN int
438
+ xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
439
+ const xmlChar *name,
440
+ xmlElementContentPtr *result);
441
+ XML_DEPRECATED
442
+ XMLPUBFUN int
443
+ xmlParseElementDecl (xmlParserCtxtPtr ctxt);
444
+ XML_DEPRECATED
445
+ XMLPUBFUN void
446
+ xmlParseMarkupDecl (xmlParserCtxtPtr ctxt);
447
+ XML_DEPRECATED
448
+ XMLPUBFUN int
449
+ xmlParseCharRef (xmlParserCtxtPtr ctxt);
450
+ XML_DEPRECATED
451
+ XMLPUBFUN xmlEntityPtr
452
+ xmlParseEntityRef (xmlParserCtxtPtr ctxt);
453
+ XML_DEPRECATED
454
+ XMLPUBFUN void
455
+ xmlParseReference (xmlParserCtxtPtr ctxt);
456
+ XML_DEPRECATED
457
+ XMLPUBFUN void
458
+ xmlParsePEReference (xmlParserCtxtPtr ctxt);
459
+ XML_DEPRECATED
460
+ XMLPUBFUN void
461
+ xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt);
462
+ #ifdef LIBXML_SAX1_ENABLED
463
+ XML_DEPRECATED
464
+ XMLPUBFUN const xmlChar *
465
+ xmlParseAttribute (xmlParserCtxtPtr ctxt,
466
+ xmlChar **value);
467
+ XML_DEPRECATED
468
+ XMLPUBFUN const xmlChar *
469
+ xmlParseStartTag (xmlParserCtxtPtr ctxt);
470
+ XML_DEPRECATED
471
+ XMLPUBFUN void
472
+ xmlParseEndTag (xmlParserCtxtPtr ctxt);
473
+ #endif /* LIBXML_SAX1_ENABLED */
474
+ XML_DEPRECATED
475
+ XMLPUBFUN void
476
+ xmlParseCDSect (xmlParserCtxtPtr ctxt);
477
+ XMLPUBFUN void
478
+ xmlParseContent (xmlParserCtxtPtr ctxt);
479
+ XML_DEPRECATED
480
+ XMLPUBFUN void
481
+ xmlParseElement (xmlParserCtxtPtr ctxt);
482
+ XML_DEPRECATED
483
+ XMLPUBFUN xmlChar *
484
+ xmlParseVersionNum (xmlParserCtxtPtr ctxt);
485
+ XML_DEPRECATED
486
+ XMLPUBFUN xmlChar *
487
+ xmlParseVersionInfo (xmlParserCtxtPtr ctxt);
488
+ XML_DEPRECATED
489
+ XMLPUBFUN xmlChar *
490
+ xmlParseEncName (xmlParserCtxtPtr ctxt);
491
+ XML_DEPRECATED
492
+ XMLPUBFUN const xmlChar *
493
+ xmlParseEncodingDecl (xmlParserCtxtPtr ctxt);
494
+ XML_DEPRECATED
495
+ XMLPUBFUN int
496
+ xmlParseSDDecl (xmlParserCtxtPtr ctxt);
497
+ XML_DEPRECATED
498
+ XMLPUBFUN void
499
+ xmlParseXMLDecl (xmlParserCtxtPtr ctxt);
500
+ XML_DEPRECATED
501
+ XMLPUBFUN void
502
+ xmlParseTextDecl (xmlParserCtxtPtr ctxt);
503
+ XML_DEPRECATED
504
+ XMLPUBFUN void
505
+ xmlParseMisc (xmlParserCtxtPtr ctxt);
506
+ XMLPUBFUN void
507
+ xmlParseExternalSubset (xmlParserCtxtPtr ctxt,
508
+ const xmlChar *ExternalID,
509
+ const xmlChar *SystemID);
510
+ /**
511
+ * XML_SUBSTITUTE_NONE:
512
+ *
513
+ * If no entities need to be substituted.
514
+ */
515
+ #define XML_SUBSTITUTE_NONE 0
516
+ /**
517
+ * XML_SUBSTITUTE_REF:
518
+ *
519
+ * Whether general entities need to be substituted.
520
+ */
521
+ #define XML_SUBSTITUTE_REF 1
522
+ /**
523
+ * XML_SUBSTITUTE_PEREF:
524
+ *
525
+ * Whether parameter entities need to be substituted.
526
+ */
527
+ #define XML_SUBSTITUTE_PEREF 2
528
+ /**
529
+ * XML_SUBSTITUTE_BOTH:
530
+ *
531
+ * Both general and parameter entities need to be substituted.
532
+ */
533
+ #define XML_SUBSTITUTE_BOTH 3
534
+
535
+ XML_DEPRECATED
536
+ XMLPUBFUN xmlChar *
537
+ xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
538
+ const xmlChar *str,
539
+ int what,
540
+ xmlChar end,
541
+ xmlChar end2,
542
+ xmlChar end3);
543
+ XML_DEPRECATED
544
+ XMLPUBFUN xmlChar *
545
+ xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt,
546
+ const xmlChar *str,
547
+ int len,
548
+ int what,
549
+ xmlChar end,
550
+ xmlChar end2,
551
+ xmlChar end3);
552
+
553
+ /*
554
+ * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.
555
+ */
556
+ XML_DEPRECATED
557
+ XMLPUBFUN int nodePush (xmlParserCtxtPtr ctxt,
558
+ xmlNodePtr value);
559
+ XML_DEPRECATED
560
+ XMLPUBFUN xmlNodePtr nodePop (xmlParserCtxtPtr ctxt);
561
+ XMLPUBFUN int inputPush (xmlParserCtxtPtr ctxt,
562
+ xmlParserInputPtr value);
563
+ XMLPUBFUN xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
564
+ XML_DEPRECATED
565
+ XMLPUBFUN const xmlChar * namePop (xmlParserCtxtPtr ctxt);
566
+ XML_DEPRECATED
567
+ XMLPUBFUN int namePush (xmlParserCtxtPtr ctxt,
568
+ const xmlChar *value);
569
+
570
+ /*
571
+ * other commodities shared between parser.c and parserInternals.
572
+ */
573
+ XML_DEPRECATED
574
+ XMLPUBFUN int xmlSkipBlankChars (xmlParserCtxtPtr ctxt);
575
+ XML_DEPRECATED
576
+ XMLPUBFUN int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
577
+ const xmlChar *cur,
578
+ int *len);
579
+ XML_DEPRECATED
580
+ XMLPUBFUN void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
581
+ XML_DEPRECATED
582
+ XMLPUBFUN int xmlCheckLanguageID (const xmlChar *lang);
583
+
584
+ /*
585
+ * Really core function shared with HTML parser.
586
+ */
587
+ XML_DEPRECATED
588
+ XMLPUBFUN int xmlCurrentChar (xmlParserCtxtPtr ctxt,
589
+ int *len);
590
+ XMLPUBFUN int xmlCopyCharMultiByte (xmlChar *out,
591
+ int val);
592
+ XMLPUBFUN int xmlCopyChar (int len,
593
+ xmlChar *out,
594
+ int val);
595
+ XML_DEPRECATED
596
+ XMLPUBFUN void xmlNextChar (xmlParserCtxtPtr ctxt);
597
+ XML_DEPRECATED
598
+ XMLPUBFUN void xmlParserInputShrink (xmlParserInputPtr in);
599
+
600
+ /*
601
+ * Specific function to keep track of entities references
602
+ * and used by the XSLT debugger.
603
+ */
604
+ #ifdef LIBXML_LEGACY_ENABLED
605
+ /**
606
+ * xmlEntityReferenceFunc:
607
+ * @ent: the entity
608
+ * @firstNode: the fist node in the chunk
609
+ * @lastNode: the last nod in the chunk
610
+ *
611
+ * Callback function used when one needs to be able to track back the
612
+ * provenance of a chunk of nodes inherited from an entity replacement.
613
+ */
614
+ typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent,
615
+ xmlNodePtr firstNode,
616
+ xmlNodePtr lastNode);
617
+
618
+ XML_DEPRECATED
619
+ XMLPUBFUN void xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func);
620
+
621
+ XML_DEPRECATED
622
+ XMLPUBFUN xmlChar *
623
+ xmlParseQuotedString (xmlParserCtxtPtr ctxt);
624
+ XML_DEPRECATED
625
+ XMLPUBFUN void
626
+ xmlParseNamespace (xmlParserCtxtPtr ctxt);
627
+ XML_DEPRECATED
628
+ XMLPUBFUN xmlChar *
629
+ xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
630
+ XML_DEPRECATED
631
+ XMLPUBFUN xmlChar *
632
+ xmlScanName (xmlParserCtxtPtr ctxt);
633
+ XML_DEPRECATED
634
+ XMLPUBFUN xmlChar *
635
+ xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
636
+ XML_DEPRECATED
637
+ XMLPUBFUN void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
638
+ XML_DEPRECATED
639
+ XMLPUBFUN xmlChar *
640
+ xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
641
+ xmlChar **prefix);
642
+ /**
643
+ * Entities
644
+ */
645
+ XML_DEPRECATED
646
+ XMLPUBFUN xmlChar *
647
+ xmlDecodeEntities (xmlParserCtxtPtr ctxt,
648
+ int len,
649
+ int what,
650
+ xmlChar end,
651
+ xmlChar end2,
652
+ xmlChar end3);
653
+ XML_DEPRECATED
654
+ XMLPUBFUN void
655
+ xmlHandleEntity (xmlParserCtxtPtr ctxt,
656
+ xmlEntityPtr entity);
657
+
658
+ #endif /* LIBXML_LEGACY_ENABLED */
659
+
660
+ #ifdef __cplusplus
661
+ }
662
+ #endif
663
+ #endif /* __XML_PARSER_INTERNALS_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/schematron.h ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: XML Schematron implementation
3
+ * Description: interface to the XML Schematron validity checking.
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Daniel Veillard
8
+ */
9
+
10
+
11
+ #ifndef __XML_SCHEMATRON_H__
12
+ #define __XML_SCHEMATRON_H__
13
+
14
+ #include <libxml/xmlversion.h>
15
+
16
+ #ifdef LIBXML_SCHEMATRON_ENABLED
17
+
18
+ #include <libxml/xmlerror.h>
19
+ #include <libxml/tree.h>
20
+
21
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif
24
+
25
+ typedef enum {
26
+ XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */
27
+ XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */
28
+ XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */
29
+ XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */
30
+ XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */
31
+ XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */
32
+ XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */
33
+ } xmlSchematronValidOptions;
34
+
35
+ /**
36
+ * The schemas related types are kept internal
37
+ */
38
+ typedef struct _xmlSchematron xmlSchematron;
39
+ typedef xmlSchematron *xmlSchematronPtr;
40
+
41
+ /**
42
+ * xmlSchematronValidityErrorFunc:
43
+ * @ctx: the validation context
44
+ * @msg: the message
45
+ * @...: extra arguments
46
+ *
47
+ * Signature of an error callback from a Schematron validation
48
+ */
49
+ typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...);
50
+
51
+ /**
52
+ * xmlSchematronValidityWarningFunc:
53
+ * @ctx: the validation context
54
+ * @msg: the message
55
+ * @...: extra arguments
56
+ *
57
+ * Signature of a warning callback from a Schematron validation
58
+ */
59
+ typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...);
60
+
61
+ /**
62
+ * A schemas validation context
63
+ */
64
+ typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt;
65
+ typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr;
66
+
67
+ typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt;
68
+ typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr;
69
+
70
+ /*
71
+ * Interfaces for parsing.
72
+ */
73
+ XMLPUBFUN xmlSchematronParserCtxtPtr
74
+ xmlSchematronNewParserCtxt (const char *URL);
75
+ XMLPUBFUN xmlSchematronParserCtxtPtr
76
+ xmlSchematronNewMemParserCtxt(const char *buffer,
77
+ int size);
78
+ XMLPUBFUN xmlSchematronParserCtxtPtr
79
+ xmlSchematronNewDocParserCtxt(xmlDocPtr doc);
80
+ XMLPUBFUN void
81
+ xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt);
82
+ /*****
83
+ XMLPUBFUN void
84
+ xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt,
85
+ xmlSchematronValidityErrorFunc err,
86
+ xmlSchematronValidityWarningFunc warn,
87
+ void *ctx);
88
+ XMLPUBFUN int
89
+ xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt,
90
+ xmlSchematronValidityErrorFunc * err,
91
+ xmlSchematronValidityWarningFunc * warn,
92
+ void **ctx);
93
+ XMLPUBFUN int
94
+ xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt);
95
+ *****/
96
+ XMLPUBFUN xmlSchematronPtr
97
+ xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt);
98
+ XMLPUBFUN void
99
+ xmlSchematronFree (xmlSchematronPtr schema);
100
+ /*
101
+ * Interfaces for validating
102
+ */
103
+ XMLPUBFUN void
104
+ xmlSchematronSetValidStructuredErrors(
105
+ xmlSchematronValidCtxtPtr ctxt,
106
+ xmlStructuredErrorFunc serror,
107
+ void *ctx);
108
+ /******
109
+ XMLPUBFUN void
110
+ xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt,
111
+ xmlSchematronValidityErrorFunc err,
112
+ xmlSchematronValidityWarningFunc warn,
113
+ void *ctx);
114
+ XMLPUBFUN int
115
+ xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt,
116
+ xmlSchematronValidityErrorFunc *err,
117
+ xmlSchematronValidityWarningFunc *warn,
118
+ void **ctx);
119
+ XMLPUBFUN int
120
+ xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt,
121
+ int options);
122
+ XMLPUBFUN int
123
+ xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt);
124
+ XMLPUBFUN int
125
+ xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt,
126
+ xmlNodePtr elem);
127
+ *******/
128
+
129
+ XMLPUBFUN xmlSchematronValidCtxtPtr
130
+ xmlSchematronNewValidCtxt (xmlSchematronPtr schema,
131
+ int options);
132
+ XMLPUBFUN void
133
+ xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt);
134
+ XMLPUBFUN int
135
+ xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt,
136
+ xmlDocPtr instance);
137
+
138
+ #ifdef __cplusplus
139
+ }
140
+ #endif
141
+
142
+ #endif /* LIBXML_SCHEMATRON_ENABLED */
143
+ #endif /* __XML_SCHEMATRON_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/valid.h ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: The DTD validation
3
+ * Description: API for the DTD handling and the validity checking
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Daniel Veillard
8
+ */
9
+
10
+
11
+ #ifndef __XML_VALID_H__
12
+ #define __XML_VALID_H__
13
+
14
+ #include <libxml/xmlversion.h>
15
+ #include <libxml/xmlerror.h>
16
+ #define XML_TREE_INTERNALS
17
+ #include <libxml/tree.h>
18
+ #undef XML_TREE_INTERNALS
19
+ #include <libxml/list.h>
20
+ #include <libxml/xmlautomata.h>
21
+ #include <libxml/xmlregexp.h>
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ /*
28
+ * Validation state added for non-determinist content model.
29
+ */
30
+ typedef struct _xmlValidState xmlValidState;
31
+ typedef xmlValidState *xmlValidStatePtr;
32
+
33
+ /**
34
+ * xmlValidityErrorFunc:
35
+ * @ctx: usually an xmlValidCtxtPtr to a validity error context,
36
+ * but comes from ctxt->userData (which normally contains such
37
+ * a pointer); ctxt->userData can be changed by the user.
38
+ * @msg: the string to format *printf like vararg
39
+ * @...: remaining arguments to the format
40
+ *
41
+ * Callback called when a validity error is found. This is a message
42
+ * oriented function similar to an *printf function.
43
+ */
44
+ typedef void (*xmlValidityErrorFunc) (void *ctx,
45
+ const char *msg,
46
+ ...) LIBXML_ATTR_FORMAT(2,3);
47
+
48
+ /**
49
+ * xmlValidityWarningFunc:
50
+ * @ctx: usually an xmlValidCtxtPtr to a validity error context,
51
+ * but comes from ctxt->userData (which normally contains such
52
+ * a pointer); ctxt->userData can be changed by the user.
53
+ * @msg: the string to format *printf like vararg
54
+ * @...: remaining arguments to the format
55
+ *
56
+ * Callback called when a validity warning is found. This is a message
57
+ * oriented function similar to an *printf function.
58
+ */
59
+ typedef void (*xmlValidityWarningFunc) (void *ctx,
60
+ const char *msg,
61
+ ...) LIBXML_ATTR_FORMAT(2,3);
62
+
63
+ /*
64
+ * xmlValidCtxt:
65
+ * An xmlValidCtxt is used for error reporting when validating.
66
+ */
67
+ typedef struct _xmlValidCtxt xmlValidCtxt;
68
+ typedef xmlValidCtxt *xmlValidCtxtPtr;
69
+ struct _xmlValidCtxt {
70
+ void *userData; /* user specific data block */
71
+ xmlValidityErrorFunc error; /* the callback in case of errors */
72
+ xmlValidityWarningFunc warning; /* the callback in case of warning */
73
+
74
+ /* Node analysis stack used when validating within entities */
75
+ xmlNodePtr node; /* Current parsed Node */
76
+ int nodeNr; /* Depth of the parsing stack */
77
+ int nodeMax; /* Max depth of the parsing stack */
78
+ xmlNodePtr *nodeTab; /* array of nodes */
79
+
80
+ unsigned int flags; /* internal flags */
81
+ xmlDocPtr doc; /* the document */
82
+ int valid; /* temporary validity check result */
83
+
84
+ /* state state used for non-determinist content validation */
85
+ xmlValidState *vstate; /* current state */
86
+ int vstateNr; /* Depth of the validation stack */
87
+ int vstateMax; /* Max depth of the validation stack */
88
+ xmlValidState *vstateTab; /* array of validation states */
89
+
90
+ #ifdef LIBXML_REGEXP_ENABLED
91
+ xmlAutomataPtr am; /* the automata */
92
+ xmlAutomataStatePtr state; /* used to build the automata */
93
+ #else
94
+ void *am;
95
+ void *state;
96
+ #endif
97
+ };
98
+
99
+ /*
100
+ * ALL notation declarations are stored in a table.
101
+ * There is one table per DTD.
102
+ */
103
+
104
+ typedef struct _xmlHashTable xmlNotationTable;
105
+ typedef xmlNotationTable *xmlNotationTablePtr;
106
+
107
+ /*
108
+ * ALL element declarations are stored in a table.
109
+ * There is one table per DTD.
110
+ */
111
+
112
+ typedef struct _xmlHashTable xmlElementTable;
113
+ typedef xmlElementTable *xmlElementTablePtr;
114
+
115
+ /*
116
+ * ALL attribute declarations are stored in a table.
117
+ * There is one table per DTD.
118
+ */
119
+
120
+ typedef struct _xmlHashTable xmlAttributeTable;
121
+ typedef xmlAttributeTable *xmlAttributeTablePtr;
122
+
123
+ /*
124
+ * ALL IDs attributes are stored in a table.
125
+ * There is one table per document.
126
+ */
127
+
128
+ typedef struct _xmlHashTable xmlIDTable;
129
+ typedef xmlIDTable *xmlIDTablePtr;
130
+
131
+ /*
132
+ * ALL Refs attributes are stored in a table.
133
+ * There is one table per document.
134
+ */
135
+
136
+ typedef struct _xmlHashTable xmlRefTable;
137
+ typedef xmlRefTable *xmlRefTablePtr;
138
+
139
+ /* Notation */
140
+ XMLPUBFUN xmlNotationPtr
141
+ xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
142
+ xmlDtdPtr dtd,
143
+ const xmlChar *name,
144
+ const xmlChar *PublicID,
145
+ const xmlChar *SystemID);
146
+ #ifdef LIBXML_TREE_ENABLED
147
+ XMLPUBFUN xmlNotationTablePtr
148
+ xmlCopyNotationTable (xmlNotationTablePtr table);
149
+ #endif /* LIBXML_TREE_ENABLED */
150
+ XMLPUBFUN void
151
+ xmlFreeNotationTable (xmlNotationTablePtr table);
152
+ #ifdef LIBXML_OUTPUT_ENABLED
153
+ XMLPUBFUN void
154
+ xmlDumpNotationDecl (xmlBufferPtr buf,
155
+ xmlNotationPtr nota);
156
+ XMLPUBFUN void
157
+ xmlDumpNotationTable (xmlBufferPtr buf,
158
+ xmlNotationTablePtr table);
159
+ #endif /* LIBXML_OUTPUT_ENABLED */
160
+
161
+ /* Element Content */
162
+ /* the non Doc version are being deprecated */
163
+ XMLPUBFUN xmlElementContentPtr
164
+ xmlNewElementContent (const xmlChar *name,
165
+ xmlElementContentType type);
166
+ XMLPUBFUN xmlElementContentPtr
167
+ xmlCopyElementContent (xmlElementContentPtr content);
168
+ XMLPUBFUN void
169
+ xmlFreeElementContent (xmlElementContentPtr cur);
170
+ /* the new versions with doc argument */
171
+ XMLPUBFUN xmlElementContentPtr
172
+ xmlNewDocElementContent (xmlDocPtr doc,
173
+ const xmlChar *name,
174
+ xmlElementContentType type);
175
+ XMLPUBFUN xmlElementContentPtr
176
+ xmlCopyDocElementContent(xmlDocPtr doc,
177
+ xmlElementContentPtr content);
178
+ XMLPUBFUN void
179
+ xmlFreeDocElementContent(xmlDocPtr doc,
180
+ xmlElementContentPtr cur);
181
+ XMLPUBFUN void
182
+ xmlSnprintfElementContent(char *buf,
183
+ int size,
184
+ xmlElementContentPtr content,
185
+ int englob);
186
+ #ifdef LIBXML_OUTPUT_ENABLED
187
+ /* DEPRECATED */
188
+ XMLPUBFUN void
189
+ xmlSprintfElementContent(char *buf,
190
+ xmlElementContentPtr content,
191
+ int englob);
192
+ #endif /* LIBXML_OUTPUT_ENABLED */
193
+ /* DEPRECATED */
194
+
195
+ /* Element */
196
+ XMLPUBFUN xmlElementPtr
197
+ xmlAddElementDecl (xmlValidCtxtPtr ctxt,
198
+ xmlDtdPtr dtd,
199
+ const xmlChar *name,
200
+ xmlElementTypeVal type,
201
+ xmlElementContentPtr content);
202
+ #ifdef LIBXML_TREE_ENABLED
203
+ XMLPUBFUN xmlElementTablePtr
204
+ xmlCopyElementTable (xmlElementTablePtr table);
205
+ #endif /* LIBXML_TREE_ENABLED */
206
+ XMLPUBFUN void
207
+ xmlFreeElementTable (xmlElementTablePtr table);
208
+ #ifdef LIBXML_OUTPUT_ENABLED
209
+ XMLPUBFUN void
210
+ xmlDumpElementTable (xmlBufferPtr buf,
211
+ xmlElementTablePtr table);
212
+ XMLPUBFUN void
213
+ xmlDumpElementDecl (xmlBufferPtr buf,
214
+ xmlElementPtr elem);
215
+ #endif /* LIBXML_OUTPUT_ENABLED */
216
+
217
+ /* Enumeration */
218
+ XMLPUBFUN xmlEnumerationPtr
219
+ xmlCreateEnumeration (const xmlChar *name);
220
+ XMLPUBFUN void
221
+ xmlFreeEnumeration (xmlEnumerationPtr cur);
222
+ #ifdef LIBXML_TREE_ENABLED
223
+ XMLPUBFUN xmlEnumerationPtr
224
+ xmlCopyEnumeration (xmlEnumerationPtr cur);
225
+ #endif /* LIBXML_TREE_ENABLED */
226
+
227
+ /* Attribute */
228
+ XMLPUBFUN xmlAttributePtr
229
+ xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
230
+ xmlDtdPtr dtd,
231
+ const xmlChar *elem,
232
+ const xmlChar *name,
233
+ const xmlChar *ns,
234
+ xmlAttributeType type,
235
+ xmlAttributeDefault def,
236
+ const xmlChar *defaultValue,
237
+ xmlEnumerationPtr tree);
238
+ #ifdef LIBXML_TREE_ENABLED
239
+ XMLPUBFUN xmlAttributeTablePtr
240
+ xmlCopyAttributeTable (xmlAttributeTablePtr table);
241
+ #endif /* LIBXML_TREE_ENABLED */
242
+ XMLPUBFUN void
243
+ xmlFreeAttributeTable (xmlAttributeTablePtr table);
244
+ #ifdef LIBXML_OUTPUT_ENABLED
245
+ XMLPUBFUN void
246
+ xmlDumpAttributeTable (xmlBufferPtr buf,
247
+ xmlAttributeTablePtr table);
248
+ XMLPUBFUN void
249
+ xmlDumpAttributeDecl (xmlBufferPtr buf,
250
+ xmlAttributePtr attr);
251
+ #endif /* LIBXML_OUTPUT_ENABLED */
252
+
253
+ /* IDs */
254
+ XMLPUBFUN xmlIDPtr
255
+ xmlAddID (xmlValidCtxtPtr ctxt,
256
+ xmlDocPtr doc,
257
+ const xmlChar *value,
258
+ xmlAttrPtr attr);
259
+ XMLPUBFUN void
260
+ xmlFreeIDTable (xmlIDTablePtr table);
261
+ XMLPUBFUN xmlAttrPtr
262
+ xmlGetID (xmlDocPtr doc,
263
+ const xmlChar *ID);
264
+ XMLPUBFUN int
265
+ xmlIsID (xmlDocPtr doc,
266
+ xmlNodePtr elem,
267
+ xmlAttrPtr attr);
268
+ XMLPUBFUN int
269
+ xmlRemoveID (xmlDocPtr doc,
270
+ xmlAttrPtr attr);
271
+
272
+ /* IDREFs */
273
+ XML_DEPRECATED
274
+ XMLPUBFUN xmlRefPtr
275
+ xmlAddRef (xmlValidCtxtPtr ctxt,
276
+ xmlDocPtr doc,
277
+ const xmlChar *value,
278
+ xmlAttrPtr attr);
279
+ XML_DEPRECATED
280
+ XMLPUBFUN void
281
+ xmlFreeRefTable (xmlRefTablePtr table);
282
+ XML_DEPRECATED
283
+ XMLPUBFUN int
284
+ xmlIsRef (xmlDocPtr doc,
285
+ xmlNodePtr elem,
286
+ xmlAttrPtr attr);
287
+ XML_DEPRECATED
288
+ XMLPUBFUN int
289
+ xmlRemoveRef (xmlDocPtr doc,
290
+ xmlAttrPtr attr);
291
+ XML_DEPRECATED
292
+ XMLPUBFUN xmlListPtr
293
+ xmlGetRefs (xmlDocPtr doc,
294
+ const xmlChar *ID);
295
+
296
+ /**
297
+ * The public function calls related to validity checking.
298
+ */
299
+ #ifdef LIBXML_VALID_ENABLED
300
+ /* Allocate/Release Validation Contexts */
301
+ XMLPUBFUN xmlValidCtxtPtr
302
+ xmlNewValidCtxt(void);
303
+ XMLPUBFUN void
304
+ xmlFreeValidCtxt(xmlValidCtxtPtr);
305
+
306
+ XMLPUBFUN int
307
+ xmlValidateRoot (xmlValidCtxtPtr ctxt,
308
+ xmlDocPtr doc);
309
+ XMLPUBFUN int
310
+ xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
311
+ xmlDocPtr doc,
312
+ xmlElementPtr elem);
313
+ XMLPUBFUN xmlChar *
314
+ xmlValidNormalizeAttributeValue(xmlDocPtr doc,
315
+ xmlNodePtr elem,
316
+ const xmlChar *name,
317
+ const xmlChar *value);
318
+ XMLPUBFUN xmlChar *
319
+ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
320
+ xmlDocPtr doc,
321
+ xmlNodePtr elem,
322
+ const xmlChar *name,
323
+ const xmlChar *value);
324
+ XMLPUBFUN int
325
+ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
326
+ xmlDocPtr doc,
327
+ xmlAttributePtr attr);
328
+ XMLPUBFUN int
329
+ xmlValidateAttributeValue(xmlAttributeType type,
330
+ const xmlChar *value);
331
+ XMLPUBFUN int
332
+ xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
333
+ xmlDocPtr doc,
334
+ xmlNotationPtr nota);
335
+ XMLPUBFUN int
336
+ xmlValidateDtd (xmlValidCtxtPtr ctxt,
337
+ xmlDocPtr doc,
338
+ xmlDtdPtr dtd);
339
+ XMLPUBFUN int
340
+ xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
341
+ xmlDocPtr doc);
342
+ XMLPUBFUN int
343
+ xmlValidateDocument (xmlValidCtxtPtr ctxt,
344
+ xmlDocPtr doc);
345
+ XMLPUBFUN int
346
+ xmlValidateElement (xmlValidCtxtPtr ctxt,
347
+ xmlDocPtr doc,
348
+ xmlNodePtr elem);
349
+ XMLPUBFUN int
350
+ xmlValidateOneElement (xmlValidCtxtPtr ctxt,
351
+ xmlDocPtr doc,
352
+ xmlNodePtr elem);
353
+ XMLPUBFUN int
354
+ xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
355
+ xmlDocPtr doc,
356
+ xmlNodePtr elem,
357
+ xmlAttrPtr attr,
358
+ const xmlChar *value);
359
+ XMLPUBFUN int
360
+ xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
361
+ xmlDocPtr doc,
362
+ xmlNodePtr elem,
363
+ const xmlChar *prefix,
364
+ xmlNsPtr ns,
365
+ const xmlChar *value);
366
+ XMLPUBFUN int
367
+ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
368
+ xmlDocPtr doc);
369
+ #endif /* LIBXML_VALID_ENABLED */
370
+
371
+ #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
372
+ XMLPUBFUN int
373
+ xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
374
+ xmlDocPtr doc,
375
+ const xmlChar *notationName);
376
+ #endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
377
+
378
+ XMLPUBFUN int
379
+ xmlIsMixedElement (xmlDocPtr doc,
380
+ const xmlChar *name);
381
+ XMLPUBFUN xmlAttributePtr
382
+ xmlGetDtdAttrDesc (xmlDtdPtr dtd,
383
+ const xmlChar *elem,
384
+ const xmlChar *name);
385
+ XMLPUBFUN xmlAttributePtr
386
+ xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
387
+ const xmlChar *elem,
388
+ const xmlChar *name,
389
+ const xmlChar *prefix);
390
+ XMLPUBFUN xmlNotationPtr
391
+ xmlGetDtdNotationDesc (xmlDtdPtr dtd,
392
+ const xmlChar *name);
393
+ XMLPUBFUN xmlElementPtr
394
+ xmlGetDtdQElementDesc (xmlDtdPtr dtd,
395
+ const xmlChar *name,
396
+ const xmlChar *prefix);
397
+ XMLPUBFUN xmlElementPtr
398
+ xmlGetDtdElementDesc (xmlDtdPtr dtd,
399
+ const xmlChar *name);
400
+
401
+ #ifdef LIBXML_VALID_ENABLED
402
+
403
+ XMLPUBFUN int
404
+ xmlValidGetPotentialChildren(xmlElementContent *ctree,
405
+ const xmlChar **names,
406
+ int *len,
407
+ int max);
408
+
409
+ XMLPUBFUN int
410
+ xmlValidGetValidElements(xmlNode *prev,
411
+ xmlNode *next,
412
+ const xmlChar **names,
413
+ int max);
414
+ XMLPUBFUN int
415
+ xmlValidateNameValue (const xmlChar *value);
416
+ XMLPUBFUN int
417
+ xmlValidateNamesValue (const xmlChar *value);
418
+ XMLPUBFUN int
419
+ xmlValidateNmtokenValue (const xmlChar *value);
420
+ XMLPUBFUN int
421
+ xmlValidateNmtokensValue(const xmlChar *value);
422
+
423
+ #ifdef LIBXML_REGEXP_ENABLED
424
+ /*
425
+ * Validation based on the regexp support
426
+ */
427
+ XMLPUBFUN int
428
+ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
429
+ xmlElementPtr elem);
430
+
431
+ XMLPUBFUN int
432
+ xmlValidatePushElement (xmlValidCtxtPtr ctxt,
433
+ xmlDocPtr doc,
434
+ xmlNodePtr elem,
435
+ const xmlChar *qname);
436
+ XMLPUBFUN int
437
+ xmlValidatePushCData (xmlValidCtxtPtr ctxt,
438
+ const xmlChar *data,
439
+ int len);
440
+ XMLPUBFUN int
441
+ xmlValidatePopElement (xmlValidCtxtPtr ctxt,
442
+ xmlDocPtr doc,
443
+ xmlNodePtr elem,
444
+ const xmlChar *qname);
445
+ #endif /* LIBXML_REGEXP_ENABLED */
446
+ #endif /* LIBXML_VALID_ENABLED */
447
+ #ifdef __cplusplus
448
+ }
449
+ #endif
450
+ #endif /* __XML_VALID_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlexports.h ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: macros for marking symbols as exportable/importable.
3
+ * Description: macros for marking symbols as exportable/importable.
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ */
7
+
8
+ #ifndef __XML_EXPORTS_H__
9
+ #define __XML_EXPORTS_H__
10
+
11
+ /** DOC_DISABLE */
12
+ #if defined(_WIN32) || defined(__CYGWIN__)
13
+ #ifdef LIBXML_STATIC
14
+ #define XMLPUBLIC
15
+ #elif defined(IN_LIBXML)
16
+ #define XMLPUBLIC __declspec(dllexport)
17
+ #else
18
+ #define XMLPUBLIC __declspec(dllimport)
19
+ #endif
20
+ #else /* not Windows */
21
+ #define XMLPUBLIC
22
+ #endif /* platform switch */
23
+ /** DOC_ENABLE */
24
+
25
+ /*
26
+ * XMLPUBFUN:
27
+ *
28
+ * Macro which declares an exportable function
29
+ */
30
+ #define XMLPUBFUN XMLPUBLIC
31
+
32
+ /**
33
+ * XMLPUBVAR:
34
+ *
35
+ * Macro which declares an exportable variable
36
+ */
37
+ #define XMLPUBVAR XMLPUBLIC extern
38
+
39
+ /** DOC_DISABLE */
40
+ /* Compatibility */
41
+ #define XMLCALL
42
+ #define XMLCDECL
43
+ #if !defined(LIBXML_DLL_IMPORT)
44
+ #define LIBXML_DLL_IMPORT XMLPUBVAR
45
+ #endif
46
+ /** DOC_ENABLE */
47
+
48
+ #endif /* __XML_EXPORTS_H__ */
49
+
50
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlreader.h ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: the XMLReader implementation
3
+ * Description: API of the XML streaming API based on C# interfaces.
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Daniel Veillard
8
+ */
9
+
10
+ #ifndef __XML_XMLREADER_H__
11
+ #define __XML_XMLREADER_H__
12
+
13
+ #include <libxml/xmlversion.h>
14
+ #include <libxml/tree.h>
15
+ #include <libxml/xmlerror.h>
16
+ #include <libxml/xmlIO.h>
17
+ #ifdef LIBXML_SCHEMAS_ENABLED
18
+ #include <libxml/relaxng.h>
19
+ #include <libxml/xmlschemas.h>
20
+ #endif
21
+ /* for compatibility */
22
+ #include <libxml/parser.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ /**
29
+ * xmlParserSeverities:
30
+ *
31
+ * How severe an error callback is when the per-reader error callback API
32
+ * is used.
33
+ */
34
+ typedef enum {
35
+ XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,
36
+ XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,
37
+ XML_PARSER_SEVERITY_WARNING = 3,
38
+ XML_PARSER_SEVERITY_ERROR = 4
39
+ } xmlParserSeverities;
40
+
41
+ #ifdef LIBXML_READER_ENABLED
42
+
43
+ /**
44
+ * xmlTextReaderMode:
45
+ *
46
+ * Internal state values for the reader.
47
+ */
48
+ typedef enum {
49
+ XML_TEXTREADER_MODE_INITIAL = 0,
50
+ XML_TEXTREADER_MODE_INTERACTIVE = 1,
51
+ XML_TEXTREADER_MODE_ERROR = 2,
52
+ XML_TEXTREADER_MODE_EOF =3,
53
+ XML_TEXTREADER_MODE_CLOSED = 4,
54
+ XML_TEXTREADER_MODE_READING = 5
55
+ } xmlTextReaderMode;
56
+
57
+ /**
58
+ * xmlParserProperties:
59
+ *
60
+ * Some common options to use with xmlTextReaderSetParserProp, but it
61
+ * is better to use xmlParserOption and the xmlReaderNewxxx and
62
+ * xmlReaderForxxx APIs now.
63
+ */
64
+ typedef enum {
65
+ XML_PARSER_LOADDTD = 1,
66
+ XML_PARSER_DEFAULTATTRS = 2,
67
+ XML_PARSER_VALIDATE = 3,
68
+ XML_PARSER_SUBST_ENTITIES = 4
69
+ } xmlParserProperties;
70
+
71
+ /**
72
+ * xmlReaderTypes:
73
+ *
74
+ * Predefined constants for the different types of nodes.
75
+ */
76
+ typedef enum {
77
+ XML_READER_TYPE_NONE = 0,
78
+ XML_READER_TYPE_ELEMENT = 1,
79
+ XML_READER_TYPE_ATTRIBUTE = 2,
80
+ XML_READER_TYPE_TEXT = 3,
81
+ XML_READER_TYPE_CDATA = 4,
82
+ XML_READER_TYPE_ENTITY_REFERENCE = 5,
83
+ XML_READER_TYPE_ENTITY = 6,
84
+ XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,
85
+ XML_READER_TYPE_COMMENT = 8,
86
+ XML_READER_TYPE_DOCUMENT = 9,
87
+ XML_READER_TYPE_DOCUMENT_TYPE = 10,
88
+ XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,
89
+ XML_READER_TYPE_NOTATION = 12,
90
+ XML_READER_TYPE_WHITESPACE = 13,
91
+ XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,
92
+ XML_READER_TYPE_END_ELEMENT = 15,
93
+ XML_READER_TYPE_END_ENTITY = 16,
94
+ XML_READER_TYPE_XML_DECLARATION = 17
95
+ } xmlReaderTypes;
96
+
97
+ /**
98
+ * xmlTextReader:
99
+ *
100
+ * Structure for an xmlReader context.
101
+ */
102
+ typedef struct _xmlTextReader xmlTextReader;
103
+
104
+ /**
105
+ * xmlTextReaderPtr:
106
+ *
107
+ * Pointer to an xmlReader context.
108
+ */
109
+ typedef xmlTextReader *xmlTextReaderPtr;
110
+
111
+ /*
112
+ * Constructors & Destructor
113
+ */
114
+ XMLPUBFUN xmlTextReaderPtr
115
+ xmlNewTextReader (xmlParserInputBufferPtr input,
116
+ const char *URI);
117
+ XMLPUBFUN xmlTextReaderPtr
118
+ xmlNewTextReaderFilename(const char *URI);
119
+
120
+ XMLPUBFUN void
121
+ xmlFreeTextReader (xmlTextReaderPtr reader);
122
+
123
+ XMLPUBFUN int
124
+ xmlTextReaderSetup(xmlTextReaderPtr reader,
125
+ xmlParserInputBufferPtr input, const char *URL,
126
+ const char *encoding, int options);
127
+ XMLPUBFUN void
128
+ xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader,
129
+ unsigned maxAmpl);
130
+
131
+ /*
132
+ * Iterators
133
+ */
134
+ XMLPUBFUN int
135
+ xmlTextReaderRead (xmlTextReaderPtr reader);
136
+
137
+ #ifdef LIBXML_WRITER_ENABLED
138
+ XMLPUBFUN xmlChar *
139
+ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);
140
+
141
+ XMLPUBFUN xmlChar *
142
+ xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);
143
+ #endif
144
+
145
+ XMLPUBFUN xmlChar *
146
+ xmlTextReaderReadString (xmlTextReaderPtr reader);
147
+ XMLPUBFUN int
148
+ xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);
149
+
150
+ /*
151
+ * Attributes of the node
152
+ */
153
+ XMLPUBFUN int
154
+ xmlTextReaderAttributeCount(xmlTextReaderPtr reader);
155
+ XMLPUBFUN int
156
+ xmlTextReaderDepth (xmlTextReaderPtr reader);
157
+ XMLPUBFUN int
158
+ xmlTextReaderHasAttributes(xmlTextReaderPtr reader);
159
+ XMLPUBFUN int
160
+ xmlTextReaderHasValue(xmlTextReaderPtr reader);
161
+ XMLPUBFUN int
162
+ xmlTextReaderIsDefault (xmlTextReaderPtr reader);
163
+ XMLPUBFUN int
164
+ xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);
165
+ XMLPUBFUN int
166
+ xmlTextReaderNodeType (xmlTextReaderPtr reader);
167
+ XMLPUBFUN int
168
+ xmlTextReaderQuoteChar (xmlTextReaderPtr reader);
169
+ XMLPUBFUN int
170
+ xmlTextReaderReadState (xmlTextReaderPtr reader);
171
+ XMLPUBFUN int
172
+ xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);
173
+
174
+ XMLPUBFUN const xmlChar *
175
+ xmlTextReaderConstBaseUri (xmlTextReaderPtr reader);
176
+ XMLPUBFUN const xmlChar *
177
+ xmlTextReaderConstLocalName (xmlTextReaderPtr reader);
178
+ XMLPUBFUN const xmlChar *
179
+ xmlTextReaderConstName (xmlTextReaderPtr reader);
180
+ XMLPUBFUN const xmlChar *
181
+ xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);
182
+ XMLPUBFUN const xmlChar *
183
+ xmlTextReaderConstPrefix (xmlTextReaderPtr reader);
184
+ XMLPUBFUN const xmlChar *
185
+ xmlTextReaderConstXmlLang (xmlTextReaderPtr reader);
186
+ XMLPUBFUN const xmlChar *
187
+ xmlTextReaderConstString (xmlTextReaderPtr reader,
188
+ const xmlChar *str);
189
+ XMLPUBFUN const xmlChar *
190
+ xmlTextReaderConstValue (xmlTextReaderPtr reader);
191
+
192
+ /*
193
+ * use the Const version of the routine for
194
+ * better performance and simpler code
195
+ */
196
+ XMLPUBFUN xmlChar *
197
+ xmlTextReaderBaseUri (xmlTextReaderPtr reader);
198
+ XMLPUBFUN xmlChar *
199
+ xmlTextReaderLocalName (xmlTextReaderPtr reader);
200
+ XMLPUBFUN xmlChar *
201
+ xmlTextReaderName (xmlTextReaderPtr reader);
202
+ XMLPUBFUN xmlChar *
203
+ xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);
204
+ XMLPUBFUN xmlChar *
205
+ xmlTextReaderPrefix (xmlTextReaderPtr reader);
206
+ XMLPUBFUN xmlChar *
207
+ xmlTextReaderXmlLang (xmlTextReaderPtr reader);
208
+ XMLPUBFUN xmlChar *
209
+ xmlTextReaderValue (xmlTextReaderPtr reader);
210
+
211
+ /*
212
+ * Methods of the XmlTextReader
213
+ */
214
+ XMLPUBFUN int
215
+ xmlTextReaderClose (xmlTextReaderPtr reader);
216
+ XMLPUBFUN xmlChar *
217
+ xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,
218
+ int no);
219
+ XMLPUBFUN xmlChar *
220
+ xmlTextReaderGetAttribute (xmlTextReaderPtr reader,
221
+ const xmlChar *name);
222
+ XMLPUBFUN xmlChar *
223
+ xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,
224
+ const xmlChar *localName,
225
+ const xmlChar *namespaceURI);
226
+ XMLPUBFUN xmlParserInputBufferPtr
227
+ xmlTextReaderGetRemainder (xmlTextReaderPtr reader);
228
+ XMLPUBFUN xmlChar *
229
+ xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,
230
+ const xmlChar *prefix);
231
+ XMLPUBFUN int
232
+ xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,
233
+ int no);
234
+ XMLPUBFUN int
235
+ xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,
236
+ const xmlChar *name);
237
+ XMLPUBFUN int
238
+ xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
239
+ const xmlChar *localName,
240
+ const xmlChar *namespaceURI);
241
+ XMLPUBFUN int
242
+ xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);
243
+ XMLPUBFUN int
244
+ xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);
245
+ XMLPUBFUN int
246
+ xmlTextReaderMoveToElement (xmlTextReaderPtr reader);
247
+ XMLPUBFUN int
248
+ xmlTextReaderNormalization (xmlTextReaderPtr reader);
249
+ XMLPUBFUN const xmlChar *
250
+ xmlTextReaderConstEncoding (xmlTextReaderPtr reader);
251
+
252
+ /*
253
+ * Extensions
254
+ */
255
+ XMLPUBFUN int
256
+ xmlTextReaderSetParserProp (xmlTextReaderPtr reader,
257
+ int prop,
258
+ int value);
259
+ XMLPUBFUN int
260
+ xmlTextReaderGetParserProp (xmlTextReaderPtr reader,
261
+ int prop);
262
+ XMLPUBFUN xmlNodePtr
263
+ xmlTextReaderCurrentNode (xmlTextReaderPtr reader);
264
+
265
+ XMLPUBFUN int
266
+ xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);
267
+
268
+ XMLPUBFUN int
269
+ xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);
270
+
271
+ XMLPUBFUN xmlNodePtr
272
+ xmlTextReaderPreserve (xmlTextReaderPtr reader);
273
+ #ifdef LIBXML_PATTERN_ENABLED
274
+ XMLPUBFUN int
275
+ xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
276
+ const xmlChar *pattern,
277
+ const xmlChar **namespaces);
278
+ #endif /* LIBXML_PATTERN_ENABLED */
279
+ XMLPUBFUN xmlDocPtr
280
+ xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);
281
+ XMLPUBFUN xmlNodePtr
282
+ xmlTextReaderExpand (xmlTextReaderPtr reader);
283
+ XMLPUBFUN int
284
+ xmlTextReaderNext (xmlTextReaderPtr reader);
285
+ XMLPUBFUN int
286
+ xmlTextReaderNextSibling (xmlTextReaderPtr reader);
287
+ XMLPUBFUN int
288
+ xmlTextReaderIsValid (xmlTextReaderPtr reader);
289
+ #ifdef LIBXML_SCHEMAS_ENABLED
290
+ XMLPUBFUN int
291
+ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
292
+ const char *rng);
293
+ XMLPUBFUN int
294
+ xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
295
+ xmlRelaxNGValidCtxtPtr ctxt,
296
+ int options);
297
+
298
+ XMLPUBFUN int
299
+ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
300
+ xmlRelaxNGPtr schema);
301
+ XMLPUBFUN int
302
+ xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
303
+ const char *xsd);
304
+ XMLPUBFUN int
305
+ xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,
306
+ xmlSchemaValidCtxtPtr ctxt,
307
+ int options);
308
+ XMLPUBFUN int
309
+ xmlTextReaderSetSchema (xmlTextReaderPtr reader,
310
+ xmlSchemaPtr schema);
311
+ #endif
312
+ XMLPUBFUN const xmlChar *
313
+ xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
314
+ XMLPUBFUN int
315
+ xmlTextReaderStandalone (xmlTextReaderPtr reader);
316
+
317
+
318
+ /*
319
+ * Index lookup
320
+ */
321
+ XMLPUBFUN long
322
+ xmlTextReaderByteConsumed (xmlTextReaderPtr reader);
323
+
324
+ /*
325
+ * New more complete APIs for simpler creation and reuse of readers
326
+ */
327
+ XMLPUBFUN xmlTextReaderPtr
328
+ xmlReaderWalker (xmlDocPtr doc);
329
+ XMLPUBFUN xmlTextReaderPtr
330
+ xmlReaderForDoc (const xmlChar * cur,
331
+ const char *URL,
332
+ const char *encoding,
333
+ int options);
334
+ XMLPUBFUN xmlTextReaderPtr
335
+ xmlReaderForFile (const char *filename,
336
+ const char *encoding,
337
+ int options);
338
+ XMLPUBFUN xmlTextReaderPtr
339
+ xmlReaderForMemory (const char *buffer,
340
+ int size,
341
+ const char *URL,
342
+ const char *encoding,
343
+ int options);
344
+ XMLPUBFUN xmlTextReaderPtr
345
+ xmlReaderForFd (int fd,
346
+ const char *URL,
347
+ const char *encoding,
348
+ int options);
349
+ XMLPUBFUN xmlTextReaderPtr
350
+ xmlReaderForIO (xmlInputReadCallback ioread,
351
+ xmlInputCloseCallback ioclose,
352
+ void *ioctx,
353
+ const char *URL,
354
+ const char *encoding,
355
+ int options);
356
+
357
+ XMLPUBFUN int
358
+ xmlReaderNewWalker (xmlTextReaderPtr reader,
359
+ xmlDocPtr doc);
360
+ XMLPUBFUN int
361
+ xmlReaderNewDoc (xmlTextReaderPtr reader,
362
+ const xmlChar * cur,
363
+ const char *URL,
364
+ const char *encoding,
365
+ int options);
366
+ XMLPUBFUN int
367
+ xmlReaderNewFile (xmlTextReaderPtr reader,
368
+ const char *filename,
369
+ const char *encoding,
370
+ int options);
371
+ XMLPUBFUN int
372
+ xmlReaderNewMemory (xmlTextReaderPtr reader,
373
+ const char *buffer,
374
+ int size,
375
+ const char *URL,
376
+ const char *encoding,
377
+ int options);
378
+ XMLPUBFUN int
379
+ xmlReaderNewFd (xmlTextReaderPtr reader,
380
+ int fd,
381
+ const char *URL,
382
+ const char *encoding,
383
+ int options);
384
+ XMLPUBFUN int
385
+ xmlReaderNewIO (xmlTextReaderPtr reader,
386
+ xmlInputReadCallback ioread,
387
+ xmlInputCloseCallback ioclose,
388
+ void *ioctx,
389
+ const char *URL,
390
+ const char *encoding,
391
+ int options);
392
+ /*
393
+ * Error handling extensions
394
+ */
395
+ typedef void * xmlTextReaderLocatorPtr;
396
+
397
+ /**
398
+ * xmlTextReaderErrorFunc:
399
+ * @arg: the user argument
400
+ * @msg: the message
401
+ * @severity: the severity of the error
402
+ * @locator: a locator indicating where the error occurred
403
+ *
404
+ * Signature of an error callback from a reader parser
405
+ */
406
+ typedef void (*xmlTextReaderErrorFunc)(void *arg,
407
+ const char *msg,
408
+ xmlParserSeverities severity,
409
+ xmlTextReaderLocatorPtr locator);
410
+ XMLPUBFUN int
411
+ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
412
+ XMLPUBFUN xmlChar *
413
+ xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
414
+ XMLPUBFUN void
415
+ xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
416
+ xmlTextReaderErrorFunc f,
417
+ void *arg);
418
+ XMLPUBFUN void
419
+ xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
420
+ xmlStructuredErrorFunc f,
421
+ void *arg);
422
+ XMLPUBFUN void
423
+ xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
424
+ xmlTextReaderErrorFunc *f,
425
+ void **arg);
426
+
427
+ #endif /* LIBXML_READER_ENABLED */
428
+
429
+ #ifdef __cplusplus
430
+ }
431
+ #endif
432
+
433
+ #endif /* __XML_XMLREADER_H__ */
434
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlsave.h ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: the XML document serializer
3
+ * Description: API to save document or subtree of document
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Daniel Veillard
8
+ */
9
+
10
+ #ifndef __XML_XMLSAVE_H__
11
+ #define __XML_XMLSAVE_H__
12
+
13
+ #include <libxml/xmlversion.h>
14
+ #include <libxml/tree.h>
15
+ #include <libxml/encoding.h>
16
+ #include <libxml/xmlIO.h>
17
+
18
+ #ifdef LIBXML_OUTPUT_ENABLED
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
22
+
23
+ /**
24
+ * xmlSaveOption:
25
+ *
26
+ * This is the set of XML save options that can be passed down
27
+ * to the xmlSaveToFd() and similar calls.
28
+ */
29
+ typedef enum {
30
+ XML_SAVE_FORMAT = 1<<0, /* format save output */
31
+ XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */
32
+ XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */
33
+ XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */
34
+ XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */
35
+ XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */
36
+ XML_SAVE_AS_HTML = 1<<6, /* force HTML serialization on XML doc */
37
+ XML_SAVE_WSNONSIG = 1<<7 /* format with non-significant whitespace */
38
+ } xmlSaveOption;
39
+
40
+
41
+ typedef struct _xmlSaveCtxt xmlSaveCtxt;
42
+ typedef xmlSaveCtxt *xmlSaveCtxtPtr;
43
+
44
+ XMLPUBFUN xmlSaveCtxtPtr
45
+ xmlSaveToFd (int fd,
46
+ const char *encoding,
47
+ int options);
48
+ XMLPUBFUN xmlSaveCtxtPtr
49
+ xmlSaveToFilename (const char *filename,
50
+ const char *encoding,
51
+ int options);
52
+
53
+ XMLPUBFUN xmlSaveCtxtPtr
54
+ xmlSaveToBuffer (xmlBufferPtr buffer,
55
+ const char *encoding,
56
+ int options);
57
+
58
+ XMLPUBFUN xmlSaveCtxtPtr
59
+ xmlSaveToIO (xmlOutputWriteCallback iowrite,
60
+ xmlOutputCloseCallback ioclose,
61
+ void *ioctx,
62
+ const char *encoding,
63
+ int options);
64
+
65
+ XMLPUBFUN long
66
+ xmlSaveDoc (xmlSaveCtxtPtr ctxt,
67
+ xmlDocPtr doc);
68
+ XMLPUBFUN long
69
+ xmlSaveTree (xmlSaveCtxtPtr ctxt,
70
+ xmlNodePtr node);
71
+
72
+ XMLPUBFUN int
73
+ xmlSaveFlush (xmlSaveCtxtPtr ctxt);
74
+ XMLPUBFUN int
75
+ xmlSaveClose (xmlSaveCtxtPtr ctxt);
76
+ XMLPUBFUN int
77
+ xmlSaveSetEscape (xmlSaveCtxtPtr ctxt,
78
+ xmlCharEncodingOutputFunc escape);
79
+ XMLPUBFUN int
80
+ xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt,
81
+ xmlCharEncodingOutputFunc escape);
82
+
83
+ XMLPUBFUN int
84
+ xmlThrDefIndentTreeOutput(int v);
85
+ XMLPUBFUN const char *
86
+ xmlThrDefTreeIndentString(const char * v);
87
+ XMLPUBFUN int
88
+ xmlThrDefSaveNoEmptyTags(int v);
89
+
90
+ #ifdef __cplusplus
91
+ }
92
+ #endif
93
+
94
+ #endif /* LIBXML_OUTPUT_ENABLED */
95
+ #endif /* __XML_XMLSAVE_H__ */
96
+
97
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlschemas.h ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: incomplete XML Schemas structure implementation
3
+ * Description: interface to the XML Schemas handling and schema validity
4
+ * checking, it is incomplete right now.
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+
12
+ #ifndef __XML_SCHEMA_H__
13
+ #define __XML_SCHEMA_H__
14
+
15
+ #include <libxml/xmlversion.h>
16
+
17
+ #ifdef LIBXML_SCHEMAS_ENABLED
18
+
19
+ #include <stdio.h>
20
+ #include <libxml/encoding.h>
21
+ #include <libxml/tree.h>
22
+ #include <libxml/xmlerror.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ /**
29
+ * This error codes are obsolete; not used any more.
30
+ */
31
+ typedef enum {
32
+ XML_SCHEMAS_ERR_OK = 0,
33
+ XML_SCHEMAS_ERR_NOROOT = 1,
34
+ XML_SCHEMAS_ERR_UNDECLAREDELEM,
35
+ XML_SCHEMAS_ERR_NOTTOPLEVEL,
36
+ XML_SCHEMAS_ERR_MISSING,
37
+ XML_SCHEMAS_ERR_WRONGELEM,
38
+ XML_SCHEMAS_ERR_NOTYPE,
39
+ XML_SCHEMAS_ERR_NOROLLBACK,
40
+ XML_SCHEMAS_ERR_ISABSTRACT,
41
+ XML_SCHEMAS_ERR_NOTEMPTY,
42
+ XML_SCHEMAS_ERR_ELEMCONT,
43
+ XML_SCHEMAS_ERR_HAVEDEFAULT,
44
+ XML_SCHEMAS_ERR_NOTNILLABLE,
45
+ XML_SCHEMAS_ERR_EXTRACONTENT,
46
+ XML_SCHEMAS_ERR_INVALIDATTR,
47
+ XML_SCHEMAS_ERR_INVALIDELEM,
48
+ XML_SCHEMAS_ERR_NOTDETERMINIST,
49
+ XML_SCHEMAS_ERR_CONSTRUCT,
50
+ XML_SCHEMAS_ERR_INTERNAL,
51
+ XML_SCHEMAS_ERR_NOTSIMPLE,
52
+ XML_SCHEMAS_ERR_ATTRUNKNOWN,
53
+ XML_SCHEMAS_ERR_ATTRINVALID,
54
+ XML_SCHEMAS_ERR_VALUE,
55
+ XML_SCHEMAS_ERR_FACET,
56
+ XML_SCHEMAS_ERR_,
57
+ XML_SCHEMAS_ERR_XXX
58
+ } xmlSchemaValidError;
59
+
60
+ /*
61
+ * ATTENTION: Change xmlSchemaSetValidOptions's check
62
+ * for invalid values, if adding to the validation
63
+ * options below.
64
+ */
65
+ /**
66
+ * xmlSchemaValidOption:
67
+ *
68
+ * This is the set of XML Schema validation options.
69
+ */
70
+ typedef enum {
71
+ XML_SCHEMA_VAL_VC_I_CREATE = 1<<0
72
+ /* Default/fixed: create an attribute node
73
+ * or an element's text node on the instance.
74
+ */
75
+ } xmlSchemaValidOption;
76
+
77
+ /*
78
+ XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,
79
+ * assemble schemata using
80
+ * xsi:schemaLocation and
81
+ * xsi:noNamespaceSchemaLocation
82
+ */
83
+
84
+ /**
85
+ * The schemas related types are kept internal
86
+ */
87
+ typedef struct _xmlSchema xmlSchema;
88
+ typedef xmlSchema *xmlSchemaPtr;
89
+
90
+ /**
91
+ * xmlSchemaValidityErrorFunc:
92
+ * @ctx: the validation context
93
+ * @msg: the message
94
+ * @...: extra arguments
95
+ *
96
+ * Signature of an error callback from an XSD validation
97
+ */
98
+ typedef void (*xmlSchemaValidityErrorFunc)
99
+ (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
100
+
101
+ /**
102
+ * xmlSchemaValidityWarningFunc:
103
+ * @ctx: the validation context
104
+ * @msg: the message
105
+ * @...: extra arguments
106
+ *
107
+ * Signature of a warning callback from an XSD validation
108
+ */
109
+ typedef void (*xmlSchemaValidityWarningFunc)
110
+ (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
111
+
112
+ /**
113
+ * A schemas validation context
114
+ */
115
+ typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
116
+ typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
117
+
118
+ typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
119
+ typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
120
+
121
+ /**
122
+ * xmlSchemaValidityLocatorFunc:
123
+ * @ctx: user provided context
124
+ * @file: returned file information
125
+ * @line: returned line information
126
+ *
127
+ * A schemas validation locator, a callback called by the validator.
128
+ * This is used when file or node information are not available
129
+ * to find out what file and line number are affected
130
+ *
131
+ * Returns: 0 in case of success and -1 in case of error
132
+ */
133
+
134
+ typedef int (*xmlSchemaValidityLocatorFunc) (void *ctx,
135
+ const char **file, unsigned long *line);
136
+
137
+ /*
138
+ * Interfaces for parsing.
139
+ */
140
+ XMLPUBFUN xmlSchemaParserCtxtPtr
141
+ xmlSchemaNewParserCtxt (const char *URL);
142
+ XMLPUBFUN xmlSchemaParserCtxtPtr
143
+ xmlSchemaNewMemParserCtxt (const char *buffer,
144
+ int size);
145
+ XMLPUBFUN xmlSchemaParserCtxtPtr
146
+ xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
147
+ XMLPUBFUN void
148
+ xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
149
+ XMLPUBFUN void
150
+ xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
151
+ xmlSchemaValidityErrorFunc err,
152
+ xmlSchemaValidityWarningFunc warn,
153
+ void *ctx);
154
+ XMLPUBFUN void
155
+ xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
156
+ xmlStructuredErrorFunc serror,
157
+ void *ctx);
158
+ XMLPUBFUN int
159
+ xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
160
+ xmlSchemaValidityErrorFunc * err,
161
+ xmlSchemaValidityWarningFunc * warn,
162
+ void **ctx);
163
+ XMLPUBFUN int
164
+ xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
165
+
166
+ XMLPUBFUN xmlSchemaPtr
167
+ xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
168
+ XMLPUBFUN void
169
+ xmlSchemaFree (xmlSchemaPtr schema);
170
+ #ifdef LIBXML_OUTPUT_ENABLED
171
+ XMLPUBFUN void
172
+ xmlSchemaDump (FILE *output,
173
+ xmlSchemaPtr schema);
174
+ #endif /* LIBXML_OUTPUT_ENABLED */
175
+ /*
176
+ * Interfaces for validating
177
+ */
178
+ XMLPUBFUN void
179
+ xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
180
+ xmlSchemaValidityErrorFunc err,
181
+ xmlSchemaValidityWarningFunc warn,
182
+ void *ctx);
183
+ XMLPUBFUN void
184
+ xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
185
+ xmlStructuredErrorFunc serror,
186
+ void *ctx);
187
+ XMLPUBFUN int
188
+ xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
189
+ xmlSchemaValidityErrorFunc *err,
190
+ xmlSchemaValidityWarningFunc *warn,
191
+ void **ctx);
192
+ XMLPUBFUN int
193
+ xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
194
+ int options);
195
+ XMLPUBFUN void
196
+ xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
197
+ const char *filename);
198
+ XMLPUBFUN int
199
+ xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
200
+
201
+ XMLPUBFUN xmlSchemaValidCtxtPtr
202
+ xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
203
+ XMLPUBFUN void
204
+ xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
205
+ XMLPUBFUN int
206
+ xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
207
+ xmlDocPtr instance);
208
+ XMLPUBFUN int
209
+ xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
210
+ xmlNodePtr elem);
211
+ XMLPUBFUN int
212
+ xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
213
+ xmlParserInputBufferPtr input,
214
+ xmlCharEncoding enc,
215
+ xmlSAXHandlerPtr sax,
216
+ void *user_data);
217
+ XMLPUBFUN int
218
+ xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
219
+ const char * filename,
220
+ int options);
221
+
222
+ XMLPUBFUN xmlParserCtxtPtr
223
+ xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
224
+
225
+ /*
226
+ * Interface to insert Schemas SAX validation in a SAX stream
227
+ */
228
+ typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
229
+ typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
230
+
231
+ XMLPUBFUN xmlSchemaSAXPlugPtr
232
+ xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
233
+ xmlSAXHandlerPtr *sax,
234
+ void **user_data);
235
+ XMLPUBFUN int
236
+ xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
237
+
238
+
239
+ XMLPUBFUN void
240
+ xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
241
+ xmlSchemaValidityLocatorFunc f,
242
+ void *ctxt);
243
+
244
+ #ifdef __cplusplus
245
+ }
246
+ #endif
247
+
248
+ #endif /* LIBXML_SCHEMAS_ENABLED */
249
+ #endif /* __XML_SCHEMA_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlschemastypes.h ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: implementation of XML Schema Datatypes
3
+ * Description: module providing the XML Schema Datatypes implementation
4
+ * both definition and validity checking
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+
12
+ #ifndef __XML_SCHEMA_TYPES_H__
13
+ #define __XML_SCHEMA_TYPES_H__
14
+
15
+ #include <libxml/xmlversion.h>
16
+
17
+ #ifdef LIBXML_SCHEMAS_ENABLED
18
+
19
+ #include <libxml/schemasInternals.h>
20
+ #include <libxml/xmlschemas.h>
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ typedef enum {
27
+ XML_SCHEMA_WHITESPACE_UNKNOWN = 0,
28
+ XML_SCHEMA_WHITESPACE_PRESERVE = 1,
29
+ XML_SCHEMA_WHITESPACE_REPLACE = 2,
30
+ XML_SCHEMA_WHITESPACE_COLLAPSE = 3
31
+ } xmlSchemaWhitespaceValueType;
32
+
33
+ XMLPUBFUN int
34
+ xmlSchemaInitTypes (void);
35
+ XML_DEPRECATED
36
+ XMLPUBFUN void
37
+ xmlSchemaCleanupTypes (void);
38
+ XMLPUBFUN xmlSchemaTypePtr
39
+ xmlSchemaGetPredefinedType (const xmlChar *name,
40
+ const xmlChar *ns);
41
+ XMLPUBFUN int
42
+ xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type,
43
+ const xmlChar *value,
44
+ xmlSchemaValPtr *val);
45
+ XMLPUBFUN int
46
+ xmlSchemaValPredefTypeNode (xmlSchemaTypePtr type,
47
+ const xmlChar *value,
48
+ xmlSchemaValPtr *val,
49
+ xmlNodePtr node);
50
+ XMLPUBFUN int
51
+ xmlSchemaValidateFacet (xmlSchemaTypePtr base,
52
+ xmlSchemaFacetPtr facet,
53
+ const xmlChar *value,
54
+ xmlSchemaValPtr val);
55
+ XMLPUBFUN int
56
+ xmlSchemaValidateFacetWhtsp (xmlSchemaFacetPtr facet,
57
+ xmlSchemaWhitespaceValueType fws,
58
+ xmlSchemaValType valType,
59
+ const xmlChar *value,
60
+ xmlSchemaValPtr val,
61
+ xmlSchemaWhitespaceValueType ws);
62
+ XMLPUBFUN void
63
+ xmlSchemaFreeValue (xmlSchemaValPtr val);
64
+ XMLPUBFUN xmlSchemaFacetPtr
65
+ xmlSchemaNewFacet (void);
66
+ XMLPUBFUN int
67
+ xmlSchemaCheckFacet (xmlSchemaFacetPtr facet,
68
+ xmlSchemaTypePtr typeDecl,
69
+ xmlSchemaParserCtxtPtr ctxt,
70
+ const xmlChar *name);
71
+ XMLPUBFUN void
72
+ xmlSchemaFreeFacet (xmlSchemaFacetPtr facet);
73
+ XMLPUBFUN int
74
+ xmlSchemaCompareValues (xmlSchemaValPtr x,
75
+ xmlSchemaValPtr y);
76
+ XMLPUBFUN xmlSchemaTypePtr
77
+ xmlSchemaGetBuiltInListSimpleTypeItemType (xmlSchemaTypePtr type);
78
+ XMLPUBFUN int
79
+ xmlSchemaValidateListSimpleTypeFacet (xmlSchemaFacetPtr facet,
80
+ const xmlChar *value,
81
+ unsigned long actualLen,
82
+ unsigned long *expectedLen);
83
+ XMLPUBFUN xmlSchemaTypePtr
84
+ xmlSchemaGetBuiltInType (xmlSchemaValType type);
85
+ XMLPUBFUN int
86
+ xmlSchemaIsBuiltInTypeFacet (xmlSchemaTypePtr type,
87
+ int facetType);
88
+ XMLPUBFUN xmlChar *
89
+ xmlSchemaCollapseString (const xmlChar *value);
90
+ XMLPUBFUN xmlChar *
91
+ xmlSchemaWhiteSpaceReplace (const xmlChar *value);
92
+ XMLPUBFUN unsigned long
93
+ xmlSchemaGetFacetValueAsULong (xmlSchemaFacetPtr facet);
94
+ XMLPUBFUN int
95
+ xmlSchemaValidateLengthFacet (xmlSchemaTypePtr type,
96
+ xmlSchemaFacetPtr facet,
97
+ const xmlChar *value,
98
+ xmlSchemaValPtr val,
99
+ unsigned long *length);
100
+ XMLPUBFUN int
101
+ xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet,
102
+ xmlSchemaValType valType,
103
+ const xmlChar *value,
104
+ xmlSchemaValPtr val,
105
+ unsigned long *length,
106
+ xmlSchemaWhitespaceValueType ws);
107
+ XMLPUBFUN int
108
+ xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type,
109
+ const xmlChar *value,
110
+ xmlSchemaValPtr *val,
111
+ xmlNodePtr node);
112
+ XMLPUBFUN int
113
+ xmlSchemaGetCanonValue (xmlSchemaValPtr val,
114
+ const xmlChar **retValue);
115
+ XMLPUBFUN int
116
+ xmlSchemaGetCanonValueWhtsp (xmlSchemaValPtr val,
117
+ const xmlChar **retValue,
118
+ xmlSchemaWhitespaceValueType ws);
119
+ XMLPUBFUN int
120
+ xmlSchemaValueAppend (xmlSchemaValPtr prev,
121
+ xmlSchemaValPtr cur);
122
+ XMLPUBFUN xmlSchemaValPtr
123
+ xmlSchemaValueGetNext (xmlSchemaValPtr cur);
124
+ XMLPUBFUN const xmlChar *
125
+ xmlSchemaValueGetAsString (xmlSchemaValPtr val);
126
+ XMLPUBFUN int
127
+ xmlSchemaValueGetAsBoolean (xmlSchemaValPtr val);
128
+ XMLPUBFUN xmlSchemaValPtr
129
+ xmlSchemaNewStringValue (xmlSchemaValType type,
130
+ const xmlChar *value);
131
+ XMLPUBFUN xmlSchemaValPtr
132
+ xmlSchemaNewNOTATIONValue (const xmlChar *name,
133
+ const xmlChar *ns);
134
+ XMLPUBFUN xmlSchemaValPtr
135
+ xmlSchemaNewQNameValue (const xmlChar *namespaceName,
136
+ const xmlChar *localName);
137
+ XMLPUBFUN int
138
+ xmlSchemaCompareValuesWhtsp (xmlSchemaValPtr x,
139
+ xmlSchemaWhitespaceValueType xws,
140
+ xmlSchemaValPtr y,
141
+ xmlSchemaWhitespaceValueType yws);
142
+ XMLPUBFUN xmlSchemaValPtr
143
+ xmlSchemaCopyValue (xmlSchemaValPtr val);
144
+ XMLPUBFUN xmlSchemaValType
145
+ xmlSchemaGetValType (xmlSchemaValPtr val);
146
+
147
+ #ifdef __cplusplus
148
+ }
149
+ #endif
150
+
151
+ #endif /* LIBXML_SCHEMAS_ENABLED */
152
+ #endif /* __XML_SCHEMA_TYPES_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlstring.h ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: set of routines to process strings
3
+ * Description: type and interfaces needed for the internal string handling
4
+ * of the library, especially UTF8 processing.
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+ #ifndef __XML_STRING_H__
12
+ #define __XML_STRING_H__
13
+
14
+ #include <stdarg.h>
15
+ #include <libxml/xmlversion.h>
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ /**
22
+ * xmlChar:
23
+ *
24
+ * This is a basic byte in an UTF-8 encoded string.
25
+ * It's unsigned allowing to pinpoint case where char * are assigned
26
+ * to xmlChar * (possibly making serialization back impossible).
27
+ */
28
+ typedef unsigned char xmlChar;
29
+
30
+ /**
31
+ * BAD_CAST:
32
+ *
33
+ * Macro to cast a string to an xmlChar * when one know its safe.
34
+ */
35
+ #define BAD_CAST (xmlChar *)
36
+
37
+ /*
38
+ * xmlChar handling
39
+ */
40
+ XMLPUBFUN xmlChar *
41
+ xmlStrdup (const xmlChar *cur);
42
+ XMLPUBFUN xmlChar *
43
+ xmlStrndup (const xmlChar *cur,
44
+ int len);
45
+ XMLPUBFUN xmlChar *
46
+ xmlCharStrndup (const char *cur,
47
+ int len);
48
+ XMLPUBFUN xmlChar *
49
+ xmlCharStrdup (const char *cur);
50
+ XMLPUBFUN xmlChar *
51
+ xmlStrsub (const xmlChar *str,
52
+ int start,
53
+ int len);
54
+ XMLPUBFUN const xmlChar *
55
+ xmlStrchr (const xmlChar *str,
56
+ xmlChar val);
57
+ XMLPUBFUN const xmlChar *
58
+ xmlStrstr (const xmlChar *str,
59
+ const xmlChar *val);
60
+ XMLPUBFUN const xmlChar *
61
+ xmlStrcasestr (const xmlChar *str,
62
+ const xmlChar *val);
63
+ XMLPUBFUN int
64
+ xmlStrcmp (const xmlChar *str1,
65
+ const xmlChar *str2);
66
+ XMLPUBFUN int
67
+ xmlStrncmp (const xmlChar *str1,
68
+ const xmlChar *str2,
69
+ int len);
70
+ XMLPUBFUN int
71
+ xmlStrcasecmp (const xmlChar *str1,
72
+ const xmlChar *str2);
73
+ XMLPUBFUN int
74
+ xmlStrncasecmp (const xmlChar *str1,
75
+ const xmlChar *str2,
76
+ int len);
77
+ XMLPUBFUN int
78
+ xmlStrEqual (const xmlChar *str1,
79
+ const xmlChar *str2);
80
+ XMLPUBFUN int
81
+ xmlStrQEqual (const xmlChar *pref,
82
+ const xmlChar *name,
83
+ const xmlChar *str);
84
+ XMLPUBFUN int
85
+ xmlStrlen (const xmlChar *str);
86
+ XMLPUBFUN xmlChar *
87
+ xmlStrcat (xmlChar *cur,
88
+ const xmlChar *add);
89
+ XMLPUBFUN xmlChar *
90
+ xmlStrncat (xmlChar *cur,
91
+ const xmlChar *add,
92
+ int len);
93
+ XMLPUBFUN xmlChar *
94
+ xmlStrncatNew (const xmlChar *str1,
95
+ const xmlChar *str2,
96
+ int len);
97
+ XMLPUBFUN int
98
+ xmlStrPrintf (xmlChar *buf,
99
+ int len,
100
+ const char *msg,
101
+ ...) LIBXML_ATTR_FORMAT(3,4);
102
+ XMLPUBFUN int
103
+ xmlStrVPrintf (xmlChar *buf,
104
+ int len,
105
+ const char *msg,
106
+ va_list ap) LIBXML_ATTR_FORMAT(3,0);
107
+
108
+ XMLPUBFUN int
109
+ xmlGetUTF8Char (const unsigned char *utf,
110
+ int *len);
111
+ XMLPUBFUN int
112
+ xmlCheckUTF8 (const unsigned char *utf);
113
+ XMLPUBFUN int
114
+ xmlUTF8Strsize (const xmlChar *utf,
115
+ int len);
116
+ XMLPUBFUN xmlChar *
117
+ xmlUTF8Strndup (const xmlChar *utf,
118
+ int len);
119
+ XMLPUBFUN const xmlChar *
120
+ xmlUTF8Strpos (const xmlChar *utf,
121
+ int pos);
122
+ XMLPUBFUN int
123
+ xmlUTF8Strloc (const xmlChar *utf,
124
+ const xmlChar *utfchar);
125
+ XMLPUBFUN xmlChar *
126
+ xmlUTF8Strsub (const xmlChar *utf,
127
+ int start,
128
+ int len);
129
+ XMLPUBFUN int
130
+ xmlUTF8Strlen (const xmlChar *utf);
131
+ XMLPUBFUN int
132
+ xmlUTF8Size (const xmlChar *utf);
133
+ XMLPUBFUN int
134
+ xmlUTF8Charcmp (const xmlChar *utf1,
135
+ const xmlChar *utf2);
136
+
137
+ #ifdef __cplusplus
138
+ }
139
+ #endif
140
+ #endif /* __XML_STRING_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxml/xmlwriter.h ADDED
@@ -0,0 +1,488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: text writing API for XML
3
+ * Description: text writing API for XML
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Alfred Mickautsch <[email protected]>
8
+ */
9
+
10
+ #ifndef __XML_XMLWRITER_H__
11
+ #define __XML_XMLWRITER_H__
12
+
13
+ #include <libxml/xmlversion.h>
14
+
15
+ #ifdef LIBXML_WRITER_ENABLED
16
+
17
+ #include <stdarg.h>
18
+ #include <libxml/xmlIO.h>
19
+ #include <libxml/list.h>
20
+ #include <libxml/xmlstring.h>
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ typedef struct _xmlTextWriter xmlTextWriter;
27
+ typedef xmlTextWriter *xmlTextWriterPtr;
28
+
29
+ /*
30
+ * Constructors & Destructor
31
+ */
32
+ XMLPUBFUN xmlTextWriterPtr
33
+ xmlNewTextWriter(xmlOutputBufferPtr out);
34
+ XMLPUBFUN xmlTextWriterPtr
35
+ xmlNewTextWriterFilename(const char *uri, int compression);
36
+ XMLPUBFUN xmlTextWriterPtr
37
+ xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);
38
+ XMLPUBFUN xmlTextWriterPtr
39
+ xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);
40
+ XMLPUBFUN xmlTextWriterPtr
41
+ xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);
42
+ XMLPUBFUN xmlTextWriterPtr
43
+ xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node,
44
+ int compression);
45
+ XMLPUBFUN void xmlFreeTextWriter(xmlTextWriterPtr writer);
46
+
47
+ /*
48
+ * Functions
49
+ */
50
+
51
+
52
+ /*
53
+ * Document
54
+ */
55
+ XMLPUBFUN int
56
+ xmlTextWriterStartDocument(xmlTextWriterPtr writer,
57
+ const char *version,
58
+ const char *encoding,
59
+ const char *standalone);
60
+ XMLPUBFUN int xmlTextWriterEndDocument(xmlTextWriterPtr
61
+ writer);
62
+
63
+ /*
64
+ * Comments
65
+ */
66
+ XMLPUBFUN int xmlTextWriterStartComment(xmlTextWriterPtr
67
+ writer);
68
+ XMLPUBFUN int xmlTextWriterEndComment(xmlTextWriterPtr writer);
69
+ XMLPUBFUN int
70
+ xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
71
+ const char *format, ...)
72
+ LIBXML_ATTR_FORMAT(2,3);
73
+ XMLPUBFUN int
74
+ xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
75
+ const char *format,
76
+ va_list argptr)
77
+ LIBXML_ATTR_FORMAT(2,0);
78
+ XMLPUBFUN int xmlTextWriterWriteComment(xmlTextWriterPtr
79
+ writer,
80
+ const xmlChar *
81
+ content);
82
+
83
+ /*
84
+ * Elements
85
+ */
86
+ XMLPUBFUN int
87
+ xmlTextWriterStartElement(xmlTextWriterPtr writer,
88
+ const xmlChar * name);
89
+ XMLPUBFUN int xmlTextWriterStartElementNS(xmlTextWriterPtr
90
+ writer,
91
+ const xmlChar *
92
+ prefix,
93
+ const xmlChar * name,
94
+ const xmlChar *
95
+ namespaceURI);
96
+ XMLPUBFUN int xmlTextWriterEndElement(xmlTextWriterPtr writer);
97
+ XMLPUBFUN int xmlTextWriterFullEndElement(xmlTextWriterPtr
98
+ writer);
99
+
100
+ /*
101
+ * Elements conveniency functions
102
+ */
103
+ XMLPUBFUN int
104
+ xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
105
+ const xmlChar * name,
106
+ const char *format, ...)
107
+ LIBXML_ATTR_FORMAT(3,4);
108
+ XMLPUBFUN int
109
+ xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
110
+ const xmlChar * name,
111
+ const char *format,
112
+ va_list argptr)
113
+ LIBXML_ATTR_FORMAT(3,0);
114
+ XMLPUBFUN int xmlTextWriterWriteElement(xmlTextWriterPtr
115
+ writer,
116
+ const xmlChar * name,
117
+ const xmlChar *
118
+ content);
119
+ XMLPUBFUN int
120
+ xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
121
+ const xmlChar * prefix,
122
+ const xmlChar * name,
123
+ const xmlChar * namespaceURI,
124
+ const char *format, ...)
125
+ LIBXML_ATTR_FORMAT(5,6);
126
+ XMLPUBFUN int
127
+ xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
128
+ const xmlChar * prefix,
129
+ const xmlChar * name,
130
+ const xmlChar * namespaceURI,
131
+ const char *format,
132
+ va_list argptr)
133
+ LIBXML_ATTR_FORMAT(5,0);
134
+ XMLPUBFUN int xmlTextWriterWriteElementNS(xmlTextWriterPtr
135
+ writer,
136
+ const xmlChar *
137
+ prefix,
138
+ const xmlChar * name,
139
+ const xmlChar *
140
+ namespaceURI,
141
+ const xmlChar *
142
+ content);
143
+
144
+ /*
145
+ * Text
146
+ */
147
+ XMLPUBFUN int
148
+ xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
149
+ const char *format, ...)
150
+ LIBXML_ATTR_FORMAT(2,3);
151
+ XMLPUBFUN int
152
+ xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
153
+ const char *format, va_list argptr)
154
+ LIBXML_ATTR_FORMAT(2,0);
155
+ XMLPUBFUN int
156
+ xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
157
+ const xmlChar * content, int len);
158
+ XMLPUBFUN int
159
+ xmlTextWriterWriteRaw(xmlTextWriterPtr writer,
160
+ const xmlChar * content);
161
+ XMLPUBFUN int xmlTextWriterWriteFormatString(xmlTextWriterPtr
162
+ writer,
163
+ const char
164
+ *format, ...)
165
+ LIBXML_ATTR_FORMAT(2,3);
166
+ XMLPUBFUN int xmlTextWriterWriteVFormatString(xmlTextWriterPtr
167
+ writer,
168
+ const char
169
+ *format,
170
+ va_list argptr)
171
+ LIBXML_ATTR_FORMAT(2,0);
172
+ XMLPUBFUN int xmlTextWriterWriteString(xmlTextWriterPtr writer,
173
+ const xmlChar *
174
+ content);
175
+ XMLPUBFUN int xmlTextWriterWriteBase64(xmlTextWriterPtr writer,
176
+ const char *data,
177
+ int start, int len);
178
+ XMLPUBFUN int xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,
179
+ const char *data,
180
+ int start, int len);
181
+
182
+ /*
183
+ * Attributes
184
+ */
185
+ XMLPUBFUN int
186
+ xmlTextWriterStartAttribute(xmlTextWriterPtr writer,
187
+ const xmlChar * name);
188
+ XMLPUBFUN int xmlTextWriterStartAttributeNS(xmlTextWriterPtr
189
+ writer,
190
+ const xmlChar *
191
+ prefix,
192
+ const xmlChar *
193
+ name,
194
+ const xmlChar *
195
+ namespaceURI);
196
+ XMLPUBFUN int xmlTextWriterEndAttribute(xmlTextWriterPtr
197
+ writer);
198
+
199
+ /*
200
+ * Attributes conveniency functions
201
+ */
202
+ XMLPUBFUN int
203
+ xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
204
+ const xmlChar * name,
205
+ const char *format, ...)
206
+ LIBXML_ATTR_FORMAT(3,4);
207
+ XMLPUBFUN int
208
+ xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
209
+ const xmlChar * name,
210
+ const char *format,
211
+ va_list argptr)
212
+ LIBXML_ATTR_FORMAT(3,0);
213
+ XMLPUBFUN int xmlTextWriterWriteAttribute(xmlTextWriterPtr
214
+ writer,
215
+ const xmlChar * name,
216
+ const xmlChar *
217
+ content);
218
+ XMLPUBFUN int
219
+ xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
220
+ const xmlChar * prefix,
221
+ const xmlChar * name,
222
+ const xmlChar * namespaceURI,
223
+ const char *format, ...)
224
+ LIBXML_ATTR_FORMAT(5,6);
225
+ XMLPUBFUN int
226
+ xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
227
+ const xmlChar * prefix,
228
+ const xmlChar * name,
229
+ const xmlChar * namespaceURI,
230
+ const char *format,
231
+ va_list argptr)
232
+ LIBXML_ATTR_FORMAT(5,0);
233
+ XMLPUBFUN int xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
234
+ writer,
235
+ const xmlChar *
236
+ prefix,
237
+ const xmlChar *
238
+ name,
239
+ const xmlChar *
240
+ namespaceURI,
241
+ const xmlChar *
242
+ content);
243
+
244
+ /*
245
+ * PI's
246
+ */
247
+ XMLPUBFUN int
248
+ xmlTextWriterStartPI(xmlTextWriterPtr writer,
249
+ const xmlChar * target);
250
+ XMLPUBFUN int xmlTextWriterEndPI(xmlTextWriterPtr writer);
251
+
252
+ /*
253
+ * PI conveniency functions
254
+ */
255
+ XMLPUBFUN int
256
+ xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
257
+ const xmlChar * target,
258
+ const char *format, ...)
259
+ LIBXML_ATTR_FORMAT(3,4);
260
+ XMLPUBFUN int
261
+ xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
262
+ const xmlChar * target,
263
+ const char *format, va_list argptr)
264
+ LIBXML_ATTR_FORMAT(3,0);
265
+ XMLPUBFUN int
266
+ xmlTextWriterWritePI(xmlTextWriterPtr writer,
267
+ const xmlChar * target,
268
+ const xmlChar * content);
269
+
270
+ /**
271
+ * xmlTextWriterWriteProcessingInstruction:
272
+ *
273
+ * This macro maps to xmlTextWriterWritePI
274
+ */
275
+ #define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI
276
+
277
+ /*
278
+ * CDATA
279
+ */
280
+ XMLPUBFUN int xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
281
+ XMLPUBFUN int xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
282
+
283
+ /*
284
+ * CDATA conveniency functions
285
+ */
286
+ XMLPUBFUN int
287
+ xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
288
+ const char *format, ...)
289
+ LIBXML_ATTR_FORMAT(2,3);
290
+ XMLPUBFUN int
291
+ xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
292
+ const char *format, va_list argptr)
293
+ LIBXML_ATTR_FORMAT(2,0);
294
+ XMLPUBFUN int
295
+ xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
296
+ const xmlChar * content);
297
+
298
+ /*
299
+ * DTD
300
+ */
301
+ XMLPUBFUN int
302
+ xmlTextWriterStartDTD(xmlTextWriterPtr writer,
303
+ const xmlChar * name,
304
+ const xmlChar * pubid,
305
+ const xmlChar * sysid);
306
+ XMLPUBFUN int xmlTextWriterEndDTD(xmlTextWriterPtr writer);
307
+
308
+ /*
309
+ * DTD conveniency functions
310
+ */
311
+ XMLPUBFUN int
312
+ xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,
313
+ const xmlChar * name,
314
+ const xmlChar * pubid,
315
+ const xmlChar * sysid,
316
+ const char *format, ...)
317
+ LIBXML_ATTR_FORMAT(5,6);
318
+ XMLPUBFUN int
319
+ xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
320
+ const xmlChar * name,
321
+ const xmlChar * pubid,
322
+ const xmlChar * sysid,
323
+ const char *format, va_list argptr)
324
+ LIBXML_ATTR_FORMAT(5,0);
325
+ XMLPUBFUN int
326
+ xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
327
+ const xmlChar * name,
328
+ const xmlChar * pubid,
329
+ const xmlChar * sysid,
330
+ const xmlChar * subset);
331
+
332
+ /**
333
+ * xmlTextWriterWriteDocType:
334
+ *
335
+ * this macro maps to xmlTextWriterWriteDTD
336
+ */
337
+ #define xmlTextWriterWriteDocType xmlTextWriterWriteDTD
338
+
339
+ /*
340
+ * DTD element definition
341
+ */
342
+ XMLPUBFUN int
343
+ xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,
344
+ const xmlChar * name);
345
+ XMLPUBFUN int xmlTextWriterEndDTDElement(xmlTextWriterPtr
346
+ writer);
347
+
348
+ /*
349
+ * DTD element definition conveniency functions
350
+ */
351
+ XMLPUBFUN int
352
+ xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
353
+ const xmlChar * name,
354
+ const char *format, ...)
355
+ LIBXML_ATTR_FORMAT(3,4);
356
+ XMLPUBFUN int
357
+ xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
358
+ const xmlChar * name,
359
+ const char *format,
360
+ va_list argptr)
361
+ LIBXML_ATTR_FORMAT(3,0);
362
+ XMLPUBFUN int xmlTextWriterWriteDTDElement(xmlTextWriterPtr
363
+ writer,
364
+ const xmlChar *
365
+ name,
366
+ const xmlChar *
367
+ content);
368
+
369
+ /*
370
+ * DTD attribute list definition
371
+ */
372
+ XMLPUBFUN int
373
+ xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,
374
+ const xmlChar * name);
375
+ XMLPUBFUN int xmlTextWriterEndDTDAttlist(xmlTextWriterPtr
376
+ writer);
377
+
378
+ /*
379
+ * DTD attribute list definition conveniency functions
380
+ */
381
+ XMLPUBFUN int
382
+ xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
383
+ const xmlChar * name,
384
+ const char *format, ...)
385
+ LIBXML_ATTR_FORMAT(3,4);
386
+ XMLPUBFUN int
387
+ xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
388
+ const xmlChar * name,
389
+ const char *format,
390
+ va_list argptr)
391
+ LIBXML_ATTR_FORMAT(3,0);
392
+ XMLPUBFUN int xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
393
+ writer,
394
+ const xmlChar *
395
+ name,
396
+ const xmlChar *
397
+ content);
398
+
399
+ /*
400
+ * DTD entity definition
401
+ */
402
+ XMLPUBFUN int
403
+ xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
404
+ int pe, const xmlChar * name);
405
+ XMLPUBFUN int xmlTextWriterEndDTDEntity(xmlTextWriterPtr
406
+ writer);
407
+
408
+ /*
409
+ * DTD entity definition conveniency functions
410
+ */
411
+ XMLPUBFUN int
412
+ xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
413
+ int pe,
414
+ const xmlChar * name,
415
+ const char *format, ...)
416
+ LIBXML_ATTR_FORMAT(4,5);
417
+ XMLPUBFUN int
418
+ xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
419
+ int pe,
420
+ const xmlChar * name,
421
+ const char *format,
422
+ va_list argptr)
423
+ LIBXML_ATTR_FORMAT(4,0);
424
+ XMLPUBFUN int
425
+ xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
426
+ int pe,
427
+ const xmlChar * name,
428
+ const xmlChar * content);
429
+ XMLPUBFUN int
430
+ xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,
431
+ int pe,
432
+ const xmlChar * name,
433
+ const xmlChar * pubid,
434
+ const xmlChar * sysid,
435
+ const xmlChar * ndataid);
436
+ XMLPUBFUN int
437
+ xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr
438
+ writer,
439
+ const xmlChar * pubid,
440
+ const xmlChar * sysid,
441
+ const xmlChar *
442
+ ndataid);
443
+ XMLPUBFUN int xmlTextWriterWriteDTDEntity(xmlTextWriterPtr
444
+ writer, int pe,
445
+ const xmlChar * name,
446
+ const xmlChar *
447
+ pubid,
448
+ const xmlChar *
449
+ sysid,
450
+ const xmlChar *
451
+ ndataid,
452
+ const xmlChar *
453
+ content);
454
+
455
+ /*
456
+ * DTD notation definition
457
+ */
458
+ XMLPUBFUN int
459
+ xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,
460
+ const xmlChar * name,
461
+ const xmlChar * pubid,
462
+ const xmlChar * sysid);
463
+
464
+ /*
465
+ * Indentation
466
+ */
467
+ XMLPUBFUN int
468
+ xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);
469
+ XMLPUBFUN int
470
+ xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
471
+ const xmlChar * str);
472
+
473
+ XMLPUBFUN int
474
+ xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);
475
+
476
+
477
+ /*
478
+ * misc
479
+ */
480
+ XMLPUBFUN int xmlTextWriterFlush(xmlTextWriterPtr writer);
481
+
482
+ #ifdef __cplusplus
483
+ }
484
+ #endif
485
+
486
+ #endif /* LIBXML_WRITER_ENABLED */
487
+
488
+ #endif /* __XML_XMLWRITER_H__ */
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/__init__.py ADDED
File without changes
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (194 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/attributes.h ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the XSLT attribute handling
3
+ * Description: this module handles the specificities of attribute
4
+ * and attribute groups processing.
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+ #ifndef __XML_XSLT_ATTRIBUTES_H__
12
+ #define __XML_XSLT_ATTRIBUTES_H__
13
+
14
+ #include <libxml/tree.h>
15
+ #include "xsltexports.h"
16
+ #include "xsltInternals.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ XSLTPUBFUN void XSLTCALL
23
+ xsltParseStylesheetAttributeSet (xsltStylesheetPtr style,
24
+ xmlNodePtr cur);
25
+ XSLTPUBFUN void XSLTCALL
26
+ xsltFreeAttributeSetsHashes (xsltStylesheetPtr style);
27
+ XSLTPUBFUN void XSLTCALL
28
+ xsltApplyAttributeSet (xsltTransformContextPtr ctxt,
29
+ xmlNodePtr node,
30
+ xmlNodePtr inst,
31
+ const xmlChar *attributes);
32
+ XSLTPUBFUN void XSLTCALL
33
+ xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style);
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+
38
+ #endif /* __XML_XSLT_ATTRIBUTES_H__ */
39
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/documents.h ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the document handling
3
+ * Description: implements document loading and cache (multiple
4
+ * document() reference for the same resources must
5
+ * be equal.
6
+ *
7
+ * Copy: See Copyright for the status of this software.
8
+ *
9
+ * Author: Daniel Veillard
10
+ */
11
+
12
+ #ifndef __XML_XSLT_DOCUMENTS_H__
13
+ #define __XML_XSLT_DOCUMENTS_H__
14
+
15
+ #include <libxml/tree.h>
16
+ #include "xsltexports.h"
17
+ #include "xsltInternals.h"
18
+
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
22
+
23
+ XSLTPUBFUN xsltDocumentPtr XSLTCALL
24
+ xsltNewDocument (xsltTransformContextPtr ctxt,
25
+ xmlDocPtr doc);
26
+ XSLTPUBFUN xsltDocumentPtr XSLTCALL
27
+ xsltLoadDocument (xsltTransformContextPtr ctxt,
28
+ const xmlChar *URI);
29
+ XSLTPUBFUN xsltDocumentPtr XSLTCALL
30
+ xsltFindDocument (xsltTransformContextPtr ctxt,
31
+ xmlDocPtr doc);
32
+ XSLTPUBFUN void XSLTCALL
33
+ xsltFreeDocuments (xsltTransformContextPtr ctxt);
34
+
35
+ XSLTPUBFUN xsltDocumentPtr XSLTCALL
36
+ xsltLoadStyleDocument (xsltStylesheetPtr style,
37
+ const xmlChar *URI);
38
+ XSLTPUBFUN xsltDocumentPtr XSLTCALL
39
+ xsltNewStyleDocument (xsltStylesheetPtr style,
40
+ xmlDocPtr doc);
41
+ XSLTPUBFUN void XSLTCALL
42
+ xsltFreeStyleDocuments (xsltStylesheetPtr style);
43
+
44
+ /*
45
+ * Hooks for document loading
46
+ */
47
+
48
+ /**
49
+ * xsltLoadType:
50
+ *
51
+ * Enum defining the kind of loader requirement.
52
+ */
53
+ typedef enum {
54
+ XSLT_LOAD_START = 0, /* loading for a top stylesheet */
55
+ XSLT_LOAD_STYLESHEET = 1, /* loading for a stylesheet include/import */
56
+ XSLT_LOAD_DOCUMENT = 2 /* loading document at transformation time */
57
+ } xsltLoadType;
58
+
59
+ /**
60
+ * xsltDocLoaderFunc:
61
+ * @URI: the URI of the document to load
62
+ * @dict: the dictionary to use when parsing that document
63
+ * @options: parsing options, a set of xmlParserOption
64
+ * @ctxt: the context, either a stylesheet or a transformation context
65
+ * @type: the xsltLoadType indicating the kind of loading required
66
+ *
67
+ * An xsltDocLoaderFunc is a signature for a function which can be
68
+ * registered to load document not provided by the compilation or
69
+ * transformation API themselve, for example when an xsl:import,
70
+ * xsl:include is found at compilation time or when a document()
71
+ * call is made at runtime.
72
+ *
73
+ * Returns the pointer to the document (which will be modified and
74
+ * freed by the engine later), or NULL in case of error.
75
+ */
76
+ typedef xmlDocPtr (*xsltDocLoaderFunc) (const xmlChar *URI,
77
+ xmlDictPtr dict,
78
+ int options,
79
+ void *ctxt,
80
+ xsltLoadType type);
81
+
82
+ XSLTPUBFUN void XSLTCALL
83
+ xsltSetLoaderFunc (xsltDocLoaderFunc f);
84
+
85
+ /* the loader may be needed by extension libraries so it is exported */
86
+ XSLTPUBVAR xsltDocLoaderFunc xsltDocDefaultLoader;
87
+
88
+ #ifdef __cplusplus
89
+ }
90
+ #endif
91
+
92
+ #endif /* __XML_XSLT_DOCUMENTS_H__ */
93
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/extensions.h ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the extension support
3
+ * Description: This provide the API needed for simple and module
4
+ * extension support.
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+ #ifndef __XML_XSLT_EXTENSION_H__
12
+ #define __XML_XSLT_EXTENSION_H__
13
+
14
+ #include <libxml/xpath.h>
15
+ #include "xsltexports.h"
16
+ #include "xsltInternals.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ /**
23
+ * Extension Modules API.
24
+ */
25
+
26
+ /**
27
+ * xsltInitGlobals:
28
+ *
29
+ * Initialize the global variables for extensions
30
+ *
31
+ */
32
+
33
+ XSLTPUBFUN void XSLTCALL
34
+ xsltInitGlobals (void);
35
+
36
+ /**
37
+ * xsltStyleExtInitFunction:
38
+ * @ctxt: an XSLT stylesheet
39
+ * @URI: the namespace URI for the extension
40
+ *
41
+ * A function called at initialization time of an XSLT extension module.
42
+ *
43
+ * Returns a pointer to the module specific data for this transformation.
44
+ */
45
+ typedef void * (*xsltStyleExtInitFunction) (xsltStylesheetPtr style,
46
+ const xmlChar *URI);
47
+
48
+ /**
49
+ * xsltStyleExtShutdownFunction:
50
+ * @ctxt: an XSLT stylesheet
51
+ * @URI: the namespace URI for the extension
52
+ * @data: the data associated to this module
53
+ *
54
+ * A function called at shutdown time of an XSLT extension module.
55
+ */
56
+ typedef void (*xsltStyleExtShutdownFunction) (xsltStylesheetPtr style,
57
+ const xmlChar *URI,
58
+ void *data);
59
+
60
+ /**
61
+ * xsltExtInitFunction:
62
+ * @ctxt: an XSLT transformation context
63
+ * @URI: the namespace URI for the extension
64
+ *
65
+ * A function called at initialization time of an XSLT extension module.
66
+ *
67
+ * Returns a pointer to the module specific data for this transformation.
68
+ */
69
+ typedef void * (*xsltExtInitFunction) (xsltTransformContextPtr ctxt,
70
+ const xmlChar *URI);
71
+
72
+ /**
73
+ * xsltExtShutdownFunction:
74
+ * @ctxt: an XSLT transformation context
75
+ * @URI: the namespace URI for the extension
76
+ * @data: the data associated to this module
77
+ *
78
+ * A function called at shutdown time of an XSLT extension module.
79
+ */
80
+ typedef void (*xsltExtShutdownFunction) (xsltTransformContextPtr ctxt,
81
+ const xmlChar *URI,
82
+ void *data);
83
+
84
+ XSLTPUBFUN int XSLTCALL
85
+ xsltRegisterExtModule (const xmlChar *URI,
86
+ xsltExtInitFunction initFunc,
87
+ xsltExtShutdownFunction shutdownFunc);
88
+ XSLTPUBFUN int XSLTCALL
89
+ xsltRegisterExtModuleFull
90
+ (const xmlChar * URI,
91
+ xsltExtInitFunction initFunc,
92
+ xsltExtShutdownFunction shutdownFunc,
93
+ xsltStyleExtInitFunction styleInitFunc,
94
+ xsltStyleExtShutdownFunction styleShutdownFunc);
95
+
96
+ XSLTPUBFUN int XSLTCALL
97
+ xsltUnregisterExtModule (const xmlChar * URI);
98
+
99
+ XSLTPUBFUN void * XSLTCALL
100
+ xsltGetExtData (xsltTransformContextPtr ctxt,
101
+ const xmlChar *URI);
102
+
103
+ XSLTPUBFUN void * XSLTCALL
104
+ xsltStyleGetExtData (xsltStylesheetPtr style,
105
+ const xmlChar *URI);
106
+ #ifdef XSLT_REFACTORED
107
+ XSLTPUBFUN void * XSLTCALL
108
+ xsltStyleStylesheetLevelGetExtData(
109
+ xsltStylesheetPtr style,
110
+ const xmlChar * URI);
111
+ #endif
112
+ XSLTPUBFUN void XSLTCALL
113
+ xsltShutdownCtxtExts (xsltTransformContextPtr ctxt);
114
+
115
+ XSLTPUBFUN void XSLTCALL
116
+ xsltShutdownExts (xsltStylesheetPtr style);
117
+
118
+ XSLTPUBFUN xsltTransformContextPtr XSLTCALL
119
+ xsltXPathGetTransformContext
120
+ (xmlXPathParserContextPtr ctxt);
121
+
122
+ /*
123
+ * extension functions
124
+ */
125
+ XSLTPUBFUN int XSLTCALL
126
+ xsltRegisterExtModuleFunction
127
+ (const xmlChar *name,
128
+ const xmlChar *URI,
129
+ xmlXPathFunction function);
130
+ XSLTPUBFUN xmlXPathFunction XSLTCALL
131
+ xsltExtModuleFunctionLookup (const xmlChar *name,
132
+ const xmlChar *URI);
133
+ XSLTPUBFUN int XSLTCALL
134
+ xsltUnregisterExtModuleFunction
135
+ (const xmlChar *name,
136
+ const xmlChar *URI);
137
+
138
+ /*
139
+ * extension elements
140
+ */
141
+ typedef xsltElemPreCompPtr (*xsltPreComputeFunction)
142
+ (xsltStylesheetPtr style,
143
+ xmlNodePtr inst,
144
+ xsltTransformFunction function);
145
+
146
+ XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
147
+ xsltNewElemPreComp (xsltStylesheetPtr style,
148
+ xmlNodePtr inst,
149
+ xsltTransformFunction function);
150
+ XSLTPUBFUN void XSLTCALL
151
+ xsltInitElemPreComp (xsltElemPreCompPtr comp,
152
+ xsltStylesheetPtr style,
153
+ xmlNodePtr inst,
154
+ xsltTransformFunction function,
155
+ xsltElemPreCompDeallocator freeFunc);
156
+
157
+ XSLTPUBFUN int XSLTCALL
158
+ xsltRegisterExtModuleElement
159
+ (const xmlChar *name,
160
+ const xmlChar *URI,
161
+ xsltPreComputeFunction precomp,
162
+ xsltTransformFunction transform);
163
+ XSLTPUBFUN xsltTransformFunction XSLTCALL
164
+ xsltExtElementLookup (xsltTransformContextPtr ctxt,
165
+ const xmlChar *name,
166
+ const xmlChar *URI);
167
+ XSLTPUBFUN xsltTransformFunction XSLTCALL
168
+ xsltExtModuleElementLookup
169
+ (const xmlChar *name,
170
+ const xmlChar *URI);
171
+ XSLTPUBFUN xsltPreComputeFunction XSLTCALL
172
+ xsltExtModuleElementPreComputeLookup
173
+ (const xmlChar *name,
174
+ const xmlChar *URI);
175
+ XSLTPUBFUN int XSLTCALL
176
+ xsltUnregisterExtModuleElement
177
+ (const xmlChar *name,
178
+ const xmlChar *URI);
179
+
180
+ /*
181
+ * top-level elements
182
+ */
183
+ typedef void (*xsltTopLevelFunction) (xsltStylesheetPtr style,
184
+ xmlNodePtr inst);
185
+
186
+ XSLTPUBFUN int XSLTCALL
187
+ xsltRegisterExtModuleTopLevel
188
+ (const xmlChar *name,
189
+ const xmlChar *URI,
190
+ xsltTopLevelFunction function);
191
+ XSLTPUBFUN xsltTopLevelFunction XSLTCALL
192
+ xsltExtModuleTopLevelLookup
193
+ (const xmlChar *name,
194
+ const xmlChar *URI);
195
+ XSLTPUBFUN int XSLTCALL
196
+ xsltUnregisterExtModuleTopLevel
197
+ (const xmlChar *name,
198
+ const xmlChar *URI);
199
+
200
+
201
+ /* These 2 functions are deprecated for use within modules. */
202
+ XSLTPUBFUN int XSLTCALL
203
+ xsltRegisterExtFunction (xsltTransformContextPtr ctxt,
204
+ const xmlChar *name,
205
+ const xmlChar *URI,
206
+ xmlXPathFunction function);
207
+ XSLTPUBFUN int XSLTCALL
208
+ xsltRegisterExtElement (xsltTransformContextPtr ctxt,
209
+ const xmlChar *name,
210
+ const xmlChar *URI,
211
+ xsltTransformFunction function);
212
+
213
+ /*
214
+ * Extension Prefix handling API.
215
+ * Those are used by the XSLT (pre)processor.
216
+ */
217
+
218
+ XSLTPUBFUN int XSLTCALL
219
+ xsltRegisterExtPrefix (xsltStylesheetPtr style,
220
+ const xmlChar *prefix,
221
+ const xmlChar *URI);
222
+ XSLTPUBFUN int XSLTCALL
223
+ xsltCheckExtPrefix (xsltStylesheetPtr style,
224
+ const xmlChar *URI);
225
+ XSLTPUBFUN int XSLTCALL
226
+ xsltCheckExtURI (xsltStylesheetPtr style,
227
+ const xmlChar *URI);
228
+ XSLTPUBFUN int XSLTCALL
229
+ xsltInitCtxtExts (xsltTransformContextPtr ctxt);
230
+ XSLTPUBFUN void XSLTCALL
231
+ xsltFreeCtxtExts (xsltTransformContextPtr ctxt);
232
+ XSLTPUBFUN void XSLTCALL
233
+ xsltFreeExts (xsltStylesheetPtr style);
234
+
235
+ XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
236
+ xsltPreComputeExtModuleElement
237
+ (xsltStylesheetPtr style,
238
+ xmlNodePtr inst);
239
+ /*
240
+ * Extension Infos access.
241
+ * Used by exslt initialisation
242
+ */
243
+
244
+ XSLTPUBFUN xmlHashTablePtr XSLTCALL
245
+ xsltGetExtInfo (xsltStylesheetPtr style,
246
+ const xmlChar *URI);
247
+
248
+ /**
249
+ * Test of the extension module API
250
+ */
251
+ XSLTPUBFUN void XSLTCALL
252
+ xsltRegisterTestModule (void);
253
+ XSLTPUBFUN void XSLTCALL
254
+ xsltDebugDumpExtensions (FILE * output);
255
+
256
+
257
+ #ifdef __cplusplus
258
+ }
259
+ #endif
260
+
261
+ #endif /* __XML_XSLT_EXTENSION_H__ */
262
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/extra.h ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the non-standard features
3
+ * Description: implement some extension outside the XSLT namespace
4
+ * but not EXSLT with is in a different library.
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+ #ifndef __XML_XSLT_EXTRA_H__
12
+ #define __XML_XSLT_EXTRA_H__
13
+
14
+ #include <libxml/xpath.h>
15
+ #include "xsltexports.h"
16
+ #include "xsltInternals.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ /**
23
+ * XSLT_LIBXSLT_NAMESPACE:
24
+ *
25
+ * This is the libxslt namespace for specific extensions.
26
+ */
27
+ #define XSLT_LIBXSLT_NAMESPACE ((xmlChar *) "http://xmlsoft.org/XSLT/namespace")
28
+
29
+ /**
30
+ * XSLT_SAXON_NAMESPACE:
31
+ *
32
+ * This is Michael Kay's Saxon processor namespace for extensions.
33
+ */
34
+ #define XSLT_SAXON_NAMESPACE ((xmlChar *) "http://icl.com/saxon")
35
+
36
+ /**
37
+ * XSLT_XT_NAMESPACE:
38
+ *
39
+ * This is James Clark's XT processor namespace for extensions.
40
+ */
41
+ #define XSLT_XT_NAMESPACE ((xmlChar *) "http://www.jclark.com/xt")
42
+
43
+ /**
44
+ * XSLT_XALAN_NAMESPACE:
45
+ *
46
+ * This is the Apache project XALAN processor namespace for extensions.
47
+ */
48
+ #define XSLT_XALAN_NAMESPACE ((xmlChar *) \
49
+ "org.apache.xalan.xslt.extensions.Redirect")
50
+
51
+
52
+ XSLTPUBFUN void XSLTCALL
53
+ xsltFunctionNodeSet (xmlXPathParserContextPtr ctxt,
54
+ int nargs);
55
+ XSLTPUBFUN void XSLTCALL
56
+ xsltDebug (xsltTransformContextPtr ctxt,
57
+ xmlNodePtr node,
58
+ xmlNodePtr inst,
59
+ xsltElemPreCompPtr comp);
60
+
61
+
62
+ XSLTPUBFUN void XSLTCALL
63
+ xsltRegisterExtras (xsltTransformContextPtr ctxt);
64
+ XSLTPUBFUN void XSLTCALL
65
+ xsltRegisterAllExtras (void);
66
+
67
+ #ifdef __cplusplus
68
+ }
69
+ #endif
70
+
71
+ #endif /* __XML_XSLT_EXTRA_H__ */
72
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/functions.h ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the XSLT functions not from XPath
3
+ * Description: a set of extra functions coming from XSLT but not in XPath
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Daniel Veillard and Bjorn Reese <[email protected]>
8
+ */
9
+
10
+ #ifndef __XML_XSLT_FUNCTIONS_H__
11
+ #define __XML_XSLT_FUNCTIONS_H__
12
+
13
+ #include <libxml/xpath.h>
14
+ #include <libxml/xpathInternals.h>
15
+ #include "xsltexports.h"
16
+ #include "xsltInternals.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ /**
23
+ * XSLT_REGISTER_FUNCTION_LOOKUP:
24
+ *
25
+ * Registering macro, not general purpose at all but used in different modules.
26
+ */
27
+ #define XSLT_REGISTER_FUNCTION_LOOKUP(ctxt) \
28
+ xmlXPathRegisterFuncLookup((ctxt)->xpathCtxt, \
29
+ xsltXPathFunctionLookup, \
30
+ (void *)(ctxt->xpathCtxt));
31
+
32
+ XSLTPUBFUN xmlXPathFunction XSLTCALL
33
+ xsltXPathFunctionLookup (void *vctxt,
34
+ const xmlChar *name,
35
+ const xmlChar *ns_uri);
36
+
37
+ /*
38
+ * Interfaces for the functions implementations.
39
+ */
40
+
41
+ XSLTPUBFUN void XSLTCALL
42
+ xsltDocumentFunction (xmlXPathParserContextPtr ctxt,
43
+ int nargs);
44
+ XSLTPUBFUN void XSLTCALL
45
+ xsltKeyFunction (xmlXPathParserContextPtr ctxt,
46
+ int nargs);
47
+ XSLTPUBFUN void XSLTCALL
48
+ xsltUnparsedEntityURIFunction (xmlXPathParserContextPtr ctxt,
49
+ int nargs);
50
+ XSLTPUBFUN void XSLTCALL
51
+ xsltFormatNumberFunction (xmlXPathParserContextPtr ctxt,
52
+ int nargs);
53
+ XSLTPUBFUN void XSLTCALL
54
+ xsltGenerateIdFunction (xmlXPathParserContextPtr ctxt,
55
+ int nargs);
56
+ XSLTPUBFUN void XSLTCALL
57
+ xsltSystemPropertyFunction (xmlXPathParserContextPtr ctxt,
58
+ int nargs);
59
+ XSLTPUBFUN void XSLTCALL
60
+ xsltElementAvailableFunction (xmlXPathParserContextPtr ctxt,
61
+ int nargs);
62
+ XSLTPUBFUN void XSLTCALL
63
+ xsltFunctionAvailableFunction (xmlXPathParserContextPtr ctxt,
64
+ int nargs);
65
+
66
+ /*
67
+ * And the registration
68
+ */
69
+
70
+ XSLTPUBFUN void XSLTCALL
71
+ xsltRegisterAllFunctions (xmlXPathContextPtr ctxt);
72
+
73
+ #ifdef __cplusplus
74
+ }
75
+ #endif
76
+
77
+ #endif /* __XML_XSLT_FUNCTIONS_H__ */
78
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/imports.h ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the XSLT import support
3
+ * Description: macros and fuctions needed to implement and
4
+ * access the import tree
5
+ *
6
+ * Copy: See Copyright for the status of this software.
7
+ *
8
+ * Author: Daniel Veillard
9
+ */
10
+
11
+ #ifndef __XML_XSLT_IMPORTS_H__
12
+ #define __XML_XSLT_IMPORTS_H__
13
+
14
+ #include <libxml/tree.h>
15
+ #include "xsltexports.h"
16
+ #include "xsltInternals.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ /**
23
+ * XSLT_GET_IMPORT_PTR:
24
+ *
25
+ * A macro to import pointers from the stylesheet cascading order.
26
+ */
27
+ #define XSLT_GET_IMPORT_PTR(res, style, name) { \
28
+ xsltStylesheetPtr st = style; \
29
+ res = NULL; \
30
+ while (st != NULL) { \
31
+ if (st->name != NULL) { res = st->name; break; } \
32
+ st = xsltNextImport(st); \
33
+ }}
34
+
35
+ /**
36
+ * XSLT_GET_IMPORT_INT:
37
+ *
38
+ * A macro to import intergers from the stylesheet cascading order.
39
+ */
40
+ #define XSLT_GET_IMPORT_INT(res, style, name) { \
41
+ xsltStylesheetPtr st = style; \
42
+ res = -1; \
43
+ while (st != NULL) { \
44
+ if (st->name != -1) { res = st->name; break; } \
45
+ st = xsltNextImport(st); \
46
+ }}
47
+
48
+ /*
49
+ * Module interfaces
50
+ */
51
+ XSLTPUBFUN int XSLTCALL
52
+ xsltParseStylesheetImport(xsltStylesheetPtr style,
53
+ xmlNodePtr cur);
54
+ XSLTPUBFUN int XSLTCALL
55
+ xsltParseStylesheetInclude
56
+ (xsltStylesheetPtr style,
57
+ xmlNodePtr cur);
58
+ XSLTPUBFUN xsltStylesheetPtr XSLTCALL
59
+ xsltNextImport (xsltStylesheetPtr style);
60
+ XSLTPUBFUN int XSLTCALL
61
+ xsltNeedElemSpaceHandling(xsltTransformContextPtr ctxt);
62
+ XSLTPUBFUN int XSLTCALL
63
+ xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt,
64
+ xmlNodePtr node);
65
+ XSLTPUBFUN xsltTemplatePtr XSLTCALL
66
+ xsltFindTemplate (xsltTransformContextPtr ctxt,
67
+ const xmlChar *name,
68
+ const xmlChar *nameURI);
69
+
70
+ #ifdef __cplusplus
71
+ }
72
+ #endif
73
+
74
+ #endif /* __XML_XSLT_IMPORTS_H__ */
75
+
llmeval-env/lib/python3.10/site-packages/lxml/includes/libxslt/keys.h ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Summary: interface for the key matching used in key() and template matches.
3
+ * Description: implementation of the key mechanims.
4
+ *
5
+ * Copy: See Copyright for the status of this software.
6
+ *
7
+ * Author: Daniel Veillard
8
+ */
9
+
10
+ #ifndef __XML_XSLT_KEY_H__
11
+ #define __XML_XSLT_KEY_H__
12
+
13
+ #include <libxml/xpath.h>
14
+ #include "xsltexports.h"
15
+ #include "xsltInternals.h"
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ /**
22
+ * NODE_IS_KEYED:
23
+ *
24
+ * check for bit 15 set
25
+ */
26
+ #define NODE_IS_KEYED (1 >> 15)
27
+
28
+ XSLTPUBFUN int XSLTCALL
29
+ xsltAddKey (xsltStylesheetPtr style,
30
+ const xmlChar *name,
31
+ const xmlChar *nameURI,
32
+ const xmlChar *match,
33
+ const xmlChar *use,
34
+ xmlNodePtr inst);
35
+ XSLTPUBFUN xmlNodeSetPtr XSLTCALL
36
+ xsltGetKey (xsltTransformContextPtr ctxt,
37
+ const xmlChar *name,
38
+ const xmlChar *nameURI,
39
+ const xmlChar *value);
40
+ XSLTPUBFUN void XSLTCALL
41
+ xsltInitCtxtKeys (xsltTransformContextPtr ctxt,
42
+ xsltDocumentPtr doc);
43
+ XSLTPUBFUN void XSLTCALL
44
+ xsltFreeKeys (xsltStylesheetPtr style);
45
+ XSLTPUBFUN void XSLTCALL
46
+ xsltFreeDocumentKeys (xsltDocumentPtr doc);
47
+
48
+ #ifdef __cplusplus
49
+ }
50
+ #endif
51
+
52
+ #endif /* __XML_XSLT_H__ */
53
+