Added login api
This commit is contained in:
244
acer-env/lib/python3.10/site-packages/lxml/ElementInclude.py
Normal file
244
acer-env/lib/python3.10/site-packages/lxml/ElementInclude.py
Normal file
@@ -0,0 +1,244 @@
|
||||
#
|
||||
# ElementTree
|
||||
# $Id: ElementInclude.py 1862 2004-06-18 07:31:02Z Fredrik $
|
||||
#
|
||||
# limited xinclude support for element trees
|
||||
#
|
||||
# history:
|
||||
# 2003-08-15 fl created
|
||||
# 2003-11-14 fl fixed default loader
|
||||
#
|
||||
# Copyright (c) 2003-2004 by Fredrik Lundh. All rights reserved.
|
||||
#
|
||||
# fredrik@pythonware.com
|
||||
# http://www.pythonware.com
|
||||
#
|
||||
# --------------------------------------------------------------------
|
||||
# The ElementTree toolkit is
|
||||
#
|
||||
# Copyright (c) 1999-2004 by Fredrik Lundh
|
||||
#
|
||||
# By obtaining, using, and/or copying this software and/or its
|
||||
# associated documentation, you agree that you have read, understood,
|
||||
# and will comply with the following terms and conditions:
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software and
|
||||
# its associated documentation for any purpose and without fee is
|
||||
# hereby granted, provided that the above copyright notice appears in
|
||||
# all copies, and that both that copyright notice and this permission
|
||||
# notice appear in supporting documentation, and that the name of
|
||||
# Secret Labs AB or the author not be used in advertising or publicity
|
||||
# pertaining to distribution of the software without specific, written
|
||||
# prior permission.
|
||||
#
|
||||
# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
||||
# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
|
||||
# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
|
||||
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
"""
|
||||
Limited XInclude support for the ElementTree package.
|
||||
|
||||
While lxml.etree has full support for XInclude (see
|
||||
`etree.ElementTree.xinclude()`), this module provides a simpler, pure
|
||||
Python, ElementTree compatible implementation that supports a simple
|
||||
form of custom URL resolvers.
|
||||
"""
|
||||
|
||||
from lxml import etree
|
||||
try:
|
||||
from urlparse import urljoin
|
||||
from urllib2 import urlopen
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from urllib.parse import urljoin
|
||||
from urllib.request import urlopen
|
||||
|
||||
XINCLUDE = "{http://www.w3.org/2001/XInclude}"
|
||||
|
||||
XINCLUDE_INCLUDE = XINCLUDE + "include"
|
||||
XINCLUDE_FALLBACK = XINCLUDE + "fallback"
|
||||
XINCLUDE_ITER_TAG = XINCLUDE + "*"
|
||||
|
||||
# For security reasons, the inclusion depth is limited to this read-only value by default.
|
||||
DEFAULT_MAX_INCLUSION_DEPTH = 6
|
||||
|
||||
|
||||
##
|
||||
# Fatal include error.
|
||||
|
||||
class FatalIncludeError(etree.LxmlSyntaxError):
|
||||
pass
|
||||
|
||||
|
||||
class LimitedRecursiveIncludeError(FatalIncludeError):
|
||||
pass
|
||||
|
||||
|
||||
##
|
||||
# ET compatible default loader.
|
||||
# This loader reads an included resource from disk.
|
||||
#
|
||||
# @param href Resource reference.
|
||||
# @param parse Parse mode. Either "xml" or "text".
|
||||
# @param encoding Optional text encoding.
|
||||
# @return The expanded resource. If the parse mode is "xml", this
|
||||
# is an ElementTree instance. If the parse mode is "text", this
|
||||
# is a Unicode string. If the loader fails, it can return None
|
||||
# or raise an IOError exception.
|
||||
# @throws IOError If the loader fails to load the resource.
|
||||
|
||||
def default_loader(href, parse, encoding=None):
|
||||
file = open(href, 'rb')
|
||||
if parse == "xml":
|
||||
data = etree.parse(file).getroot()
|
||||
else:
|
||||
data = file.read()
|
||||
if not encoding:
|
||||
encoding = 'utf-8'
|
||||
data = data.decode(encoding)
|
||||
file.close()
|
||||
return data
|
||||
|
||||
|
||||
##
|
||||
# Default loader used by lxml.etree - handles custom resolvers properly
|
||||
#
|
||||
|
||||
def _lxml_default_loader(href, parse, encoding=None, parser=None):
|
||||
if parse == "xml":
|
||||
data = etree.parse(href, parser).getroot()
|
||||
else:
|
||||
if "://" in href:
|
||||
f = urlopen(href)
|
||||
else:
|
||||
f = open(href, 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
if not encoding:
|
||||
encoding = 'utf-8'
|
||||
data = data.decode(encoding)
|
||||
return data
|
||||
|
||||
|
||||
##
|
||||
# Wrapper for ET compatibility - drops the parser
|
||||
|
||||
def _wrap_et_loader(loader):
|
||||
def load(href, parse, encoding=None, parser=None):
|
||||
return loader(href, parse, encoding)
|
||||
return load
|
||||
|
||||
|
||||
##
|
||||
# Expand XInclude directives.
|
||||
#
|
||||
# @param elem Root element.
|
||||
# @param loader Optional resource loader. If omitted, it defaults
|
||||
# to {@link default_loader}. If given, it should be a callable
|
||||
# that implements the same interface as <b>default_loader</b>.
|
||||
# @param base_url The base URL of the original file, to resolve
|
||||
# relative include file references.
|
||||
# @param max_depth The maximum number of recursive inclusions.
|
||||
# Limited to reduce the risk of malicious content explosion.
|
||||
# Pass None to disable the limitation.
|
||||
# @throws LimitedRecursiveIncludeError If the {@link max_depth} was exceeded.
|
||||
# @throws FatalIncludeError If the function fails to include a given
|
||||
# resource, or if the tree contains malformed XInclude elements.
|
||||
# @throws IOError If the function fails to load a given resource.
|
||||
# @returns the node or its replacement if it was an XInclude node
|
||||
|
||||
def include(elem, loader=None, base_url=None,
|
||||
max_depth=DEFAULT_MAX_INCLUSION_DEPTH):
|
||||
if max_depth is None:
|
||||
max_depth = -1
|
||||
elif max_depth < 0:
|
||||
raise ValueError("expected non-negative depth or None for 'max_depth', got %r" % max_depth)
|
||||
|
||||
if base_url is None:
|
||||
if hasattr(elem, 'getroot'):
|
||||
tree = elem
|
||||
elem = elem.getroot()
|
||||
else:
|
||||
tree = elem.getroottree()
|
||||
if hasattr(tree, 'docinfo'):
|
||||
base_url = tree.docinfo.URL
|
||||
elif hasattr(elem, 'getroot'):
|
||||
elem = elem.getroot()
|
||||
_include(elem, loader, base_url, max_depth)
|
||||
|
||||
|
||||
def _include(elem, loader=None, base_url=None,
|
||||
max_depth=DEFAULT_MAX_INCLUSION_DEPTH, _parent_hrefs=None):
|
||||
if loader is not None:
|
||||
load_include = _wrap_et_loader(loader)
|
||||
else:
|
||||
load_include = _lxml_default_loader
|
||||
|
||||
if _parent_hrefs is None:
|
||||
_parent_hrefs = set()
|
||||
|
||||
parser = elem.getroottree().parser
|
||||
|
||||
include_elements = list(
|
||||
elem.iter(XINCLUDE_ITER_TAG))
|
||||
|
||||
for e in include_elements:
|
||||
if e.tag == XINCLUDE_INCLUDE:
|
||||
# process xinclude directive
|
||||
href = urljoin(base_url, e.get("href"))
|
||||
parse = e.get("parse", "xml")
|
||||
parent = e.getparent()
|
||||
if parse == "xml":
|
||||
if href in _parent_hrefs:
|
||||
raise FatalIncludeError(
|
||||
"recursive include of %r detected" % href
|
||||
)
|
||||
if max_depth == 0:
|
||||
raise LimitedRecursiveIncludeError(
|
||||
"maximum xinclude depth reached when including file %s" % href)
|
||||
node = load_include(href, parse, parser=parser)
|
||||
if node is None:
|
||||
raise FatalIncludeError(
|
||||
"cannot load %r as %r" % (href, parse)
|
||||
)
|
||||
node = _include(node, loader, href, max_depth - 1, {href} | _parent_hrefs)
|
||||
if e.tail:
|
||||
node.tail = (node.tail or "") + e.tail
|
||||
if parent is None:
|
||||
return node # replaced the root node!
|
||||
parent.replace(e, node)
|
||||
elif parse == "text":
|
||||
text = load_include(href, parse, encoding=e.get("encoding"))
|
||||
if text is None:
|
||||
raise FatalIncludeError(
|
||||
"cannot load %r as %r" % (href, parse)
|
||||
)
|
||||
predecessor = e.getprevious()
|
||||
if predecessor is not None:
|
||||
predecessor.tail = (predecessor.tail or "") + text
|
||||
elif parent is None:
|
||||
return text # replaced the root node!
|
||||
else:
|
||||
parent.text = (parent.text or "") + text + (e.tail or "")
|
||||
parent.remove(e)
|
||||
else:
|
||||
raise FatalIncludeError(
|
||||
"unknown parse type in xi:include tag (%r)" % parse
|
||||
)
|
||||
elif e.tag == XINCLUDE_FALLBACK:
|
||||
parent = e.getparent()
|
||||
if parent is not None and parent.tag != XINCLUDE_INCLUDE:
|
||||
raise FatalIncludeError(
|
||||
"xi:fallback tag must be child of xi:include (%r)" % e.tag
|
||||
)
|
||||
else:
|
||||
raise FatalIncludeError(
|
||||
"Invalid element found in XInclude namespace (%r)" % e.tag
|
||||
)
|
||||
return elem
|
||||
23
acer-env/lib/python3.10/site-packages/lxml/__init__.py
Normal file
23
acer-env/lib/python3.10/site-packages/lxml/__init__.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# this is a package
|
||||
|
||||
__version__ = "4.9.1"
|
||||
|
||||
|
||||
def get_include():
|
||||
"""
|
||||
Returns a list of header include paths (for lxml itself, libxml2
|
||||
and libxslt) needed to compile C code against lxml if it was built
|
||||
with statically linked libraries.
|
||||
"""
|
||||
import os
|
||||
lxml_path = __path__[0]
|
||||
include_path = os.path.join(lxml_path, 'includes')
|
||||
includes = [include_path, lxml_path]
|
||||
|
||||
for name in os.listdir(include_path):
|
||||
path = os.path.join(include_path, name)
|
||||
if os.path.isdir(path):
|
||||
includes.append(path)
|
||||
|
||||
return includes
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
345
acer-env/lib/python3.10/site-packages/lxml/_elementpath.py
Normal file
345
acer-env/lib/python3.10/site-packages/lxml/_elementpath.py
Normal file
@@ -0,0 +1,345 @@
|
||||
# cython: language_level=2
|
||||
|
||||
#
|
||||
# ElementTree
|
||||
# $Id: ElementPath.py 3375 2008-02-13 08:05:08Z fredrik $
|
||||
#
|
||||
# limited xpath support for element trees
|
||||
#
|
||||
# history:
|
||||
# 2003-05-23 fl created
|
||||
# 2003-05-28 fl added support for // etc
|
||||
# 2003-08-27 fl fixed parsing of periods in element names
|
||||
# 2007-09-10 fl new selection engine
|
||||
# 2007-09-12 fl fixed parent selector
|
||||
# 2007-09-13 fl added iterfind; changed findall to return a list
|
||||
# 2007-11-30 fl added namespaces support
|
||||
# 2009-10-30 fl added child element value filter
|
||||
#
|
||||
# Copyright (c) 2003-2009 by Fredrik Lundh. All rights reserved.
|
||||
#
|
||||
# fredrik@pythonware.com
|
||||
# http://www.pythonware.com
|
||||
#
|
||||
# --------------------------------------------------------------------
|
||||
# The ElementTree toolkit is
|
||||
#
|
||||
# Copyright (c) 1999-2009 by Fredrik Lundh
|
||||
#
|
||||
# By obtaining, using, and/or copying this software and/or its
|
||||
# associated documentation, you agree that you have read, understood,
|
||||
# and will comply with the following terms and conditions:
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software and
|
||||
# its associated documentation for any purpose and without fee is
|
||||
# hereby granted, provided that the above copyright notice appears in
|
||||
# all copies, and that both that copyright notice and this permission
|
||||
# notice appear in supporting documentation, and that the name of
|
||||
# Secret Labs AB or the author not be used in advertising or publicity
|
||||
# pertaining to distribution of the software without specific, written
|
||||
# prior permission.
|
||||
#
|
||||
# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
||||
# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
|
||||
# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
|
||||
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
##
|
||||
# Implementation module for XPath support. There's usually no reason
|
||||
# to import this module directly; the <b>ElementTree</b> does this for
|
||||
# you, if needed.
|
||||
##
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
|
||||
xpath_tokenizer_re = re.compile(
|
||||
"("
|
||||
"'[^']*'|\"[^\"]*\"|"
|
||||
"::|"
|
||||
"//?|"
|
||||
r"\.\.|"
|
||||
r"\(\)|"
|
||||
r"[/.*:\[\]\(\)@=])|"
|
||||
r"((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|"
|
||||
r"\s+"
|
||||
)
|
||||
|
||||
def xpath_tokenizer(pattern, namespaces=None):
|
||||
# ElementTree uses '', lxml used None originally.
|
||||
default_namespace = (namespaces.get(None) or namespaces.get('')) if namespaces else None
|
||||
parsing_attribute = False
|
||||
for token in xpath_tokenizer_re.findall(pattern):
|
||||
ttype, tag = token
|
||||
if tag and tag[0] != "{":
|
||||
if ":" in tag:
|
||||
prefix, uri = tag.split(":", 1)
|
||||
try:
|
||||
if not namespaces:
|
||||
raise KeyError
|
||||
yield ttype, "{%s}%s" % (namespaces[prefix], uri)
|
||||
except KeyError:
|
||||
raise SyntaxError("prefix %r not found in prefix map" % prefix)
|
||||
elif default_namespace and not parsing_attribute:
|
||||
yield ttype, "{%s}%s" % (default_namespace, tag)
|
||||
else:
|
||||
yield token
|
||||
parsing_attribute = False
|
||||
else:
|
||||
yield token
|
||||
parsing_attribute = ttype == '@'
|
||||
|
||||
|
||||
def prepare_child(next, token):
|
||||
tag = token[1]
|
||||
def select(result):
|
||||
for elem in result:
|
||||
for e in elem.iterchildren(tag):
|
||||
yield e
|
||||
return select
|
||||
|
||||
def prepare_star(next, token):
|
||||
def select(result):
|
||||
for elem in result:
|
||||
for e in elem.iterchildren('*'):
|
||||
yield e
|
||||
return select
|
||||
|
||||
def prepare_self(next, token):
|
||||
def select(result):
|
||||
return result
|
||||
return select
|
||||
|
||||
def prepare_descendant(next, token):
|
||||
token = next()
|
||||
if token[0] == "*":
|
||||
tag = "*"
|
||||
elif not token[0]:
|
||||
tag = token[1]
|
||||
else:
|
||||
raise SyntaxError("invalid descendant")
|
||||
def select(result):
|
||||
for elem in result:
|
||||
for e in elem.iterdescendants(tag):
|
||||
yield e
|
||||
return select
|
||||
|
||||
def prepare_parent(next, token):
|
||||
def select(result):
|
||||
for elem in result:
|
||||
parent = elem.getparent()
|
||||
if parent is not None:
|
||||
yield parent
|
||||
return select
|
||||
|
||||
def prepare_predicate(next, token):
|
||||
# FIXME: replace with real parser!!! refs:
|
||||
# http://effbot.org/zone/simple-iterator-parser.htm
|
||||
# http://javascript.crockford.com/tdop/tdop.html
|
||||
signature = ''
|
||||
predicate = []
|
||||
while 1:
|
||||
token = next()
|
||||
if token[0] == "]":
|
||||
break
|
||||
if token == ('', ''):
|
||||
# ignore whitespace
|
||||
continue
|
||||
if token[0] and token[0][:1] in "'\"":
|
||||
token = "'", token[0][1:-1]
|
||||
signature += token[0] or "-"
|
||||
predicate.append(token[1])
|
||||
|
||||
# use signature to determine predicate type
|
||||
if signature == "@-":
|
||||
# [@attribute] predicate
|
||||
key = predicate[1]
|
||||
def select(result):
|
||||
for elem in result:
|
||||
if elem.get(key) is not None:
|
||||
yield elem
|
||||
return select
|
||||
if signature == "@-='":
|
||||
# [@attribute='value']
|
||||
key = predicate[1]
|
||||
value = predicate[-1]
|
||||
def select(result):
|
||||
for elem in result:
|
||||
if elem.get(key) == value:
|
||||
yield elem
|
||||
return select
|
||||
if signature == "-" and not re.match(r"-?\d+$", predicate[0]):
|
||||
# [tag]
|
||||
tag = predicate[0]
|
||||
def select(result):
|
||||
for elem in result:
|
||||
for _ in elem.iterchildren(tag):
|
||||
yield elem
|
||||
break
|
||||
return select
|
||||
if signature == ".='" or (signature == "-='" and not re.match(r"-?\d+$", predicate[0])):
|
||||
# [.='value'] or [tag='value']
|
||||
tag = predicate[0]
|
||||
value = predicate[-1]
|
||||
if tag:
|
||||
def select(result):
|
||||
for elem in result:
|
||||
for e in elem.iterchildren(tag):
|
||||
if "".join(e.itertext()) == value:
|
||||
yield elem
|
||||
break
|
||||
else:
|
||||
def select(result):
|
||||
for elem in result:
|
||||
if "".join(elem.itertext()) == value:
|
||||
yield elem
|
||||
return select
|
||||
if signature == "-" or signature == "-()" or signature == "-()-":
|
||||
# [index] or [last()] or [last()-index]
|
||||
if signature == "-":
|
||||
# [index]
|
||||
index = int(predicate[0]) - 1
|
||||
if index < 0:
|
||||
if index == -1:
|
||||
raise SyntaxError(
|
||||
"indices in path predicates are 1-based, not 0-based")
|
||||
else:
|
||||
raise SyntaxError("path index >= 1 expected")
|
||||
else:
|
||||
if predicate[0] != "last":
|
||||
raise SyntaxError("unsupported function")
|
||||
if signature == "-()-":
|
||||
try:
|
||||
index = int(predicate[2]) - 1
|
||||
except ValueError:
|
||||
raise SyntaxError("unsupported expression")
|
||||
else:
|
||||
index = -1
|
||||
def select(result):
|
||||
for elem in result:
|
||||
parent = elem.getparent()
|
||||
if parent is None:
|
||||
continue
|
||||
try:
|
||||
# FIXME: what if the selector is "*" ?
|
||||
elems = list(parent.iterchildren(elem.tag))
|
||||
if elems[index] is elem:
|
||||
yield elem
|
||||
except IndexError:
|
||||
pass
|
||||
return select
|
||||
raise SyntaxError("invalid predicate")
|
||||
|
||||
ops = {
|
||||
"": prepare_child,
|
||||
"*": prepare_star,
|
||||
".": prepare_self,
|
||||
"..": prepare_parent,
|
||||
"//": prepare_descendant,
|
||||
"[": prepare_predicate,
|
||||
}
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
_cache = {}
|
||||
|
||||
|
||||
def _build_path_iterator(path, namespaces):
|
||||
"""compile selector pattern"""
|
||||
if path[-1:] == "/":
|
||||
path += "*" # implicit all (FIXME: keep this?)
|
||||
|
||||
cache_key = (path,)
|
||||
if namespaces:
|
||||
# lxml originally used None for the default namespace but ElementTree uses the
|
||||
# more convenient (all-strings-dict) empty string, so we support both here,
|
||||
# preferring the more convenient '', as long as they aren't ambiguous.
|
||||
if None in namespaces:
|
||||
if '' in namespaces and namespaces[None] != namespaces['']:
|
||||
raise ValueError("Ambiguous default namespace provided: %r versus %r" % (
|
||||
namespaces[None], namespaces['']))
|
||||
cache_key += (namespaces[None],) + tuple(sorted(
|
||||
item for item in namespaces.items() if item[0] is not None))
|
||||
else:
|
||||
cache_key += tuple(sorted(namespaces.items()))
|
||||
|
||||
try:
|
||||
return _cache[cache_key]
|
||||
except KeyError:
|
||||
pass
|
||||
if len(_cache) > 100:
|
||||
_cache.clear()
|
||||
|
||||
if path[:1] == "/":
|
||||
raise SyntaxError("cannot use absolute path on element")
|
||||
stream = iter(xpath_tokenizer(path, namespaces))
|
||||
try:
|
||||
_next = stream.next
|
||||
except AttributeError:
|
||||
# Python 3
|
||||
_next = stream.__next__
|
||||
try:
|
||||
token = _next()
|
||||
except StopIteration:
|
||||
raise SyntaxError("empty path expression")
|
||||
selector = []
|
||||
while 1:
|
||||
try:
|
||||
selector.append(ops[token[0]](_next, token))
|
||||
except StopIteration:
|
||||
raise SyntaxError("invalid path")
|
||||
try:
|
||||
token = _next()
|
||||
if token[0] == "/":
|
||||
token = _next()
|
||||
except StopIteration:
|
||||
break
|
||||
_cache[cache_key] = selector
|
||||
return selector
|
||||
|
||||
|
||||
##
|
||||
# Iterate over the matching nodes
|
||||
|
||||
def iterfind(elem, path, namespaces=None):
|
||||
selector = _build_path_iterator(path, namespaces)
|
||||
result = iter((elem,))
|
||||
for select in selector:
|
||||
result = select(result)
|
||||
return result
|
||||
|
||||
|
||||
##
|
||||
# Find first matching object.
|
||||
|
||||
def find(elem, path, namespaces=None):
|
||||
it = iterfind(elem, path, namespaces)
|
||||
try:
|
||||
return next(it)
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
|
||||
##
|
||||
# Find all matching objects.
|
||||
|
||||
def findall(elem, path, namespaces=None):
|
||||
return list(iterfind(elem, path, namespaces))
|
||||
|
||||
|
||||
##
|
||||
# Find text for first matching object.
|
||||
|
||||
def findtext(elem, path, default=None, namespaces=None):
|
||||
el = find(elem, path, namespaces)
|
||||
if el is None:
|
||||
return default
|
||||
else:
|
||||
return el.text or ''
|
||||
Binary file not shown.
233
acer-env/lib/python3.10/site-packages/lxml/builder.py
Normal file
233
acer-env/lib/python3.10/site-packages/lxml/builder.py
Normal file
@@ -0,0 +1,233 @@
|
||||
# cython: language_level=2
|
||||
|
||||
#
|
||||
# Element generator factory by Fredrik Lundh.
|
||||
#
|
||||
# Source:
|
||||
# http://online.effbot.org/2006_11_01_archive.htm#et-builder
|
||||
# http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py
|
||||
#
|
||||
# --------------------------------------------------------------------
|
||||
# The ElementTree toolkit is
|
||||
#
|
||||
# Copyright (c) 1999-2004 by Fredrik Lundh
|
||||
#
|
||||
# By obtaining, using, and/or copying this software and/or its
|
||||
# associated documentation, you agree that you have read, understood,
|
||||
# and will comply with the following terms and conditions:
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software and
|
||||
# its associated documentation for any purpose and without fee is
|
||||
# hereby granted, provided that the above copyright notice appears in
|
||||
# all copies, and that both that copyright notice and this permission
|
||||
# notice appear in supporting documentation, and that the name of
|
||||
# Secret Labs AB or the author not be used in advertising or publicity
|
||||
# pertaining to distribution of the software without specific, written
|
||||
# prior permission.
|
||||
#
|
||||
# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
||||
# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
|
||||
# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
|
||||
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
"""
|
||||
The ``E`` Element factory for generating XML documents.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import lxml.etree as ET
|
||||
_QName = ET.QName
|
||||
|
||||
from functools import partial
|
||||
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = str
|
||||
|
||||
try:
|
||||
unicode
|
||||
except NameError:
|
||||
unicode = str
|
||||
|
||||
|
||||
class ElementMaker(object):
|
||||
"""Element generator factory.
|
||||
|
||||
Unlike the ordinary Element factory, the E factory allows you to pass in
|
||||
more than just a tag and some optional attributes; you can also pass in
|
||||
text and other elements. The text is added as either text or tail
|
||||
attributes, and elements are inserted at the right spot. Some small
|
||||
examples::
|
||||
|
||||
>>> from lxml import etree as ET
|
||||
>>> from lxml.builder import E
|
||||
|
||||
>>> ET.tostring(E("tag"))
|
||||
'<tag/>'
|
||||
>>> ET.tostring(E("tag", "text"))
|
||||
'<tag>text</tag>'
|
||||
>>> ET.tostring(E("tag", "text", key="value"))
|
||||
'<tag key="value">text</tag>'
|
||||
>>> ET.tostring(E("tag", E("subtag", "text"), "tail"))
|
||||
'<tag><subtag>text</subtag>tail</tag>'
|
||||
|
||||
For simple tags, the factory also allows you to write ``E.tag(...)`` instead
|
||||
of ``E('tag', ...)``::
|
||||
|
||||
>>> ET.tostring(E.tag())
|
||||
'<tag/>'
|
||||
>>> ET.tostring(E.tag("text"))
|
||||
'<tag>text</tag>'
|
||||
>>> ET.tostring(E.tag(E.subtag("text"), "tail"))
|
||||
'<tag><subtag>text</subtag>tail</tag>'
|
||||
|
||||
Here's a somewhat larger example; this shows how to generate HTML
|
||||
documents, using a mix of prepared factory functions for inline elements,
|
||||
nested ``E.tag`` calls, and embedded XHTML fragments::
|
||||
|
||||
# some common inline elements
|
||||
A = E.a
|
||||
I = E.i
|
||||
B = E.b
|
||||
|
||||
def CLASS(v):
|
||||
# helper function, 'class' is a reserved word
|
||||
return {'class': v}
|
||||
|
||||
page = (
|
||||
E.html(
|
||||
E.head(
|
||||
E.title("This is a sample document")
|
||||
),
|
||||
E.body(
|
||||
E.h1("Hello!", CLASS("title")),
|
||||
E.p("This is a paragraph with ", B("bold"), " text in it!"),
|
||||
E.p("This is another paragraph, with a ",
|
||||
A("link", href="http://www.python.org"), "."),
|
||||
E.p("Here are some reserved characters: <spam&egg>."),
|
||||
ET.XML("<p>And finally, here is an embedded XHTML fragment.</p>"),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
print ET.tostring(page)
|
||||
|
||||
Here's a prettyprinted version of the output from the above script::
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>This is a sample document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="title">Hello!</h1>
|
||||
<p>This is a paragraph with <b>bold</b> text in it!</p>
|
||||
<p>This is another paragraph, with <a href="http://www.python.org">link</a>.</p>
|
||||
<p>Here are some reserved characters: <spam&egg>.</p>
|
||||
<p>And finally, here is an embedded XHTML fragment.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
For namespace support, you can pass a namespace map (``nsmap``)
|
||||
and/or a specific target ``namespace`` to the ElementMaker class::
|
||||
|
||||
>>> E = ElementMaker(namespace="http://my.ns/")
|
||||
>>> print(ET.tostring( E.test ))
|
||||
<test xmlns="http://my.ns/"/>
|
||||
|
||||
>>> E = ElementMaker(namespace="http://my.ns/", nsmap={'p':'http://my.ns/'})
|
||||
>>> print(ET.tostring( E.test ))
|
||||
<p:test xmlns:p="http://my.ns/"/>
|
||||
"""
|
||||
|
||||
def __init__(self, typemap=None,
|
||||
namespace=None, nsmap=None, makeelement=None):
|
||||
self._namespace = '{' + namespace + '}' if namespace is not None else None
|
||||
self._nsmap = dict(nsmap) if nsmap else None
|
||||
|
||||
assert makeelement is None or callable(makeelement)
|
||||
self._makeelement = makeelement if makeelement is not None else ET.Element
|
||||
|
||||
# initialize the default type map functions for this element factory
|
||||
typemap = dict(typemap) if typemap else {}
|
||||
|
||||
def add_text(elem, item):
|
||||
try:
|
||||
last_child = elem[-1]
|
||||
except IndexError:
|
||||
elem.text = (elem.text or "") + item
|
||||
else:
|
||||
last_child.tail = (last_child.tail or "") + item
|
||||
|
||||
def add_cdata(elem, cdata):
|
||||
if elem.text:
|
||||
raise ValueError("Can't add a CDATA section. Element already has some text: %r" % elem.text)
|
||||
elem.text = cdata
|
||||
|
||||
if str not in typemap:
|
||||
typemap[str] = add_text
|
||||
if unicode not in typemap:
|
||||
typemap[unicode] = add_text
|
||||
if ET.CDATA not in typemap:
|
||||
typemap[ET.CDATA] = add_cdata
|
||||
|
||||
def add_dict(elem, item):
|
||||
attrib = elem.attrib
|
||||
for k, v in item.items():
|
||||
if isinstance(v, basestring):
|
||||
attrib[k] = v
|
||||
else:
|
||||
attrib[k] = typemap[type(v)](None, v)
|
||||
|
||||
if dict not in typemap:
|
||||
typemap[dict] = add_dict
|
||||
|
||||
self._typemap = typemap
|
||||
|
||||
def __call__(self, tag, *children, **attrib):
|
||||
typemap = self._typemap
|
||||
|
||||
# We'll usually get a 'str', and the compiled type check is very fast.
|
||||
if not isinstance(tag, str) and isinstance(tag, _QName):
|
||||
# A QName is explicitly qualified, do not look at self._namespace.
|
||||
tag = tag.text
|
||||
elif self._namespace is not None and tag[0] != '{':
|
||||
tag = self._namespace + tag
|
||||
elem = self._makeelement(tag, nsmap=self._nsmap)
|
||||
if attrib:
|
||||
typemap[dict](elem, attrib)
|
||||
|
||||
for item in children:
|
||||
if callable(item):
|
||||
item = item()
|
||||
t = typemap.get(type(item))
|
||||
if t is None:
|
||||
if ET.iselement(item):
|
||||
elem.append(item)
|
||||
continue
|
||||
for basetype in type(item).__mro__:
|
||||
# See if the typemap knows of any of this type's bases.
|
||||
t = typemap.get(basetype)
|
||||
if t is not None:
|
||||
break
|
||||
else:
|
||||
raise TypeError("bad argument type: %s(%r)" %
|
||||
(type(item).__name__, item))
|
||||
v = t(elem, item)
|
||||
if v:
|
||||
typemap.get(type(v))(elem, v)
|
||||
|
||||
return elem
|
||||
|
||||
def __getattr__(self, tag):
|
||||
return partial(self, tag)
|
||||
|
||||
|
||||
# create factory object
|
||||
E = ElementMaker()
|
||||
102
acer-env/lib/python3.10/site-packages/lxml/cssselect.py
Normal file
102
acer-env/lib/python3.10/site-packages/lxml/cssselect.py
Normal file
@@ -0,0 +1,102 @@
|
||||
"""CSS Selectors based on XPath.
|
||||
|
||||
This module supports selecting XML/HTML tags based on CSS selectors.
|
||||
See the `CSSSelector` class for details.
|
||||
|
||||
This is a thin wrapper around cssselect 0.7 or later.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from . import etree
|
||||
try:
|
||||
import cssselect as external_cssselect
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
'cssselect does not seem to be installed. '
|
||||
'See http://packages.python.org/cssselect/')
|
||||
|
||||
|
||||
SelectorSyntaxError = external_cssselect.SelectorSyntaxError
|
||||
ExpressionError = external_cssselect.ExpressionError
|
||||
SelectorError = external_cssselect.SelectorError
|
||||
|
||||
|
||||
__all__ = ['SelectorSyntaxError', 'ExpressionError', 'SelectorError',
|
||||
'CSSSelector']
|
||||
|
||||
|
||||
class LxmlTranslator(external_cssselect.GenericTranslator):
|
||||
"""
|
||||
A custom CSS selector to XPath translator with lxml-specific extensions.
|
||||
"""
|
||||
def xpath_contains_function(self, xpath, function):
|
||||
# Defined there, removed in later drafts:
|
||||
# http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#content-selectors
|
||||
if function.argument_types() not in (['STRING'], ['IDENT']):
|
||||
raise ExpressionError(
|
||||
"Expected a single string or ident for :contains(), got %r"
|
||||
% function.arguments)
|
||||
value = function.arguments[0].value
|
||||
return xpath.add_condition(
|
||||
'contains(__lxml_internal_css:lower-case(string(.)), %s)'
|
||||
% self.xpath_literal(value.lower()))
|
||||
|
||||
|
||||
class LxmlHTMLTranslator(LxmlTranslator, external_cssselect.HTMLTranslator):
|
||||
"""
|
||||
lxml extensions + HTML support.
|
||||
"""
|
||||
|
||||
|
||||
def _make_lower_case(context, s):
|
||||
return s.lower()
|
||||
|
||||
ns = etree.FunctionNamespace('http://codespeak.net/lxml/css/')
|
||||
ns.prefix = '__lxml_internal_css'
|
||||
ns['lower-case'] = _make_lower_case
|
||||
|
||||
|
||||
class CSSSelector(etree.XPath):
|
||||
"""A CSS selector.
|
||||
|
||||
Usage::
|
||||
|
||||
>>> from lxml import etree, cssselect
|
||||
>>> select = cssselect.CSSSelector("a tag > child")
|
||||
|
||||
>>> root = etree.XML("<a><b><c/><tag><child>TEXT</child></tag></b></a>")
|
||||
>>> [ el.tag for el in select(root) ]
|
||||
['child']
|
||||
|
||||
To use CSS namespaces, you need to pass a prefix-to-namespace
|
||||
mapping as ``namespaces`` keyword argument::
|
||||
|
||||
>>> rdfns = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
|
||||
>>> select_ns = cssselect.CSSSelector('root > rdf|Description',
|
||||
... namespaces={'rdf': rdfns})
|
||||
|
||||
>>> rdf = etree.XML((
|
||||
... '<root xmlns:rdf="%s">'
|
||||
... '<rdf:Description>blah</rdf:Description>'
|
||||
... '</root>') % rdfns)
|
||||
>>> [(el.tag, el.text) for el in select_ns(rdf)]
|
||||
[('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description', 'blah')]
|
||||
|
||||
"""
|
||||
def __init__(self, css, namespaces=None, translator='xml'):
|
||||
if translator == 'xml':
|
||||
translator = LxmlTranslator()
|
||||
elif translator == 'html':
|
||||
translator = LxmlHTMLTranslator()
|
||||
elif translator == 'xhtml':
|
||||
translator = LxmlHTMLTranslator(xhtml=True)
|
||||
path = translator.css_to_xpath(css)
|
||||
etree.XPath.__init__(self, path, namespaces=namespaces)
|
||||
self.css = css
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s %s for %r>' % (
|
||||
self.__class__.__name__,
|
||||
hex(abs(id(self)))[2:],
|
||||
self.css)
|
||||
507
acer-env/lib/python3.10/site-packages/lxml/doctestcompare.py
Normal file
507
acer-env/lib/python3.10/site-packages/lxml/doctestcompare.py
Normal file
@@ -0,0 +1,507 @@
|
||||
"""
|
||||
lxml-based doctest output comparison.
|
||||
|
||||
Note: normally, you should just import the `lxml.usedoctest` and
|
||||
`lxml.html.usedoctest` modules from within a doctest, instead of this
|
||||
one::
|
||||
|
||||
>>> import lxml.usedoctest # for XML output
|
||||
|
||||
>>> import lxml.html.usedoctest # for HTML output
|
||||
|
||||
To use this module directly, you must call ``lxmldoctest.install()``,
|
||||
which will cause doctest to use this in all subsequent calls.
|
||||
|
||||
This changes the way output is checked and comparisons are made for
|
||||
XML or HTML-like content.
|
||||
|
||||
XML or HTML content is noticed because the example starts with ``<``
|
||||
(it's HTML if it starts with ``<html``). You can also use the
|
||||
``PARSE_HTML`` and ``PARSE_XML`` flags to force parsing.
|
||||
|
||||
Some rough wildcard-like things are allowed. Whitespace is generally
|
||||
ignored (except in attributes). In text (attributes and text in the
|
||||
body) you can use ``...`` as a wildcard. In an example it also
|
||||
matches any trailing tags in the element, though it does not match
|
||||
leading tags. You may create a tag ``<any>`` or include an ``any``
|
||||
attribute in the tag. An ``any`` tag matches any tag, while the
|
||||
attribute matches any and all attributes.
|
||||
|
||||
When a match fails, the reformatted example and gotten text is
|
||||
displayed (indented), and a rough diff-like output is given. Anything
|
||||
marked with ``+`` is in the output but wasn't supposed to be, and
|
||||
similarly ``-`` means its in the example but wasn't in the output.
|
||||
|
||||
You can disable parsing on one line with ``# doctest:+NOPARSE_MARKUP``
|
||||
"""
|
||||
|
||||
from lxml import etree
|
||||
import sys
|
||||
import re
|
||||
import doctest
|
||||
try:
|
||||
from html import escape as html_escape
|
||||
except ImportError:
|
||||
from cgi import escape as html_escape
|
||||
|
||||
__all__ = ['PARSE_HTML', 'PARSE_XML', 'NOPARSE_MARKUP', 'LXMLOutputChecker',
|
||||
'LHTMLOutputChecker', 'install', 'temp_install']
|
||||
|
||||
try:
|
||||
_basestring = basestring
|
||||
except NameError:
|
||||
_basestring = (str, bytes)
|
||||
|
||||
_IS_PYTHON_3 = sys.version_info[0] >= 3
|
||||
|
||||
PARSE_HTML = doctest.register_optionflag('PARSE_HTML')
|
||||
PARSE_XML = doctest.register_optionflag('PARSE_XML')
|
||||
NOPARSE_MARKUP = doctest.register_optionflag('NOPARSE_MARKUP')
|
||||
|
||||
OutputChecker = doctest.OutputChecker
|
||||
|
||||
def strip(v):
|
||||
if v is None:
|
||||
return None
|
||||
else:
|
||||
return v.strip()
|
||||
|
||||
def norm_whitespace(v):
|
||||
return _norm_whitespace_re.sub(' ', v)
|
||||
|
||||
_html_parser = etree.HTMLParser(recover=False, remove_blank_text=True)
|
||||
|
||||
def html_fromstring(html):
|
||||
return etree.fromstring(html, _html_parser)
|
||||
|
||||
# We use this to distinguish repr()s from elements:
|
||||
_repr_re = re.compile(r'^<[^>]+ (at|object) ')
|
||||
_norm_whitespace_re = re.compile(r'[ \t\n][ \t\n]+')
|
||||
|
||||
class LXMLOutputChecker(OutputChecker):
|
||||
|
||||
empty_tags = (
|
||||
'param', 'img', 'area', 'br', 'basefont', 'input',
|
||||
'base', 'meta', 'link', 'col')
|
||||
|
||||
def get_default_parser(self):
|
||||
return etree.XML
|
||||
|
||||
def check_output(self, want, got, optionflags):
|
||||
alt_self = getattr(self, '_temp_override_self', None)
|
||||
if alt_self is not None:
|
||||
super_method = self._temp_call_super_check_output
|
||||
self = alt_self
|
||||
else:
|
||||
super_method = OutputChecker.check_output
|
||||
parser = self.get_parser(want, got, optionflags)
|
||||
if not parser:
|
||||
return super_method(
|
||||
self, want, got, optionflags)
|
||||
try:
|
||||
want_doc = parser(want)
|
||||
except etree.XMLSyntaxError:
|
||||
return False
|
||||
try:
|
||||
got_doc = parser(got)
|
||||
except etree.XMLSyntaxError:
|
||||
return False
|
||||
return self.compare_docs(want_doc, got_doc)
|
||||
|
||||
def get_parser(self, want, got, optionflags):
|
||||
parser = None
|
||||
if NOPARSE_MARKUP & optionflags:
|
||||
return None
|
||||
if PARSE_HTML & optionflags:
|
||||
parser = html_fromstring
|
||||
elif PARSE_XML & optionflags:
|
||||
parser = etree.XML
|
||||
elif (want.strip().lower().startswith('<html')
|
||||
and got.strip().startswith('<html')):
|
||||
parser = html_fromstring
|
||||
elif (self._looks_like_markup(want)
|
||||
and self._looks_like_markup(got)):
|
||||
parser = self.get_default_parser()
|
||||
return parser
|
||||
|
||||
def _looks_like_markup(self, s):
|
||||
s = s.strip()
|
||||
return (s.startswith('<')
|
||||
and not _repr_re.search(s))
|
||||
|
||||
def compare_docs(self, want, got):
|
||||
if not self.tag_compare(want.tag, got.tag):
|
||||
return False
|
||||
if not self.text_compare(want.text, got.text, True):
|
||||
return False
|
||||
if not self.text_compare(want.tail, got.tail, True):
|
||||
return False
|
||||
if 'any' not in want.attrib:
|
||||
want_keys = sorted(want.attrib.keys())
|
||||
got_keys = sorted(got.attrib.keys())
|
||||
if want_keys != got_keys:
|
||||
return False
|
||||
for key in want_keys:
|
||||
if not self.text_compare(want.attrib[key], got.attrib[key], False):
|
||||
return False
|
||||
if want.text != '...' or len(want):
|
||||
want_children = list(want)
|
||||
got_children = list(got)
|
||||
while want_children or got_children:
|
||||
if not want_children or not got_children:
|
||||
return False
|
||||
want_first = want_children.pop(0)
|
||||
got_first = got_children.pop(0)
|
||||
if not self.compare_docs(want_first, got_first):
|
||||
return False
|
||||
if not got_children and want_first.tail == '...':
|
||||
break
|
||||
return True
|
||||
|
||||
def text_compare(self, want, got, strip):
|
||||
want = want or ''
|
||||
got = got or ''
|
||||
if strip:
|
||||
want = norm_whitespace(want).strip()
|
||||
got = norm_whitespace(got).strip()
|
||||
want = '^%s$' % re.escape(want)
|
||||
want = want.replace(r'\.\.\.', '.*')
|
||||
if re.search(want, got):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def tag_compare(self, want, got):
|
||||
if want == 'any':
|
||||
return True
|
||||
if (not isinstance(want, _basestring)
|
||||
or not isinstance(got, _basestring)):
|
||||
return want == got
|
||||
want = want or ''
|
||||
got = got or ''
|
||||
if want.startswith('{...}'):
|
||||
# Ellipsis on the namespace
|
||||
return want.split('}')[-1] == got.split('}')[-1]
|
||||
else:
|
||||
return want == got
|
||||
|
||||
def output_difference(self, example, got, optionflags):
|
||||
want = example.want
|
||||
parser = self.get_parser(want, got, optionflags)
|
||||
errors = []
|
||||
if parser is not None:
|
||||
try:
|
||||
want_doc = parser(want)
|
||||
except etree.XMLSyntaxError:
|
||||
e = sys.exc_info()[1]
|
||||
errors.append('In example: %s' % e)
|
||||
try:
|
||||
got_doc = parser(got)
|
||||
except etree.XMLSyntaxError:
|
||||
e = sys.exc_info()[1]
|
||||
errors.append('In actual output: %s' % e)
|
||||
if parser is None or errors:
|
||||
value = OutputChecker.output_difference(
|
||||
self, example, got, optionflags)
|
||||
if errors:
|
||||
errors.append(value)
|
||||
return '\n'.join(errors)
|
||||
else:
|
||||
return value
|
||||
html = parser is html_fromstring
|
||||
diff_parts = ['Expected:',
|
||||
self.format_doc(want_doc, html, 2),
|
||||
'Got:',
|
||||
self.format_doc(got_doc, html, 2),
|
||||
'Diff:',
|
||||
self.collect_diff(want_doc, got_doc, html, 2)]
|
||||
return '\n'.join(diff_parts)
|
||||
|
||||
def html_empty_tag(self, el, html=True):
|
||||
if not html:
|
||||
return False
|
||||
if el.tag not in self.empty_tags:
|
||||
return False
|
||||
if el.text or len(el):
|
||||
# This shouldn't happen (contents in an empty tag)
|
||||
return False
|
||||
return True
|
||||
|
||||
def format_doc(self, doc, html, indent, prefix=''):
|
||||
parts = []
|
||||
if not len(doc):
|
||||
# No children...
|
||||
parts.append(' '*indent)
|
||||
parts.append(prefix)
|
||||
parts.append(self.format_tag(doc))
|
||||
if not self.html_empty_tag(doc, html):
|
||||
if strip(doc.text):
|
||||
parts.append(self.format_text(doc.text))
|
||||
parts.append(self.format_end_tag(doc))
|
||||
if strip(doc.tail):
|
||||
parts.append(self.format_text(doc.tail))
|
||||
parts.append('\n')
|
||||
return ''.join(parts)
|
||||
parts.append(' '*indent)
|
||||
parts.append(prefix)
|
||||
parts.append(self.format_tag(doc))
|
||||
if not self.html_empty_tag(doc, html):
|
||||
parts.append('\n')
|
||||
if strip(doc.text):
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.format_text(doc.text))
|
||||
parts.append('\n')
|
||||
for el in doc:
|
||||
parts.append(self.format_doc(el, html, indent+2))
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.format_end_tag(doc))
|
||||
parts.append('\n')
|
||||
if strip(doc.tail):
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.format_text(doc.tail))
|
||||
parts.append('\n')
|
||||
return ''.join(parts)
|
||||
|
||||
def format_text(self, text, strip=True):
|
||||
if text is None:
|
||||
return ''
|
||||
if strip:
|
||||
text = text.strip()
|
||||
return html_escape(text, 1)
|
||||
|
||||
def format_tag(self, el):
|
||||
attrs = []
|
||||
if isinstance(el, etree.CommentBase):
|
||||
# FIXME: probably PIs should be handled specially too?
|
||||
return '<!--'
|
||||
for name, value in sorted(el.attrib.items()):
|
||||
attrs.append('%s="%s"' % (name, self.format_text(value, False)))
|
||||
if not attrs:
|
||||
return '<%s>' % el.tag
|
||||
return '<%s %s>' % (el.tag, ' '.join(attrs))
|
||||
|
||||
def format_end_tag(self, el):
|
||||
if isinstance(el, etree.CommentBase):
|
||||
# FIXME: probably PIs should be handled specially too?
|
||||
return '-->'
|
||||
return '</%s>' % el.tag
|
||||
|
||||
def collect_diff(self, want, got, html, indent):
|
||||
parts = []
|
||||
if not len(want) and not len(got):
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.collect_diff_tag(want, got))
|
||||
if not self.html_empty_tag(got, html):
|
||||
parts.append(self.collect_diff_text(want.text, got.text))
|
||||
parts.append(self.collect_diff_end_tag(want, got))
|
||||
parts.append(self.collect_diff_text(want.tail, got.tail))
|
||||
parts.append('\n')
|
||||
return ''.join(parts)
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.collect_diff_tag(want, got))
|
||||
parts.append('\n')
|
||||
if strip(want.text) or strip(got.text):
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.collect_diff_text(want.text, got.text))
|
||||
parts.append('\n')
|
||||
want_children = list(want)
|
||||
got_children = list(got)
|
||||
while want_children or got_children:
|
||||
if not want_children:
|
||||
parts.append(self.format_doc(got_children.pop(0), html, indent+2, '+'))
|
||||
continue
|
||||
if not got_children:
|
||||
parts.append(self.format_doc(want_children.pop(0), html, indent+2, '-'))
|
||||
continue
|
||||
parts.append(self.collect_diff(
|
||||
want_children.pop(0), got_children.pop(0), html, indent+2))
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.collect_diff_end_tag(want, got))
|
||||
parts.append('\n')
|
||||
if strip(want.tail) or strip(got.tail):
|
||||
parts.append(' '*indent)
|
||||
parts.append(self.collect_diff_text(want.tail, got.tail))
|
||||
parts.append('\n')
|
||||
return ''.join(parts)
|
||||
|
||||
def collect_diff_tag(self, want, got):
|
||||
if not self.tag_compare(want.tag, got.tag):
|
||||
tag = '%s (got: %s)' % (want.tag, got.tag)
|
||||
else:
|
||||
tag = got.tag
|
||||
attrs = []
|
||||
any = want.tag == 'any' or 'any' in want.attrib
|
||||
for name, value in sorted(got.attrib.items()):
|
||||
if name not in want.attrib and not any:
|
||||
attrs.append('+%s="%s"' % (name, self.format_text(value, False)))
|
||||
else:
|
||||
if name in want.attrib:
|
||||
text = self.collect_diff_text(want.attrib[name], value, False)
|
||||
else:
|
||||
text = self.format_text(value, False)
|
||||
attrs.append('%s="%s"' % (name, text))
|
||||
if not any:
|
||||
for name, value in sorted(want.attrib.items()):
|
||||
if name in got.attrib:
|
||||
continue
|
||||
attrs.append('-%s="%s"' % (name, self.format_text(value, False)))
|
||||
if attrs:
|
||||
tag = '<%s %s>' % (tag, ' '.join(attrs))
|
||||
else:
|
||||
tag = '<%s>' % tag
|
||||
return tag
|
||||
|
||||
def collect_diff_end_tag(self, want, got):
|
||||
if want.tag != got.tag:
|
||||
tag = '%s (got: %s)' % (want.tag, got.tag)
|
||||
else:
|
||||
tag = got.tag
|
||||
return '</%s>' % tag
|
||||
|
||||
def collect_diff_text(self, want, got, strip=True):
|
||||
if self.text_compare(want, got, strip):
|
||||
if not got:
|
||||
return ''
|
||||
return self.format_text(got, strip)
|
||||
text = '%s (got: %s)' % (want, got)
|
||||
return self.format_text(text, strip)
|
||||
|
||||
class LHTMLOutputChecker(LXMLOutputChecker):
|
||||
def get_default_parser(self):
|
||||
return html_fromstring
|
||||
|
||||
def install(html=False):
|
||||
"""
|
||||
Install doctestcompare for all future doctests.
|
||||
|
||||
If html is true, then by default the HTML parser will be used;
|
||||
otherwise the XML parser is used.
|
||||
"""
|
||||
if html:
|
||||
doctest.OutputChecker = LHTMLOutputChecker
|
||||
else:
|
||||
doctest.OutputChecker = LXMLOutputChecker
|
||||
|
||||
def temp_install(html=False, del_module=None):
|
||||
"""
|
||||
Use this *inside* a doctest to enable this checker for this
|
||||
doctest only.
|
||||
|
||||
If html is true, then by default the HTML parser will be used;
|
||||
otherwise the XML parser is used.
|
||||
"""
|
||||
if html:
|
||||
Checker = LHTMLOutputChecker
|
||||
else:
|
||||
Checker = LXMLOutputChecker
|
||||
frame = _find_doctest_frame()
|
||||
dt_self = frame.f_locals['self']
|
||||
checker = Checker()
|
||||
old_checker = dt_self._checker
|
||||
dt_self._checker = checker
|
||||
# The unfortunate thing is that there is a local variable 'check'
|
||||
# in the function that runs the doctests, that is a bound method
|
||||
# into the output checker. We have to update that. We can't
|
||||
# modify the frame, so we have to modify the object in place. The
|
||||
# only way to do this is to actually change the func_code
|
||||
# attribute of the method. We change it, and then wait for
|
||||
# __record_outcome to be run, which signals the end of the __run
|
||||
# method, at which point we restore the previous check_output
|
||||
# implementation.
|
||||
if _IS_PYTHON_3:
|
||||
check_func = frame.f_locals['check'].__func__
|
||||
checker_check_func = checker.check_output.__func__
|
||||
else:
|
||||
check_func = frame.f_locals['check'].im_func
|
||||
checker_check_func = checker.check_output.im_func
|
||||
# Because we can't patch up func_globals, this is the only global
|
||||
# in check_output that we care about:
|
||||
doctest.etree = etree
|
||||
_RestoreChecker(dt_self, old_checker, checker,
|
||||
check_func, checker_check_func,
|
||||
del_module)
|
||||
|
||||
class _RestoreChecker(object):
|
||||
def __init__(self, dt_self, old_checker, new_checker, check_func, clone_func,
|
||||
del_module):
|
||||
self.dt_self = dt_self
|
||||
self.checker = old_checker
|
||||
self.checker._temp_call_super_check_output = self.call_super
|
||||
self.checker._temp_override_self = new_checker
|
||||
self.check_func = check_func
|
||||
self.clone_func = clone_func
|
||||
self.del_module = del_module
|
||||
self.install_clone()
|
||||
self.install_dt_self()
|
||||
def install_clone(self):
|
||||
if _IS_PYTHON_3:
|
||||
self.func_code = self.check_func.__code__
|
||||
self.func_globals = self.check_func.__globals__
|
||||
self.check_func.__code__ = self.clone_func.__code__
|
||||
else:
|
||||
self.func_code = self.check_func.func_code
|
||||
self.func_globals = self.check_func.func_globals
|
||||
self.check_func.func_code = self.clone_func.func_code
|
||||
def uninstall_clone(self):
|
||||
if _IS_PYTHON_3:
|
||||
self.check_func.__code__ = self.func_code
|
||||
else:
|
||||
self.check_func.func_code = self.func_code
|
||||
def install_dt_self(self):
|
||||
self.prev_func = self.dt_self._DocTestRunner__record_outcome
|
||||
self.dt_self._DocTestRunner__record_outcome = self
|
||||
def uninstall_dt_self(self):
|
||||
self.dt_self._DocTestRunner__record_outcome = self.prev_func
|
||||
def uninstall_module(self):
|
||||
if self.del_module:
|
||||
import sys
|
||||
del sys.modules[self.del_module]
|
||||
if '.' in self.del_module:
|
||||
package, module = self.del_module.rsplit('.', 1)
|
||||
package_mod = sys.modules[package]
|
||||
delattr(package_mod, module)
|
||||
def __call__(self, *args, **kw):
|
||||
self.uninstall_clone()
|
||||
self.uninstall_dt_self()
|
||||
del self.checker._temp_override_self
|
||||
del self.checker._temp_call_super_check_output
|
||||
result = self.prev_func(*args, **kw)
|
||||
self.uninstall_module()
|
||||
return result
|
||||
def call_super(self, *args, **kw):
|
||||
self.uninstall_clone()
|
||||
try:
|
||||
return self.check_func(*args, **kw)
|
||||
finally:
|
||||
self.install_clone()
|
||||
|
||||
def _find_doctest_frame():
|
||||
import sys
|
||||
frame = sys._getframe(1)
|
||||
while frame:
|
||||
l = frame.f_locals
|
||||
if 'BOOM' in l:
|
||||
# Sign of doctest
|
||||
return frame
|
||||
frame = frame.f_back
|
||||
raise LookupError(
|
||||
"Could not find doctest (only use this function *inside* a doctest)")
|
||||
|
||||
__test__ = {
|
||||
'basic': '''
|
||||
>>> temp_install()
|
||||
>>> print """<xml a="1" b="2">stuff</xml>"""
|
||||
<xml b="2" a="1">...</xml>
|
||||
>>> print """<xml xmlns="http://example.com"><tag attr="bar" /></xml>"""
|
||||
<xml xmlns="...">
|
||||
<tag attr="..." />
|
||||
</xml>
|
||||
>>> print """<xml>blahblahblah<foo /></xml>""" # doctest: +NOPARSE_MARKUP, +ELLIPSIS
|
||||
<xml>...foo /></xml>
|
||||
'''}
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
|
||||
BIN
acer-env/lib/python3.10/site-packages/lxml/etree.cpython-310-x86_64-linux-gnu.so
Executable file
BIN
acer-env/lib/python3.10/site-packages/lxml/etree.cpython-310-x86_64-linux-gnu.so
Executable file
Binary file not shown.
224
acer-env/lib/python3.10/site-packages/lxml/etree.h
Normal file
224
acer-env/lib/python3.10/site-packages/lxml/etree.h
Normal file
@@ -0,0 +1,224 @@
|
||||
/* Generated by Cython 0.29.30 */
|
||||
|
||||
#ifndef __PYX_HAVE__lxml__etree
|
||||
#define __PYX_HAVE__lxml__etree
|
||||
|
||||
#include "Python.h"
|
||||
struct LxmlDocument;
|
||||
struct LxmlElement;
|
||||
struct LxmlElementTree;
|
||||
struct LxmlElementTagMatcher;
|
||||
struct LxmlElementIterator;
|
||||
struct LxmlElementBase;
|
||||
struct LxmlElementClassLookup;
|
||||
struct LxmlFallbackElementClassLookup;
|
||||
|
||||
/* "lxml/etree.pyx":337
|
||||
*
|
||||
* # type of a function that steps from node to node
|
||||
* ctypedef public xmlNode* (*_node_to_node_function)(xmlNode*) # <<<<<<<<<<<<<<
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef xmlNode *(*_node_to_node_function)(xmlNode *);
|
||||
|
||||
/* "lxml/etree.pyx":353
|
||||
* @cython.final
|
||||
* @cython.freelist(8)
|
||||
* cdef public class _Document [ type LxmlDocumentType, object LxmlDocument ]: # <<<<<<<<<<<<<<
|
||||
* u"""Internal base class to reference a libxml document.
|
||||
*
|
||||
*/
|
||||
struct LxmlDocument {
|
||||
PyObject_HEAD
|
||||
struct __pyx_vtabstruct_4lxml_5etree__Document *__pyx_vtab;
|
||||
int _ns_counter;
|
||||
PyObject *_prefix_tail;
|
||||
xmlDoc *_c_doc;
|
||||
struct __pyx_obj_4lxml_5etree__BaseParser *_parser;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":702
|
||||
*
|
||||
* @cython.no_gc_clear
|
||||
* cdef public class _Element [ type LxmlElementType, object LxmlElement ]: # <<<<<<<<<<<<<<
|
||||
* u"""Element class.
|
||||
*
|
||||
*/
|
||||
struct LxmlElement {
|
||||
PyObject_HEAD
|
||||
struct LxmlDocument *_doc;
|
||||
xmlNode *_c_node;
|
||||
PyObject *_tag;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":1871
|
||||
*
|
||||
*
|
||||
* cdef public class _ElementTree [ type LxmlElementTreeType, # <<<<<<<<<<<<<<
|
||||
* object LxmlElementTree ]:
|
||||
* cdef _Document _doc
|
||||
*/
|
||||
struct LxmlElementTree {
|
||||
PyObject_HEAD
|
||||
struct __pyx_vtabstruct_4lxml_5etree__ElementTree *__pyx_vtab;
|
||||
struct LxmlDocument *_doc;
|
||||
struct LxmlElement *_context_node;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":2615
|
||||
*
|
||||
*
|
||||
* cdef public class _ElementTagMatcher [ object LxmlElementTagMatcher, # <<<<<<<<<<<<<<
|
||||
* type LxmlElementTagMatcherType ]:
|
||||
* """
|
||||
*/
|
||||
struct LxmlElementTagMatcher {
|
||||
PyObject_HEAD
|
||||
struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher *__pyx_vtab;
|
||||
PyObject *_pystrings;
|
||||
int _node_type;
|
||||
char *_href;
|
||||
char *_name;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":2646
|
||||
* self._name = NULL
|
||||
*
|
||||
* cdef public class _ElementIterator(_ElementTagMatcher) [ # <<<<<<<<<<<<<<
|
||||
* object LxmlElementIterator, type LxmlElementIteratorType ]:
|
||||
* """
|
||||
*/
|
||||
struct LxmlElementIterator {
|
||||
struct LxmlElementTagMatcher __pyx_base;
|
||||
struct LxmlElement *_node;
|
||||
_node_to_node_function _next_element;
|
||||
};
|
||||
|
||||
/* "src/lxml/classlookup.pxi":6
|
||||
* # Custom Element classes
|
||||
*
|
||||
* cdef public class ElementBase(_Element) [ type LxmlElementBaseType, # <<<<<<<<<<<<<<
|
||||
* object LxmlElementBase ]:
|
||||
* u"""ElementBase(*children, attrib=None, nsmap=None, **_extra)
|
||||
*/
|
||||
struct LxmlElementBase {
|
||||
struct LxmlElement __pyx_base;
|
||||
};
|
||||
|
||||
/* "src/lxml/classlookup.pxi":210
|
||||
* # Element class lookup
|
||||
*
|
||||
* ctypedef public object (*_element_class_lookup_function)(object, _Document, xmlNode*) # <<<<<<<<<<<<<<
|
||||
*
|
||||
* # class to store element class lookup functions
|
||||
*/
|
||||
typedef PyObject *(*_element_class_lookup_function)(PyObject *, struct LxmlDocument *, xmlNode *);
|
||||
|
||||
/* "src/lxml/classlookup.pxi":213
|
||||
*
|
||||
* # class to store element class lookup functions
|
||||
* cdef public class ElementClassLookup [ type LxmlElementClassLookupType, # <<<<<<<<<<<<<<
|
||||
* object LxmlElementClassLookup ]:
|
||||
* u"""ElementClassLookup(self)
|
||||
*/
|
||||
struct LxmlElementClassLookup {
|
||||
PyObject_HEAD
|
||||
_element_class_lookup_function _lookup_function;
|
||||
};
|
||||
|
||||
/* "src/lxml/classlookup.pxi":221
|
||||
*
|
||||
*
|
||||
* cdef public class FallbackElementClassLookup(ElementClassLookup) \ # <<<<<<<<<<<<<<
|
||||
* [ type LxmlFallbackElementClassLookupType,
|
||||
* object LxmlFallbackElementClassLookup ]:
|
||||
*/
|
||||
struct LxmlFallbackElementClassLookup {
|
||||
struct LxmlElementClassLookup __pyx_base;
|
||||
struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup *__pyx_vtab;
|
||||
struct LxmlElementClassLookup *fallback;
|
||||
_element_class_lookup_function _fallback_function;
|
||||
};
|
||||
|
||||
#ifndef __PYX_HAVE_API__lxml__etree
|
||||
|
||||
#ifndef __PYX_EXTERN_C
|
||||
#ifdef __cplusplus
|
||||
#define __PYX_EXTERN_C extern "C"
|
||||
#else
|
||||
#define __PYX_EXTERN_C extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DL_IMPORT
|
||||
#define DL_IMPORT(_T) _T
|
||||
#endif
|
||||
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlDocumentType;
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementType;
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementTreeType;
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementTagMatcherType;
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementIteratorType;
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementBaseType;
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementClassLookupType;
|
||||
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlFallbackElementClassLookupType;
|
||||
|
||||
__PYX_EXTERN_C struct LxmlElement *deepcopyNodeToDocument(struct LxmlDocument *, xmlNode *);
|
||||
__PYX_EXTERN_C struct LxmlElementTree *elementTreeFactory(struct LxmlElement *);
|
||||
__PYX_EXTERN_C struct LxmlElementTree *newElementTree(struct LxmlElement *, PyObject *);
|
||||
__PYX_EXTERN_C struct LxmlElementTree *adoptExternalDocument(xmlDoc *, PyObject *, int);
|
||||
__PYX_EXTERN_C struct LxmlElement *elementFactory(struct LxmlDocument *, xmlNode *);
|
||||
__PYX_EXTERN_C struct LxmlElement *makeElement(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);
|
||||
__PYX_EXTERN_C struct LxmlElement *makeSubElement(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);
|
||||
__PYX_EXTERN_C void setElementClassLookupFunction(_element_class_lookup_function, PyObject *);
|
||||
__PYX_EXTERN_C PyObject *lookupDefaultElementClass(PyObject *, PyObject *, xmlNode *);
|
||||
__PYX_EXTERN_C PyObject *lookupNamespaceElementClass(PyObject *, PyObject *, xmlNode *);
|
||||
__PYX_EXTERN_C PyObject *callLookupFallback(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *);
|
||||
__PYX_EXTERN_C int tagMatches(xmlNode *, const xmlChar *, const xmlChar *);
|
||||
__PYX_EXTERN_C struct LxmlDocument *documentOrRaise(PyObject *);
|
||||
__PYX_EXTERN_C struct LxmlElement *rootNodeOrRaise(PyObject *);
|
||||
__PYX_EXTERN_C int hasText(xmlNode *);
|
||||
__PYX_EXTERN_C int hasTail(xmlNode *);
|
||||
__PYX_EXTERN_C PyObject *textOf(xmlNode *);
|
||||
__PYX_EXTERN_C PyObject *tailOf(xmlNode *);
|
||||
__PYX_EXTERN_C int setNodeText(xmlNode *, PyObject *);
|
||||
__PYX_EXTERN_C int setTailText(xmlNode *, PyObject *);
|
||||
__PYX_EXTERN_C PyObject *attributeValue(xmlNode *, xmlAttr *);
|
||||
__PYX_EXTERN_C PyObject *attributeValueFromNsName(xmlNode *, const xmlChar *, const xmlChar *);
|
||||
__PYX_EXTERN_C PyObject *getAttributeValue(struct LxmlElement *, PyObject *, PyObject *);
|
||||
__PYX_EXTERN_C PyObject *iterattributes(struct LxmlElement *, int);
|
||||
__PYX_EXTERN_C PyObject *collectAttributes(xmlNode *, int);
|
||||
__PYX_EXTERN_C int setAttributeValue(struct LxmlElement *, PyObject *, PyObject *);
|
||||
__PYX_EXTERN_C int delAttribute(struct LxmlElement *, PyObject *);
|
||||
__PYX_EXTERN_C int delAttributeFromNsName(xmlNode *, const xmlChar *, const xmlChar *);
|
||||
__PYX_EXTERN_C int hasChild(xmlNode *);
|
||||
__PYX_EXTERN_C xmlNode *findChild(xmlNode *, Py_ssize_t);
|
||||
__PYX_EXTERN_C xmlNode *findChildForwards(xmlNode *, Py_ssize_t);
|
||||
__PYX_EXTERN_C xmlNode *findChildBackwards(xmlNode *, Py_ssize_t);
|
||||
__PYX_EXTERN_C xmlNode *nextElement(xmlNode *);
|
||||
__PYX_EXTERN_C xmlNode *previousElement(xmlNode *);
|
||||
__PYX_EXTERN_C void appendChild(struct LxmlElement *, struct LxmlElement *);
|
||||
__PYX_EXTERN_C int appendChildToElement(struct LxmlElement *, struct LxmlElement *);
|
||||
__PYX_EXTERN_C PyObject *pyunicode(const xmlChar *);
|
||||
__PYX_EXTERN_C PyObject *utf8(PyObject *);
|
||||
__PYX_EXTERN_C PyObject *getNsTag(PyObject *);
|
||||
__PYX_EXTERN_C PyObject *getNsTagWithEmptyNs(PyObject *);
|
||||
__PYX_EXTERN_C PyObject *namespacedName(xmlNode *);
|
||||
__PYX_EXTERN_C PyObject *namespacedNameFromNsName(const xmlChar *, const xmlChar *);
|
||||
__PYX_EXTERN_C void iteratorStoreNext(struct LxmlElementIterator *, struct LxmlElement *);
|
||||
__PYX_EXTERN_C void initTagMatch(struct LxmlElementTagMatcher *, PyObject *);
|
||||
__PYX_EXTERN_C xmlNs *findOrBuildNodeNsPrefix(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *);
|
||||
|
||||
#endif /* !__PYX_HAVE_API__lxml__etree */
|
||||
|
||||
/* WARNING: the interface of the module init function changed in CPython 3.5. */
|
||||
/* It now returns a PyModuleDef instance instead of a PyModule instance. */
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
PyMODINIT_FUNC initetree(void);
|
||||
#else
|
||||
PyMODINIT_FUNC PyInit_etree(void);
|
||||
#endif
|
||||
|
||||
#endif /* !__PYX_HAVE__lxml__etree */
|
||||
219
acer-env/lib/python3.10/site-packages/lxml/etree_api.h
Normal file
219
acer-env/lib/python3.10/site-packages/lxml/etree_api.h
Normal file
@@ -0,0 +1,219 @@
|
||||
/* Generated by Cython 0.29.30 */
|
||||
|
||||
#ifndef __PYX_HAVE_API__lxml__etree
|
||||
#define __PYX_HAVE_API__lxml__etree
|
||||
#ifdef __MINGW64__
|
||||
#define MS_WIN64
|
||||
#endif
|
||||
#include "Python.h"
|
||||
#include "etree.h"
|
||||
|
||||
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument)(struct LxmlDocument *, xmlNode *) = 0;
|
||||
#define deepcopyNodeToDocument __pyx_api_f_4lxml_5etree_deepcopyNodeToDocument
|
||||
static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_elementTreeFactory)(struct LxmlElement *) = 0;
|
||||
#define elementTreeFactory __pyx_api_f_4lxml_5etree_elementTreeFactory
|
||||
static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_newElementTree)(struct LxmlElement *, PyObject *) = 0;
|
||||
#define newElementTree __pyx_api_f_4lxml_5etree_newElementTree
|
||||
static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_adoptExternalDocument)(xmlDoc *, PyObject *, int) = 0;
|
||||
#define adoptExternalDocument __pyx_api_f_4lxml_5etree_adoptExternalDocument
|
||||
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_elementFactory)(struct LxmlDocument *, xmlNode *) = 0;
|
||||
#define elementFactory __pyx_api_f_4lxml_5etree_elementFactory
|
||||
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeElement)(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
|
||||
#define makeElement __pyx_api_f_4lxml_5etree_makeElement
|
||||
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeSubElement)(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
|
||||
#define makeSubElement __pyx_api_f_4lxml_5etree_makeSubElement
|
||||
static void (*__pyx_api_f_4lxml_5etree_setElementClassLookupFunction)(_element_class_lookup_function, PyObject *) = 0;
|
||||
#define setElementClassLookupFunction __pyx_api_f_4lxml_5etree_setElementClassLookupFunction
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_lookupDefaultElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
|
||||
#define lookupDefaultElementClass __pyx_api_f_4lxml_5etree_lookupDefaultElementClass
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
|
||||
#define lookupNamespaceElementClass __pyx_api_f_4lxml_5etree_lookupNamespaceElementClass
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_callLookupFallback)(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *) = 0;
|
||||
#define callLookupFallback __pyx_api_f_4lxml_5etree_callLookupFallback
|
||||
static int (*__pyx_api_f_4lxml_5etree_tagMatches)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
||||
#define tagMatches __pyx_api_f_4lxml_5etree_tagMatches
|
||||
static struct LxmlDocument *(*__pyx_api_f_4lxml_5etree_documentOrRaise)(PyObject *) = 0;
|
||||
#define documentOrRaise __pyx_api_f_4lxml_5etree_documentOrRaise
|
||||
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_rootNodeOrRaise)(PyObject *) = 0;
|
||||
#define rootNodeOrRaise __pyx_api_f_4lxml_5etree_rootNodeOrRaise
|
||||
static int (*__pyx_api_f_4lxml_5etree_hasText)(xmlNode *) = 0;
|
||||
#define hasText __pyx_api_f_4lxml_5etree_hasText
|
||||
static int (*__pyx_api_f_4lxml_5etree_hasTail)(xmlNode *) = 0;
|
||||
#define hasTail __pyx_api_f_4lxml_5etree_hasTail
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_textOf)(xmlNode *) = 0;
|
||||
#define textOf __pyx_api_f_4lxml_5etree_textOf
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_tailOf)(xmlNode *) = 0;
|
||||
#define tailOf __pyx_api_f_4lxml_5etree_tailOf
|
||||
static int (*__pyx_api_f_4lxml_5etree_setNodeText)(xmlNode *, PyObject *) = 0;
|
||||
#define setNodeText __pyx_api_f_4lxml_5etree_setNodeText
|
||||
static int (*__pyx_api_f_4lxml_5etree_setTailText)(xmlNode *, PyObject *) = 0;
|
||||
#define setTailText __pyx_api_f_4lxml_5etree_setTailText
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValue)(xmlNode *, xmlAttr *) = 0;
|
||||
#define attributeValue __pyx_api_f_4lxml_5etree_attributeValue
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValueFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
||||
#define attributeValueFromNsName __pyx_api_f_4lxml_5etree_attributeValueFromNsName
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_getAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
|
||||
#define getAttributeValue __pyx_api_f_4lxml_5etree_getAttributeValue
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_iterattributes)(struct LxmlElement *, int) = 0;
|
||||
#define iterattributes __pyx_api_f_4lxml_5etree_iterattributes
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_collectAttributes)(xmlNode *, int) = 0;
|
||||
#define collectAttributes __pyx_api_f_4lxml_5etree_collectAttributes
|
||||
static int (*__pyx_api_f_4lxml_5etree_setAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
|
||||
#define setAttributeValue __pyx_api_f_4lxml_5etree_setAttributeValue
|
||||
static int (*__pyx_api_f_4lxml_5etree_delAttribute)(struct LxmlElement *, PyObject *) = 0;
|
||||
#define delAttribute __pyx_api_f_4lxml_5etree_delAttribute
|
||||
static int (*__pyx_api_f_4lxml_5etree_delAttributeFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
||||
#define delAttributeFromNsName __pyx_api_f_4lxml_5etree_delAttributeFromNsName
|
||||
static int (*__pyx_api_f_4lxml_5etree_hasChild)(xmlNode *) = 0;
|
||||
#define hasChild __pyx_api_f_4lxml_5etree_hasChild
|
||||
static xmlNode *(*__pyx_api_f_4lxml_5etree_findChild)(xmlNode *, Py_ssize_t) = 0;
|
||||
#define findChild __pyx_api_f_4lxml_5etree_findChild
|
||||
static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildForwards)(xmlNode *, Py_ssize_t) = 0;
|
||||
#define findChildForwards __pyx_api_f_4lxml_5etree_findChildForwards
|
||||
static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildBackwards)(xmlNode *, Py_ssize_t) = 0;
|
||||
#define findChildBackwards __pyx_api_f_4lxml_5etree_findChildBackwards
|
||||
static xmlNode *(*__pyx_api_f_4lxml_5etree_nextElement)(xmlNode *) = 0;
|
||||
#define nextElement __pyx_api_f_4lxml_5etree_nextElement
|
||||
static xmlNode *(*__pyx_api_f_4lxml_5etree_previousElement)(xmlNode *) = 0;
|
||||
#define previousElement __pyx_api_f_4lxml_5etree_previousElement
|
||||
static void (*__pyx_api_f_4lxml_5etree_appendChild)(struct LxmlElement *, struct LxmlElement *) = 0;
|
||||
#define appendChild __pyx_api_f_4lxml_5etree_appendChild
|
||||
static int (*__pyx_api_f_4lxml_5etree_appendChildToElement)(struct LxmlElement *, struct LxmlElement *) = 0;
|
||||
#define appendChildToElement __pyx_api_f_4lxml_5etree_appendChildToElement
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_pyunicode)(const xmlChar *) = 0;
|
||||
#define pyunicode __pyx_api_f_4lxml_5etree_pyunicode
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_utf8)(PyObject *) = 0;
|
||||
#define utf8 __pyx_api_f_4lxml_5etree_utf8
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTag)(PyObject *) = 0;
|
||||
#define getNsTag __pyx_api_f_4lxml_5etree_getNsTag
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs)(PyObject *) = 0;
|
||||
#define getNsTagWithEmptyNs __pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedName)(xmlNode *) = 0;
|
||||
#define namespacedName __pyx_api_f_4lxml_5etree_namespacedName
|
||||
static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedNameFromNsName)(const xmlChar *, const xmlChar *) = 0;
|
||||
#define namespacedNameFromNsName __pyx_api_f_4lxml_5etree_namespacedNameFromNsName
|
||||
static void (*__pyx_api_f_4lxml_5etree_iteratorStoreNext)(struct LxmlElementIterator *, struct LxmlElement *) = 0;
|
||||
#define iteratorStoreNext __pyx_api_f_4lxml_5etree_iteratorStoreNext
|
||||
static void (*__pyx_api_f_4lxml_5etree_initTagMatch)(struct LxmlElementTagMatcher *, PyObject *) = 0;
|
||||
#define initTagMatch __pyx_api_f_4lxml_5etree_initTagMatch
|
||||
static xmlNs *(*__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix)(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
||||
#define findOrBuildNodeNsPrefix __pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix
|
||||
#if !defined(__Pyx_PyIdentifier_FromString)
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
|
||||
#else
|
||||
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PYX_HAVE_RT_ImportFunction
|
||||
#define __PYX_HAVE_RT_ImportFunction
|
||||
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
||||
PyObject *d = 0;
|
||||
PyObject *cobj = 0;
|
||||
union {
|
||||
void (*fp)(void);
|
||||
void *p;
|
||||
} tmp;
|
||||
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
|
||||
if (!d)
|
||||
goto bad;
|
||||
cobj = PyDict_GetItemString(d, funcname);
|
||||
if (!cobj) {
|
||||
PyErr_Format(PyExc_ImportError,
|
||||
"%.200s does not export expected C function %.200s",
|
||||
PyModule_GetName(module), funcname);
|
||||
goto bad;
|
||||
}
|
||||
#if PY_VERSION_HEX >= 0x02070000
|
||||
if (!PyCapsule_IsValid(cobj, sig)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
|
||||
goto bad;
|
||||
}
|
||||
tmp.p = PyCapsule_GetPointer(cobj, sig);
|
||||
#else
|
||||
{const char *desc, *s1, *s2;
|
||||
desc = (const char *)PyCObject_GetDesc(cobj);
|
||||
if (!desc)
|
||||
goto bad;
|
||||
s1 = desc; s2 = sig;
|
||||
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
|
||||
if (*s1 != *s2) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||
PyModule_GetName(module), funcname, sig, desc);
|
||||
goto bad;
|
||||
}
|
||||
tmp.p = PyCObject_AsVoidPtr(cobj);}
|
||||
#endif
|
||||
*f = tmp.fp;
|
||||
if (!(*f))
|
||||
goto bad;
|
||||
Py_DECREF(d);
|
||||
return 0;
|
||||
bad:
|
||||
Py_XDECREF(d);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int import_lxml__etree(void) {
|
||||
PyObject *module = 0;
|
||||
module = PyImport_ImportModule("lxml.etree");
|
||||
if (!module) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "deepcopyNodeToDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "elementTreeFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementTreeFactory, "struct LxmlElementTree *(struct LxmlElement *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "newElementTree", (void (**)(void))&__pyx_api_f_4lxml_5etree_newElementTree, "struct LxmlElementTree *(struct LxmlElement *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "adoptExternalDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_adoptExternalDocument, "struct LxmlElementTree *(xmlDoc *, PyObject *, int)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "elementFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementFactory, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "makeElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeElement, "struct LxmlElement *(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "makeSubElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeSubElement, "struct LxmlElement *(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "setElementClassLookupFunction", (void (**)(void))&__pyx_api_f_4lxml_5etree_setElementClassLookupFunction, "void (_element_class_lookup_function, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "lookupDefaultElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupDefaultElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "lookupNamespaceElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "callLookupFallback", (void (**)(void))&__pyx_api_f_4lxml_5etree_callLookupFallback, "PyObject *(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "tagMatches", (void (**)(void))&__pyx_api_f_4lxml_5etree_tagMatches, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "documentOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_documentOrRaise, "struct LxmlDocument *(PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "rootNodeOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_rootNodeOrRaise, "struct LxmlElement *(PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "hasText", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasText, "int (xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "hasTail", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasTail, "int (xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "textOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_textOf, "PyObject *(xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "tailOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_tailOf, "PyObject *(xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "setNodeText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setNodeText, "int (xmlNode *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "setTailText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setTailText, "int (xmlNode *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "attributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValue, "PyObject *(xmlNode *, xmlAttr *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "attributeValueFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValueFromNsName, "PyObject *(xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "getAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_getAttributeValue, "PyObject *(struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "iterattributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_iterattributes, "PyObject *(struct LxmlElement *, int)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "collectAttributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_collectAttributes, "PyObject *(xmlNode *, int)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "setAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_setAttributeValue, "int (struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "delAttribute", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttribute, "int (struct LxmlElement *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "delAttributeFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttributeFromNsName, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "hasChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasChild, "int (xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "findChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChild, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "findChildForwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildForwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "findChildBackwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildBackwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "nextElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_nextElement, "xmlNode *(xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "previousElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_previousElement, "xmlNode *(xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "appendChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChild, "void (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "appendChildToElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChildToElement, "int (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "pyunicode", (void (**)(void))&__pyx_api_f_4lxml_5etree_pyunicode, "PyObject *(const xmlChar *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "utf8", (void (**)(void))&__pyx_api_f_4lxml_5etree_utf8, "PyObject *(PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "getNsTag", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTag, "PyObject *(PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "getNsTagWithEmptyNs", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs, "PyObject *(PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "namespacedName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedName, "PyObject *(xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "namespacedNameFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedNameFromNsName, "PyObject *(const xmlChar *, const xmlChar *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "iteratorStoreNext", (void (**)(void))&__pyx_api_f_4lxml_5etree_iteratorStoreNext, "void (struct LxmlElementIterator *, struct LxmlElement *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "initTagMatch", (void (**)(void))&__pyx_api_f_4lxml_5etree_initTagMatch, "void (struct LxmlElementTagMatcher *, PyObject *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "findOrBuildNodeNsPrefix", (void (**)(void))&__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix, "xmlNs *(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
||||
Py_DECREF(module); module = 0;
|
||||
return 0;
|
||||
bad:
|
||||
Py_XDECREF(module);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* !__PYX_HAVE_API__lxml__etree */
|
||||
@@ -0,0 +1,10 @@
|
||||
__doc__ = """Legacy interface to the BeautifulSoup HTML parser.
|
||||
"""
|
||||
|
||||
__all__ = ["parse", "convert_tree"]
|
||||
|
||||
from .soupparser import convert_tree, parse as _parse
|
||||
|
||||
def parse(file, beautifulsoup=None, makeelement=None):
|
||||
root = _parse(file, beautifulsoup=beautifulsoup, makeelement=makeelement)
|
||||
return root.getroot()
|
||||
1946
acer-env/lib/python3.10/site-packages/lxml/html/__init__.py
Normal file
1946
acer-env/lib/python3.10/site-packages/lxml/html/__init__.py
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import optparse
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
from .diff import htmldiff
|
||||
|
||||
description = """\
|
||||
"""
|
||||
|
||||
parser = optparse.OptionParser(
|
||||
usage="%prog [OPTIONS] FILE1 FILE2\n"
|
||||
"%prog --annotate [OPTIONS] INFO1 FILE1 INFO2 FILE2 ...",
|
||||
description=description,
|
||||
)
|
||||
|
||||
parser.add_option(
|
||||
'-o', '--output',
|
||||
metavar="FILE",
|
||||
dest="output",
|
||||
default="-",
|
||||
help="File to write the difference to",
|
||||
)
|
||||
|
||||
parser.add_option(
|
||||
'-a', '--annotation',
|
||||
action="store_true",
|
||||
dest="annotation",
|
||||
help="Do an annotation")
|
||||
|
||||
def main(args=None):
|
||||
if args is None:
|
||||
args = sys.argv[1:]
|
||||
options, args = parser.parse_args(args)
|
||||
if options.annotation:
|
||||
return annotate(options, args)
|
||||
if len(args) != 2:
|
||||
print('Error: you must give two files')
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
file1, file2 = args
|
||||
input1 = read_file(file1)
|
||||
input2 = read_file(file2)
|
||||
body1 = split_body(input1)[1]
|
||||
pre, body2, post = split_body(input2)
|
||||
result = htmldiff(body1, body2)
|
||||
result = pre + result + post
|
||||
if options.output == '-':
|
||||
if not result.endswith('\n'):
|
||||
result += '\n'
|
||||
sys.stdout.write(result)
|
||||
else:
|
||||
with open(options.output, 'wb') as f:
|
||||
f.write(result)
|
||||
|
||||
def read_file(filename):
|
||||
if filename == '-':
|
||||
c = sys.stdin.read()
|
||||
elif not os.path.exists(filename):
|
||||
raise OSError(
|
||||
"Input file %s does not exist" % filename)
|
||||
else:
|
||||
with open(filename, 'rb') as f:
|
||||
c = f.read()
|
||||
return c
|
||||
|
||||
body_start_re = re.compile(
|
||||
r"<body.*?>", re.I|re.S)
|
||||
body_end_re = re.compile(
|
||||
r"</body.*?>", re.I|re.S)
|
||||
|
||||
def split_body(html):
|
||||
pre = post = ''
|
||||
match = body_start_re.search(html)
|
||||
if match:
|
||||
pre = html[:match.end()]
|
||||
html = html[match.end():]
|
||||
match = body_end_re.search(html)
|
||||
if match:
|
||||
post = html[match.start():]
|
||||
html = html[:match.start()]
|
||||
return pre, html, post
|
||||
|
||||
def annotate(options, args):
|
||||
print("Not yet implemented")
|
||||
sys.exit(1)
|
||||
|
||||
100
acer-env/lib/python3.10/site-packages/lxml/html/_html5builder.py
Normal file
100
acer-env/lib/python3.10/site-packages/lxml/html/_html5builder.py
Normal file
@@ -0,0 +1,100 @@
|
||||
"""
|
||||
Legacy module - don't use in new code!
|
||||
|
||||
html5lib now has its own proper implementation.
|
||||
|
||||
This module implements a tree builder for html5lib that generates lxml
|
||||
html element trees. This module uses camelCase as it follows the
|
||||
html5lib style guide.
|
||||
"""
|
||||
|
||||
from html5lib.treebuilders import _base, etree as etree_builders
|
||||
from lxml import html, etree
|
||||
|
||||
|
||||
class DocumentType(object):
|
||||
|
||||
def __init__(self, name, publicId, systemId):
|
||||
self.name = name
|
||||
self.publicId = publicId
|
||||
self.systemId = systemId
|
||||
|
||||
class Document(object):
|
||||
|
||||
def __init__(self):
|
||||
self._elementTree = None
|
||||
self.childNodes = []
|
||||
|
||||
def appendChild(self, element):
|
||||
self._elementTree.getroot().addnext(element._element)
|
||||
|
||||
|
||||
class TreeBuilder(_base.TreeBuilder):
|
||||
documentClass = Document
|
||||
doctypeClass = DocumentType
|
||||
elementClass = None
|
||||
commentClass = None
|
||||
fragmentClass = Document
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
html_builder = etree_builders.getETreeModule(html, fullTree=False)
|
||||
etree_builder = etree_builders.getETreeModule(etree, fullTree=False)
|
||||
self.elementClass = html_builder.Element
|
||||
self.commentClass = etree_builder.Comment
|
||||
_base.TreeBuilder.__init__(self, *args, **kwargs)
|
||||
|
||||
def reset(self):
|
||||
_base.TreeBuilder.reset(self)
|
||||
self.rootInserted = False
|
||||
self.initialComments = []
|
||||
self.doctype = None
|
||||
|
||||
def getDocument(self):
|
||||
return self.document._elementTree
|
||||
|
||||
def getFragment(self):
|
||||
fragment = []
|
||||
element = self.openElements[0]._element
|
||||
if element.text:
|
||||
fragment.append(element.text)
|
||||
fragment.extend(element.getchildren())
|
||||
if element.tail:
|
||||
fragment.append(element.tail)
|
||||
return fragment
|
||||
|
||||
def insertDoctype(self, name, publicId, systemId):
|
||||
doctype = self.doctypeClass(name, publicId, systemId)
|
||||
self.doctype = doctype
|
||||
|
||||
def insertComment(self, data, parent=None):
|
||||
if not self.rootInserted:
|
||||
self.initialComments.append(data)
|
||||
else:
|
||||
_base.TreeBuilder.insertComment(self, data, parent)
|
||||
|
||||
def insertRoot(self, name):
|
||||
buf = []
|
||||
if self.doctype and self.doctype.name:
|
||||
buf.append('<!DOCTYPE %s' % self.doctype.name)
|
||||
if self.doctype.publicId is not None or self.doctype.systemId is not None:
|
||||
buf.append(' PUBLIC "%s" "%s"' % (self.doctype.publicId,
|
||||
self.doctype.systemId))
|
||||
buf.append('>')
|
||||
buf.append('<html></html>')
|
||||
root = html.fromstring(''.join(buf))
|
||||
|
||||
# Append the initial comments:
|
||||
for comment in self.initialComments:
|
||||
root.addprevious(etree.Comment(comment))
|
||||
|
||||
# Create the root document and add the ElementTree to it
|
||||
self.document = self.documentClass()
|
||||
self.document._elementTree = root.getroottree()
|
||||
|
||||
# Add the root element to the internal child/open data structures
|
||||
root_element = self.elementClass(name)
|
||||
root_element._element = root
|
||||
self.document.childNodes.append(root_element)
|
||||
self.openElements.append(root_element)
|
||||
|
||||
self.rootInserted = True
|
||||
56
acer-env/lib/python3.10/site-packages/lxml/html/_setmixin.py
Normal file
56
acer-env/lib/python3.10/site-packages/lxml/html/_setmixin.py
Normal file
@@ -0,0 +1,56 @@
|
||||
try:
|
||||
from collections.abc import MutableSet
|
||||
except ImportError:
|
||||
from collections import MutableSet
|
||||
|
||||
|
||||
class SetMixin(MutableSet):
|
||||
|
||||
"""
|
||||
Mix-in for sets. You must define __iter__, add, remove
|
||||
"""
|
||||
|
||||
def __len__(self):
|
||||
length = 0
|
||||
for item in self:
|
||||
length += 1
|
||||
return length
|
||||
|
||||
def __contains__(self, item):
|
||||
for has_item in self:
|
||||
if item == has_item:
|
||||
return True
|
||||
return False
|
||||
|
||||
issubset = MutableSet.__le__
|
||||
issuperset = MutableSet.__ge__
|
||||
|
||||
union = MutableSet.__or__
|
||||
intersection = MutableSet.__and__
|
||||
difference = MutableSet.__sub__
|
||||
symmetric_difference = MutableSet.__xor__
|
||||
|
||||
def copy(self):
|
||||
return set(self)
|
||||
|
||||
def update(self, other):
|
||||
self |= other
|
||||
|
||||
def intersection_update(self, other):
|
||||
self &= other
|
||||
|
||||
def difference_update(self, other):
|
||||
self -= other
|
||||
|
||||
def symmetric_difference_update(self, other):
|
||||
self ^= other
|
||||
|
||||
def discard(self, item):
|
||||
try:
|
||||
self.remove(item)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def _from_iterable(cls, it):
|
||||
return set(it)
|
||||
133
acer-env/lib/python3.10/site-packages/lxml/html/builder.py
Normal file
133
acer-env/lib/python3.10/site-packages/lxml/html/builder.py
Normal file
@@ -0,0 +1,133 @@
|
||||
# --------------------------------------------------------------------
|
||||
# The ElementTree toolkit is
|
||||
# Copyright (c) 1999-2004 by Fredrik Lundh
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
"""
|
||||
A set of HTML generator tags for building HTML documents.
|
||||
|
||||
Usage::
|
||||
|
||||
>>> from lxml.html.builder import *
|
||||
>>> html = HTML(
|
||||
... HEAD( TITLE("Hello World") ),
|
||||
... BODY( CLASS("main"),
|
||||
... H1("Hello World !")
|
||||
... )
|
||||
... )
|
||||
|
||||
>>> import lxml.etree
|
||||
>>> print lxml.etree.tostring(html, pretty_print=True)
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello World</title>
|
||||
</head>
|
||||
<body class="main">
|
||||
<h1>Hello World !</h1>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
"""
|
||||
|
||||
from lxml.builder import ElementMaker
|
||||
from lxml.html import html_parser
|
||||
|
||||
E = ElementMaker(makeelement=html_parser.makeelement)
|
||||
|
||||
# elements
|
||||
A = E.a #: anchor
|
||||
ABBR = E.abbr #: abbreviated form (e.g., WWW, HTTP, etc.)
|
||||
ACRONYM = E.acronym #:
|
||||
ADDRESS = E.address #: information on author
|
||||
APPLET = E.applet #: Java applet (DEPRECATED)
|
||||
AREA = E.area #: client-side image map area
|
||||
B = E.b #: bold text style
|
||||
BASE = E.base #: document base URI
|
||||
BASEFONT = E.basefont #: base font size (DEPRECATED)
|
||||
BDO = E.bdo #: I18N BiDi over-ride
|
||||
BIG = E.big #: large text style
|
||||
BLOCKQUOTE = E.blockquote #: long quotation
|
||||
BODY = E.body #: document body
|
||||
BR = E.br #: forced line break
|
||||
BUTTON = E.button #: push button
|
||||
CAPTION = E.caption #: table caption
|
||||
CENTER = E.center #: shorthand for DIV align=center (DEPRECATED)
|
||||
CITE = E.cite #: citation
|
||||
CODE = E.code #: computer code fragment
|
||||
COL = E.col #: table column
|
||||
COLGROUP = E.colgroup #: table column group
|
||||
DD = E.dd #: definition description
|
||||
DEL = getattr(E, 'del') #: deleted text
|
||||
DFN = E.dfn #: instance definition
|
||||
DIR = E.dir #: directory list (DEPRECATED)
|
||||
DIV = E.div #: generic language/style container
|
||||
DL = E.dl #: definition list
|
||||
DT = E.dt #: definition term
|
||||
EM = E.em #: emphasis
|
||||
FIELDSET = E.fieldset #: form control group
|
||||
FONT = E.font #: local change to font (DEPRECATED)
|
||||
FORM = E.form #: interactive form
|
||||
FRAME = E.frame #: subwindow
|
||||
FRAMESET = E.frameset #: window subdivision
|
||||
H1 = E.h1 #: heading
|
||||
H2 = E.h2 #: heading
|
||||
H3 = E.h3 #: heading
|
||||
H4 = E.h4 #: heading
|
||||
H5 = E.h5 #: heading
|
||||
H6 = E.h6 #: heading
|
||||
HEAD = E.head #: document head
|
||||
HR = E.hr #: horizontal rule
|
||||
HTML = E.html #: document root element
|
||||
I = E.i #: italic text style
|
||||
IFRAME = E.iframe #: inline subwindow
|
||||
IMG = E.img #: Embedded image
|
||||
INPUT = E.input #: form control
|
||||
INS = E.ins #: inserted text
|
||||
ISINDEX = E.isindex #: single line prompt (DEPRECATED)
|
||||
KBD = E.kbd #: text to be entered by the user
|
||||
LABEL = E.label #: form field label text
|
||||
LEGEND = E.legend #: fieldset legend
|
||||
LI = E.li #: list item
|
||||
LINK = E.link #: a media-independent link
|
||||
MAP = E.map #: client-side image map
|
||||
MENU = E.menu #: menu list (DEPRECATED)
|
||||
META = E.meta #: generic metainformation
|
||||
NOFRAMES = E.noframes #: alternate content container for non frame-based rendering
|
||||
NOSCRIPT = E.noscript #: alternate content container for non script-based rendering
|
||||
OBJECT = E.object #: generic embedded object
|
||||
OL = E.ol #: ordered list
|
||||
OPTGROUP = E.optgroup #: option group
|
||||
OPTION = E.option #: selectable choice
|
||||
P = E.p #: paragraph
|
||||
PARAM = E.param #: named property value
|
||||
PRE = E.pre #: preformatted text
|
||||
Q = E.q #: short inline quotation
|
||||
S = E.s #: strike-through text style (DEPRECATED)
|
||||
SAMP = E.samp #: sample program output, scripts, etc.
|
||||
SCRIPT = E.script #: script statements
|
||||
SELECT = E.select #: option selector
|
||||
SMALL = E.small #: small text style
|
||||
SPAN = E.span #: generic language/style container
|
||||
STRIKE = E.strike #: strike-through text (DEPRECATED)
|
||||
STRONG = E.strong #: strong emphasis
|
||||
STYLE = E.style #: style info
|
||||
SUB = E.sub #: subscript
|
||||
SUP = E.sup #: superscript
|
||||
TABLE = E.table #:
|
||||
TBODY = E.tbody #: table body
|
||||
TD = E.td #: table data cell
|
||||
TEXTAREA = E.textarea #: multi-line text field
|
||||
TFOOT = E.tfoot #: table footer
|
||||
TH = E.th #: table header cell
|
||||
THEAD = E.thead #: table header
|
||||
TITLE = E.title #: document title
|
||||
TR = E.tr #: table row
|
||||
TT = E.tt #: teletype or monospaced text style
|
||||
U = E.u #: underlined text style (DEPRECATED)
|
||||
UL = E.ul #: unordered list
|
||||
VAR = E.var #: instance of a variable or program argument
|
||||
|
||||
# attributes (only reserved words are included here)
|
||||
ATTR = dict
|
||||
def CLASS(v): return {'class': v}
|
||||
def FOR(v): return {'for': v}
|
||||
Binary file not shown.
786
acer-env/lib/python3.10/site-packages/lxml/html/clean.py
Normal file
786
acer-env/lib/python3.10/site-packages/lxml/html/clean.py
Normal file
@@ -0,0 +1,786 @@
|
||||
# cython: language_level=3str
|
||||
|
||||
"""A cleanup tool for HTML.
|
||||
|
||||
Removes unwanted tags and content. See the `Cleaner` class for
|
||||
details.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import copy
|
||||
import re
|
||||
import sys
|
||||
try:
|
||||
from urlparse import urlsplit
|
||||
from urllib import unquote_plus
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from urllib.parse import urlsplit, unquote_plus
|
||||
from lxml import etree
|
||||
from lxml.html import defs
|
||||
from lxml.html import fromstring, XHTML_NAMESPACE
|
||||
from lxml.html import xhtml_to_html, _transform_result
|
||||
|
||||
try:
|
||||
unichr
|
||||
except NameError:
|
||||
# Python 3
|
||||
unichr = chr
|
||||
try:
|
||||
unicode
|
||||
except NameError:
|
||||
# Python 3
|
||||
unicode = str
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = (str, bytes)
|
||||
|
||||
|
||||
__all__ = ['clean_html', 'clean', 'Cleaner', 'autolink', 'autolink_html',
|
||||
'word_break', 'word_break_html']
|
||||
|
||||
# Look at http://code.sixapart.com/trac/livejournal/browser/trunk/cgi-bin/cleanhtml.pl
|
||||
# Particularly the CSS cleaning; most of the tag cleaning is integrated now
|
||||
# I have multiple kinds of schemes searched; but should schemes be
|
||||
# whitelisted instead?
|
||||
# max height?
|
||||
# remove images? Also in CSS? background attribute?
|
||||
# Some way to whitelist object, iframe, etc (e.g., if you want to
|
||||
# allow *just* embedded YouTube movies)
|
||||
# Log what was deleted and why?
|
||||
# style="behavior: ..." might be bad in IE?
|
||||
# Should we have something for just <meta http-equiv>? That's the worst of the
|
||||
# metas.
|
||||
# UTF-7 detections? Example:
|
||||
# <HEAD><META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-7"> </HEAD>+ADw-SCRIPT+AD4-alert('XSS');+ADw-/SCRIPT+AD4-
|
||||
# you don't always have to have the charset set, if the page has no charset
|
||||
# and there's UTF7-like code in it.
|
||||
# Look at these tests: http://htmlpurifier.org/live/smoketests/xssAttacks.php
|
||||
|
||||
|
||||
# This is an IE-specific construct you can have in a stylesheet to
|
||||
# run some Javascript:
|
||||
_replace_css_javascript = re.compile(
|
||||
r'expression\s*\(.*?\)', re.S|re.I).sub
|
||||
|
||||
# Do I have to worry about @\nimport?
|
||||
_replace_css_import = re.compile(
|
||||
r'@\s*import', re.I).sub
|
||||
|
||||
_looks_like_tag_content = re.compile(
|
||||
r'</?[a-zA-Z]+|\son[a-zA-Z]+\s*=',
|
||||
*((re.ASCII,) if sys.version_info[0] >= 3 else ())).search
|
||||
|
||||
# All kinds of schemes besides just javascript: that can cause
|
||||
# execution:
|
||||
_find_image_dataurls = re.compile(
|
||||
r'data:image/(.+);base64,', re.I).findall
|
||||
_possibly_malicious_schemes = re.compile(
|
||||
r'(javascript|jscript|livescript|vbscript|data|about|mocha):',
|
||||
re.I).findall
|
||||
# SVG images can contain script content
|
||||
_is_unsafe_image_type = re.compile(r"(xml|svg)", re.I).search
|
||||
|
||||
def _has_javascript_scheme(s):
|
||||
safe_image_urls = 0
|
||||
for image_type in _find_image_dataurls(s):
|
||||
if _is_unsafe_image_type(image_type):
|
||||
return True
|
||||
safe_image_urls += 1
|
||||
return len(_possibly_malicious_schemes(s)) > safe_image_urls
|
||||
|
||||
_substitute_whitespace = re.compile(r'[\s\x00-\x08\x0B\x0C\x0E-\x19]+').sub
|
||||
|
||||
# FIXME: check against: http://msdn2.microsoft.com/en-us/library/ms537512.aspx
|
||||
_conditional_comment_re = re.compile(
|
||||
r'\[if[\s\n\r]+.*?][\s\n\r]*>', re.I|re.S)
|
||||
|
||||
_find_styled_elements = etree.XPath(
|
||||
"descendant-or-self::*[@style]")
|
||||
|
||||
_find_external_links = etree.XPath(
|
||||
("descendant-or-self::a [normalize-space(@href) and substring(normalize-space(@href),1,1) != '#'] |"
|
||||
"descendant-or-self::x:a[normalize-space(@href) and substring(normalize-space(@href),1,1) != '#']"),
|
||||
namespaces={'x':XHTML_NAMESPACE})
|
||||
|
||||
|
||||
class Cleaner(object):
|
||||
"""
|
||||
Instances cleans the document of each of the possible offending
|
||||
elements. The cleaning is controlled by attributes; you can
|
||||
override attributes in a subclass, or set them in the constructor.
|
||||
|
||||
``scripts``:
|
||||
Removes any ``<script>`` tags.
|
||||
|
||||
``javascript``:
|
||||
Removes any Javascript, like an ``onclick`` attribute. Also removes stylesheets
|
||||
as they could contain Javascript.
|
||||
|
||||
``comments``:
|
||||
Removes any comments.
|
||||
|
||||
``style``:
|
||||
Removes any style tags.
|
||||
|
||||
``inline_style``
|
||||
Removes any style attributes. Defaults to the value of the ``style`` option.
|
||||
|
||||
``links``:
|
||||
Removes any ``<link>`` tags
|
||||
|
||||
``meta``:
|
||||
Removes any ``<meta>`` tags
|
||||
|
||||
``page_structure``:
|
||||
Structural parts of a page: ``<head>``, ``<html>``, ``<title>``.
|
||||
|
||||
``processing_instructions``:
|
||||
Removes any processing instructions.
|
||||
|
||||
``embedded``:
|
||||
Removes any embedded objects (flash, iframes)
|
||||
|
||||
``frames``:
|
||||
Removes any frame-related tags
|
||||
|
||||
``forms``:
|
||||
Removes any form tags
|
||||
|
||||
``annoying_tags``:
|
||||
Tags that aren't *wrong*, but are annoying. ``<blink>`` and ``<marquee>``
|
||||
|
||||
``remove_tags``:
|
||||
A list of tags to remove. Only the tags will be removed,
|
||||
their content will get pulled up into the parent tag.
|
||||
|
||||
``kill_tags``:
|
||||
A list of tags to kill. Killing also removes the tag's content,
|
||||
i.e. the whole subtree, not just the tag itself.
|
||||
|
||||
``allow_tags``:
|
||||
A list of tags to include (default include all).
|
||||
|
||||
``remove_unknown_tags``:
|
||||
Remove any tags that aren't standard parts of HTML.
|
||||
|
||||
``safe_attrs_only``:
|
||||
If true, only include 'safe' attributes (specifically the list
|
||||
from the feedparser HTML sanitisation web site).
|
||||
|
||||
``safe_attrs``:
|
||||
A set of attribute names to override the default list of attributes
|
||||
considered 'safe' (when safe_attrs_only=True).
|
||||
|
||||
``add_nofollow``:
|
||||
If true, then any <a> tags will have ``rel="nofollow"`` added to them.
|
||||
|
||||
``host_whitelist``:
|
||||
A list or set of hosts that you can use for embedded content
|
||||
(for content like ``<object>``, ``<link rel="stylesheet">``, etc).
|
||||
You can also implement/override the method
|
||||
``allow_embedded_url(el, url)`` or ``allow_element(el)`` to
|
||||
implement more complex rules for what can be embedded.
|
||||
Anything that passes this test will be shown, regardless of
|
||||
the value of (for instance) ``embedded``.
|
||||
|
||||
Note that this parameter might not work as intended if you do not
|
||||
make the links absolute before doing the cleaning.
|
||||
|
||||
Note that you may also need to set ``whitelist_tags``.
|
||||
|
||||
``whitelist_tags``:
|
||||
A set of tags that can be included with ``host_whitelist``.
|
||||
The default is ``iframe`` and ``embed``; you may wish to
|
||||
include other tags like ``script``, or you may want to
|
||||
implement ``allow_embedded_url`` for more control. Set to None to
|
||||
include all tags.
|
||||
|
||||
This modifies the document *in place*.
|
||||
"""
|
||||
|
||||
scripts = True
|
||||
javascript = True
|
||||
comments = True
|
||||
style = False
|
||||
inline_style = None
|
||||
links = True
|
||||
meta = True
|
||||
page_structure = True
|
||||
processing_instructions = True
|
||||
embedded = True
|
||||
frames = True
|
||||
forms = True
|
||||
annoying_tags = True
|
||||
remove_tags = None
|
||||
allow_tags = None
|
||||
kill_tags = None
|
||||
remove_unknown_tags = True
|
||||
safe_attrs_only = True
|
||||
safe_attrs = defs.safe_attrs
|
||||
add_nofollow = False
|
||||
host_whitelist = ()
|
||||
whitelist_tags = {'iframe', 'embed'}
|
||||
|
||||
def __init__(self, **kw):
|
||||
not_an_attribute = object()
|
||||
for name, value in kw.items():
|
||||
default = getattr(self, name, not_an_attribute)
|
||||
if (default is not None and default is not True and default is not False
|
||||
and not isinstance(default, (frozenset, set, tuple, list))):
|
||||
raise TypeError(
|
||||
"Unknown parameter: %s=%r" % (name, value))
|
||||
setattr(self, name, value)
|
||||
if self.inline_style is None and 'inline_style' not in kw:
|
||||
self.inline_style = self.style
|
||||
|
||||
if kw.get("allow_tags"):
|
||||
if kw.get("remove_unknown_tags"):
|
||||
raise ValueError("It does not make sense to pass in both "
|
||||
"allow_tags and remove_unknown_tags")
|
||||
self.remove_unknown_tags = False
|
||||
|
||||
# Used to lookup the primary URL for a given tag that is up for
|
||||
# removal:
|
||||
_tag_link_attrs = dict(
|
||||
script='src',
|
||||
link='href',
|
||||
# From: http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html
|
||||
# From what I can tell, both attributes can contain a link:
|
||||
applet=['code', 'object'],
|
||||
iframe='src',
|
||||
embed='src',
|
||||
layer='src',
|
||||
# FIXME: there doesn't really seem like a general way to figure out what
|
||||
# links an <object> tag uses; links often go in <param> tags with values
|
||||
# that we don't really know. You'd have to have knowledge about specific
|
||||
# kinds of plugins (probably keyed off classid), and match against those.
|
||||
##object=?,
|
||||
# FIXME: not looking at the action currently, because it is more complex
|
||||
# than than -- if you keep the form, you should keep the form controls.
|
||||
##form='action',
|
||||
a='href',
|
||||
)
|
||||
|
||||
def __call__(self, doc):
|
||||
"""
|
||||
Cleans the document.
|
||||
"""
|
||||
try:
|
||||
getroot = doc.getroot
|
||||
except AttributeError:
|
||||
pass # Element instance
|
||||
else:
|
||||
doc = getroot() # ElementTree instance, instead of an element
|
||||
# convert XHTML to HTML
|
||||
xhtml_to_html(doc)
|
||||
# Normalize a case that IE treats <image> like <img>, and that
|
||||
# can confuse either this step or later steps.
|
||||
for el in doc.iter('image'):
|
||||
el.tag = 'img'
|
||||
if not self.comments:
|
||||
# Of course, if we were going to kill comments anyway, we don't
|
||||
# need to worry about this
|
||||
self.kill_conditional_comments(doc)
|
||||
|
||||
kill_tags = set(self.kill_tags or ())
|
||||
remove_tags = set(self.remove_tags or ())
|
||||
allow_tags = set(self.allow_tags or ())
|
||||
|
||||
if self.scripts:
|
||||
kill_tags.add('script')
|
||||
if self.safe_attrs_only:
|
||||
safe_attrs = set(self.safe_attrs)
|
||||
for el in doc.iter(etree.Element):
|
||||
attrib = el.attrib
|
||||
for aname in attrib.keys():
|
||||
if aname not in safe_attrs:
|
||||
del attrib[aname]
|
||||
if self.javascript:
|
||||
if not (self.safe_attrs_only and
|
||||
self.safe_attrs == defs.safe_attrs):
|
||||
# safe_attrs handles events attributes itself
|
||||
for el in doc.iter(etree.Element):
|
||||
attrib = el.attrib
|
||||
for aname in attrib.keys():
|
||||
if aname.startswith('on'):
|
||||
del attrib[aname]
|
||||
doc.rewrite_links(self._remove_javascript_link,
|
||||
resolve_base_href=False)
|
||||
# If we're deleting style then we don't have to remove JS links
|
||||
# from styles, otherwise...
|
||||
if not self.inline_style:
|
||||
for el in _find_styled_elements(doc):
|
||||
old = el.get('style')
|
||||
new = _replace_css_javascript('', old)
|
||||
new = _replace_css_import('', new)
|
||||
if self._has_sneaky_javascript(new):
|
||||
# Something tricky is going on...
|
||||
del el.attrib['style']
|
||||
elif new != old:
|
||||
el.set('style', new)
|
||||
if not self.style:
|
||||
for el in list(doc.iter('style')):
|
||||
if el.get('type', '').lower().strip() == 'text/javascript':
|
||||
el.drop_tree()
|
||||
continue
|
||||
old = el.text or ''
|
||||
new = _replace_css_javascript('', old)
|
||||
# The imported CSS can do anything; we just can't allow:
|
||||
new = _replace_css_import('', new)
|
||||
if self._has_sneaky_javascript(new):
|
||||
# Something tricky is going on...
|
||||
el.text = '/* deleted */'
|
||||
elif new != old:
|
||||
el.text = new
|
||||
if self.comments:
|
||||
kill_tags.add(etree.Comment)
|
||||
if self.processing_instructions:
|
||||
kill_tags.add(etree.ProcessingInstruction)
|
||||
if self.style:
|
||||
kill_tags.add('style')
|
||||
if self.inline_style:
|
||||
etree.strip_attributes(doc, 'style')
|
||||
if self.links:
|
||||
kill_tags.add('link')
|
||||
elif self.style or self.javascript:
|
||||
# We must get rid of included stylesheets if Javascript is not
|
||||
# allowed, as you can put Javascript in them
|
||||
for el in list(doc.iter('link')):
|
||||
if 'stylesheet' in el.get('rel', '').lower():
|
||||
# Note this kills alternate stylesheets as well
|
||||
if not self.allow_element(el):
|
||||
el.drop_tree()
|
||||
if self.meta:
|
||||
kill_tags.add('meta')
|
||||
if self.page_structure:
|
||||
remove_tags.update(('head', 'html', 'title'))
|
||||
if self.embedded:
|
||||
# FIXME: is <layer> really embedded?
|
||||
# We should get rid of any <param> tags not inside <applet>;
|
||||
# These are not really valid anyway.
|
||||
for el in list(doc.iter('param')):
|
||||
parent = el.getparent()
|
||||
while parent is not None and parent.tag not in ('applet', 'object'):
|
||||
parent = parent.getparent()
|
||||
if parent is None:
|
||||
el.drop_tree()
|
||||
kill_tags.update(('applet',))
|
||||
# The alternate contents that are in an iframe are a good fallback:
|
||||
remove_tags.update(('iframe', 'embed', 'layer', 'object', 'param'))
|
||||
if self.frames:
|
||||
# FIXME: ideally we should look at the frame links, but
|
||||
# generally frames don't mix properly with an HTML
|
||||
# fragment anyway.
|
||||
kill_tags.update(defs.frame_tags)
|
||||
if self.forms:
|
||||
remove_tags.add('form')
|
||||
kill_tags.update(('button', 'input', 'select', 'textarea'))
|
||||
if self.annoying_tags:
|
||||
remove_tags.update(('blink', 'marquee'))
|
||||
|
||||
_remove = []
|
||||
_kill = []
|
||||
for el in doc.iter():
|
||||
if el.tag in kill_tags:
|
||||
if self.allow_element(el):
|
||||
continue
|
||||
_kill.append(el)
|
||||
elif el.tag in remove_tags:
|
||||
if self.allow_element(el):
|
||||
continue
|
||||
_remove.append(el)
|
||||
|
||||
if _remove and _remove[0] == doc:
|
||||
# We have to drop the parent-most tag, which we can't
|
||||
# do. Instead we'll rewrite it:
|
||||
el = _remove.pop(0)
|
||||
el.tag = 'div'
|
||||
el.attrib.clear()
|
||||
elif _kill and _kill[0] == doc:
|
||||
# We have to drop the parent-most element, which we can't
|
||||
# do. Instead we'll clear it:
|
||||
el = _kill.pop(0)
|
||||
if el.tag != 'html':
|
||||
el.tag = 'div'
|
||||
el.clear()
|
||||
|
||||
_kill.reverse() # start with innermost tags
|
||||
for el in _kill:
|
||||
el.drop_tree()
|
||||
for el in _remove:
|
||||
el.drop_tag()
|
||||
|
||||
if self.remove_unknown_tags:
|
||||
if allow_tags:
|
||||
raise ValueError(
|
||||
"It does not make sense to pass in both allow_tags and remove_unknown_tags")
|
||||
allow_tags = set(defs.tags)
|
||||
if allow_tags:
|
||||
# make sure we do not remove comments/PIs if users want them (which is rare enough)
|
||||
if not self.comments:
|
||||
allow_tags.add(etree.Comment)
|
||||
if not self.processing_instructions:
|
||||
allow_tags.add(etree.ProcessingInstruction)
|
||||
|
||||
bad = []
|
||||
for el in doc.iter():
|
||||
if el.tag not in allow_tags:
|
||||
bad.append(el)
|
||||
if bad:
|
||||
if bad[0] is doc:
|
||||
el = bad.pop(0)
|
||||
el.tag = 'div'
|
||||
el.attrib.clear()
|
||||
for el in bad:
|
||||
el.drop_tag()
|
||||
if self.add_nofollow:
|
||||
for el in _find_external_links(doc):
|
||||
if not self.allow_follow(el):
|
||||
rel = el.get('rel')
|
||||
if rel:
|
||||
if ('nofollow' in rel
|
||||
and ' nofollow ' in (' %s ' % rel)):
|
||||
continue
|
||||
rel = '%s nofollow' % rel
|
||||
else:
|
||||
rel = 'nofollow'
|
||||
el.set('rel', rel)
|
||||
|
||||
def allow_follow(self, anchor):
|
||||
"""
|
||||
Override to suppress rel="nofollow" on some anchors.
|
||||
"""
|
||||
return False
|
||||
|
||||
def allow_element(self, el):
|
||||
"""
|
||||
Decide whether an element is configured to be accepted or rejected.
|
||||
|
||||
:param el: an element.
|
||||
:return: true to accept the element or false to reject/discard it.
|
||||
"""
|
||||
if el.tag not in self._tag_link_attrs:
|
||||
return False
|
||||
attr = self._tag_link_attrs[el.tag]
|
||||
if isinstance(attr, (list, tuple)):
|
||||
for one_attr in attr:
|
||||
url = el.get(one_attr)
|
||||
if not url:
|
||||
return False
|
||||
if not self.allow_embedded_url(el, url):
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
url = el.get(attr)
|
||||
if not url:
|
||||
return False
|
||||
return self.allow_embedded_url(el, url)
|
||||
|
||||
def allow_embedded_url(self, el, url):
|
||||
"""
|
||||
Decide whether a URL that was found in an element's attributes or text
|
||||
if configured to be accepted or rejected.
|
||||
|
||||
:param el: an element.
|
||||
:param url: a URL found on the element.
|
||||
:return: true to accept the URL and false to reject it.
|
||||
"""
|
||||
if self.whitelist_tags is not None and el.tag not in self.whitelist_tags:
|
||||
return False
|
||||
scheme, netloc, path, query, fragment = urlsplit(url)
|
||||
netloc = netloc.lower().split(':', 1)[0]
|
||||
if scheme not in ('http', 'https'):
|
||||
return False
|
||||
if netloc in self.host_whitelist:
|
||||
return True
|
||||
return False
|
||||
|
||||
def kill_conditional_comments(self, doc):
|
||||
"""
|
||||
IE conditional comments basically embed HTML that the parser
|
||||
doesn't normally see. We can't allow anything like that, so
|
||||
we'll kill any comments that could be conditional.
|
||||
"""
|
||||
has_conditional_comment = _conditional_comment_re.search
|
||||
self._kill_elements(
|
||||
doc, lambda el: has_conditional_comment(el.text),
|
||||
etree.Comment)
|
||||
|
||||
def _kill_elements(self, doc, condition, iterate=None):
|
||||
bad = []
|
||||
for el in doc.iter(iterate):
|
||||
if condition(el):
|
||||
bad.append(el)
|
||||
for el in bad:
|
||||
el.drop_tree()
|
||||
|
||||
def _remove_javascript_link(self, link):
|
||||
# links like "j a v a s c r i p t:" might be interpreted in IE
|
||||
new = _substitute_whitespace('', unquote_plus(link))
|
||||
if _has_javascript_scheme(new):
|
||||
# FIXME: should this be None to delete?
|
||||
return ''
|
||||
return link
|
||||
|
||||
_substitute_comments = re.compile(r'/\*.*?\*/', re.S).sub
|
||||
|
||||
def _has_sneaky_javascript(self, style):
|
||||
"""
|
||||
Depending on the browser, stuff like ``e x p r e s s i o n(...)``
|
||||
can get interpreted, or ``expre/* stuff */ssion(...)``. This
|
||||
checks for attempt to do stuff like this.
|
||||
|
||||
Typically the response will be to kill the entire style; if you
|
||||
have just a bit of Javascript in the style another rule will catch
|
||||
that and remove only the Javascript from the style; this catches
|
||||
more sneaky attempts.
|
||||
"""
|
||||
style = self._substitute_comments('', style)
|
||||
style = style.replace('\\', '')
|
||||
style = _substitute_whitespace('', style)
|
||||
style = style.lower()
|
||||
if _has_javascript_scheme(style):
|
||||
return True
|
||||
if 'expression(' in style:
|
||||
return True
|
||||
if '@import' in style:
|
||||
return True
|
||||
if '</noscript' in style:
|
||||
# e.g. '<noscript><style><a title="</noscript><img src=x onerror=alert(1)>">'
|
||||
return True
|
||||
if _looks_like_tag_content(style):
|
||||
# e.g. '<math><style><img src=x onerror=alert(1)></style></math>'
|
||||
return True
|
||||
return False
|
||||
|
||||
def clean_html(self, html):
|
||||
result_type = type(html)
|
||||
if isinstance(html, basestring):
|
||||
doc = fromstring(html)
|
||||
else:
|
||||
doc = copy.deepcopy(html)
|
||||
self(doc)
|
||||
return _transform_result(result_type, doc)
|
||||
|
||||
clean = Cleaner()
|
||||
clean_html = clean.clean_html
|
||||
|
||||
############################################################
|
||||
## Autolinking
|
||||
############################################################
|
||||
|
||||
_link_regexes = [
|
||||
re.compile(r'(?P<body>https?://(?P<host>[a-z0-9._-]+)(?:/[/\-_.,a-z0-9%&?;=~]*)?(?:\([/\-_.,a-z0-9%&?;=~]*\))?)', re.I),
|
||||
# This is conservative, but autolinking can be a bit conservative:
|
||||
re.compile(r'mailto:(?P<body>[a-z0-9._-]+@(?P<host>[a-z0-9_.-]+[a-z]))', re.I),
|
||||
]
|
||||
|
||||
_avoid_elements = ['textarea', 'pre', 'code', 'head', 'select', 'a']
|
||||
|
||||
_avoid_hosts = [
|
||||
re.compile(r'^localhost', re.I),
|
||||
re.compile(r'\bexample\.(?:com|org|net)$', re.I),
|
||||
re.compile(r'^127\.0\.0\.1$'),
|
||||
]
|
||||
|
||||
_avoid_classes = ['nolink']
|
||||
|
||||
def autolink(el, link_regexes=_link_regexes,
|
||||
avoid_elements=_avoid_elements,
|
||||
avoid_hosts=_avoid_hosts,
|
||||
avoid_classes=_avoid_classes):
|
||||
"""
|
||||
Turn any URLs into links.
|
||||
|
||||
It will search for links identified by the given regular
|
||||
expressions (by default mailto and http(s) links).
|
||||
|
||||
It won't link text in an element in avoid_elements, or an element
|
||||
with a class in avoid_classes. It won't link to anything with a
|
||||
host that matches one of the regular expressions in avoid_hosts
|
||||
(default localhost and 127.0.0.1).
|
||||
|
||||
If you pass in an element, the element's tail will not be
|
||||
substituted, only the contents of the element.
|
||||
"""
|
||||
if el.tag in avoid_elements:
|
||||
return
|
||||
class_name = el.get('class')
|
||||
if class_name:
|
||||
class_name = class_name.split()
|
||||
for match_class in avoid_classes:
|
||||
if match_class in class_name:
|
||||
return
|
||||
for child in list(el):
|
||||
autolink(child, link_regexes=link_regexes,
|
||||
avoid_elements=avoid_elements,
|
||||
avoid_hosts=avoid_hosts,
|
||||
avoid_classes=avoid_classes)
|
||||
if child.tail:
|
||||
text, tail_children = _link_text(
|
||||
child.tail, link_regexes, avoid_hosts, factory=el.makeelement)
|
||||
if tail_children:
|
||||
child.tail = text
|
||||
index = el.index(child)
|
||||
el[index+1:index+1] = tail_children
|
||||
if el.text:
|
||||
text, pre_children = _link_text(
|
||||
el.text, link_regexes, avoid_hosts, factory=el.makeelement)
|
||||
if pre_children:
|
||||
el.text = text
|
||||
el[:0] = pre_children
|
||||
|
||||
def _link_text(text, link_regexes, avoid_hosts, factory):
|
||||
leading_text = ''
|
||||
links = []
|
||||
last_pos = 0
|
||||
while 1:
|
||||
best_match, best_pos = None, None
|
||||
for regex in link_regexes:
|
||||
regex_pos = last_pos
|
||||
while 1:
|
||||
match = regex.search(text, pos=regex_pos)
|
||||
if match is None:
|
||||
break
|
||||
host = match.group('host')
|
||||
for host_regex in avoid_hosts:
|
||||
if host_regex.search(host):
|
||||
regex_pos = match.end()
|
||||
break
|
||||
else:
|
||||
break
|
||||
if match is None:
|
||||
continue
|
||||
if best_pos is None or match.start() < best_pos:
|
||||
best_match = match
|
||||
best_pos = match.start()
|
||||
if best_match is None:
|
||||
# No more matches
|
||||
if links:
|
||||
assert not links[-1].tail
|
||||
links[-1].tail = text
|
||||
else:
|
||||
assert not leading_text
|
||||
leading_text = text
|
||||
break
|
||||
link = best_match.group(0)
|
||||
end = best_match.end()
|
||||
if link.endswith('.') or link.endswith(','):
|
||||
# These punctuation marks shouldn't end a link
|
||||
end -= 1
|
||||
link = link[:-1]
|
||||
prev_text = text[:best_match.start()]
|
||||
if links:
|
||||
assert not links[-1].tail
|
||||
links[-1].tail = prev_text
|
||||
else:
|
||||
assert not leading_text
|
||||
leading_text = prev_text
|
||||
anchor = factory('a')
|
||||
anchor.set('href', link)
|
||||
body = best_match.group('body')
|
||||
if not body:
|
||||
body = link
|
||||
if body.endswith('.') or body.endswith(','):
|
||||
body = body[:-1]
|
||||
anchor.text = body
|
||||
links.append(anchor)
|
||||
text = text[end:]
|
||||
return leading_text, links
|
||||
|
||||
def autolink_html(html, *args, **kw):
|
||||
result_type = type(html)
|
||||
if isinstance(html, basestring):
|
||||
doc = fromstring(html)
|
||||
else:
|
||||
doc = copy.deepcopy(html)
|
||||
autolink(doc, *args, **kw)
|
||||
return _transform_result(result_type, doc)
|
||||
|
||||
autolink_html.__doc__ = autolink.__doc__
|
||||
|
||||
############################################################
|
||||
## Word wrapping
|
||||
############################################################
|
||||
|
||||
_avoid_word_break_elements = ['pre', 'textarea', 'code']
|
||||
_avoid_word_break_classes = ['nobreak']
|
||||
|
||||
def word_break(el, max_width=40,
|
||||
avoid_elements=_avoid_word_break_elements,
|
||||
avoid_classes=_avoid_word_break_classes,
|
||||
break_character=unichr(0x200b)):
|
||||
"""
|
||||
Breaks any long words found in the body of the text (not attributes).
|
||||
|
||||
Doesn't effect any of the tags in avoid_elements, by default
|
||||
``<textarea>`` and ``<pre>``
|
||||
|
||||
Breaks words by inserting ​, which is a unicode character
|
||||
for Zero Width Space character. This generally takes up no space
|
||||
in rendering, but does copy as a space, and in monospace contexts
|
||||
usually takes up space.
|
||||
|
||||
See http://www.cs.tut.fi/~jkorpela/html/nobr.html for a discussion
|
||||
"""
|
||||
# Character suggestion of ​ comes from:
|
||||
# http://www.cs.tut.fi/~jkorpela/html/nobr.html
|
||||
if el.tag in _avoid_word_break_elements:
|
||||
return
|
||||
class_name = el.get('class')
|
||||
if class_name:
|
||||
dont_break = False
|
||||
class_name = class_name.split()
|
||||
for avoid in avoid_classes:
|
||||
if avoid in class_name:
|
||||
dont_break = True
|
||||
break
|
||||
if dont_break:
|
||||
return
|
||||
if el.text:
|
||||
el.text = _break_text(el.text, max_width, break_character)
|
||||
for child in el:
|
||||
word_break(child, max_width=max_width,
|
||||
avoid_elements=avoid_elements,
|
||||
avoid_classes=avoid_classes,
|
||||
break_character=break_character)
|
||||
if child.tail:
|
||||
child.tail = _break_text(child.tail, max_width, break_character)
|
||||
|
||||
def word_break_html(html, *args, **kw):
|
||||
result_type = type(html)
|
||||
doc = fromstring(html)
|
||||
word_break(doc, *args, **kw)
|
||||
return _transform_result(result_type, doc)
|
||||
|
||||
def _break_text(text, max_width, break_character):
|
||||
words = text.split()
|
||||
for word in words:
|
||||
if len(word) > max_width:
|
||||
replacement = _insert_break(word, max_width, break_character)
|
||||
text = text.replace(word, replacement)
|
||||
return text
|
||||
|
||||
_break_prefer_re = re.compile(r'[^a-z]', re.I)
|
||||
|
||||
def _insert_break(word, width, break_character):
|
||||
orig_word = word
|
||||
result = ''
|
||||
while len(word) > width:
|
||||
start = word[:width]
|
||||
breaks = list(_break_prefer_re.finditer(start))
|
||||
if breaks:
|
||||
last_break = breaks[-1]
|
||||
# Only walk back up to 10 characters to find a nice break:
|
||||
if last_break.end() > width-10:
|
||||
# FIXME: should the break character be at the end of the
|
||||
# chunk, or the beginning of the next chunk?
|
||||
start = word[:last_break.end()]
|
||||
result += start + break_character
|
||||
word = word[len(start):]
|
||||
result += word
|
||||
return result
|
||||
|
||||
135
acer-env/lib/python3.10/site-packages/lxml/html/defs.py
Normal file
135
acer-env/lib/python3.10/site-packages/lxml/html/defs.py
Normal file
@@ -0,0 +1,135 @@
|
||||
# FIXME: this should all be confirmed against what a DTD says
|
||||
# (probably in a test; this may not match the DTD exactly, but we
|
||||
# should document just how it differs).
|
||||
|
||||
"""
|
||||
Data taken from https://www.w3.org/TR/html401/index/elements.html
|
||||
and https://www.w3.org/community/webed/wiki/HTML/New_HTML5_Elements
|
||||
for html5_tags.
|
||||
"""
|
||||
|
||||
empty_tags = frozenset([
|
||||
'area', 'base', 'basefont', 'br', 'col', 'frame', 'hr',
|
||||
'img', 'input', 'isindex', 'link', 'meta', 'param', 'source', 'track'])
|
||||
|
||||
deprecated_tags = frozenset([
|
||||
'applet', 'basefont', 'center', 'dir', 'font', 'isindex',
|
||||
'menu', 's', 'strike', 'u'])
|
||||
|
||||
# archive actually takes a space-separated list of URIs
|
||||
link_attrs = frozenset([
|
||||
'action', 'archive', 'background', 'cite', 'classid',
|
||||
'codebase', 'data', 'href', 'longdesc', 'profile', 'src',
|
||||
'usemap',
|
||||
# Not standard:
|
||||
'dynsrc', 'lowsrc',
|
||||
# HTML5 formaction
|
||||
'formaction'
|
||||
])
|
||||
|
||||
# Not in the HTML 4 spec:
|
||||
# onerror, onresize
|
||||
event_attrs = frozenset([
|
||||
'onblur', 'onchange', 'onclick', 'ondblclick', 'onerror',
|
||||
'onfocus', 'onkeydown', 'onkeypress', 'onkeyup', 'onload',
|
||||
'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover',
|
||||
'onmouseup', 'onreset', 'onresize', 'onselect', 'onsubmit',
|
||||
'onunload',
|
||||
])
|
||||
|
||||
safe_attrs = frozenset([
|
||||
'abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align',
|
||||
'alt', 'axis', 'border', 'cellpadding', 'cellspacing', 'char', 'charoff',
|
||||
'charset', 'checked', 'cite', 'class', 'clear', 'cols', 'colspan',
|
||||
'color', 'compact', 'coords', 'datetime', 'dir', 'disabled', 'enctype',
|
||||
'for', 'frame', 'headers', 'height', 'href', 'hreflang', 'hspace', 'id',
|
||||
'ismap', 'label', 'lang', 'longdesc', 'maxlength', 'media', 'method',
|
||||
'multiple', 'name', 'nohref', 'noshade', 'nowrap', 'prompt', 'readonly',
|
||||
'rel', 'rev', 'rows', 'rowspan', 'rules', 'scope', 'selected', 'shape',
|
||||
'size', 'span', 'src', 'start', 'summary', 'tabindex', 'target', 'title',
|
||||
'type', 'usemap', 'valign', 'value', 'vspace', 'width'])
|
||||
|
||||
# From http://htmlhelp.com/reference/html40/olist.html
|
||||
top_level_tags = frozenset([
|
||||
'html', 'head', 'body', 'frameset',
|
||||
])
|
||||
|
||||
head_tags = frozenset([
|
||||
'base', 'isindex', 'link', 'meta', 'script', 'style', 'title',
|
||||
])
|
||||
|
||||
general_block_tags = frozenset([
|
||||
'address',
|
||||
'blockquote',
|
||||
'center',
|
||||
'del',
|
||||
'div',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'hr',
|
||||
'ins',
|
||||
'isindex',
|
||||
'noscript',
|
||||
'p',
|
||||
'pre',
|
||||
])
|
||||
|
||||
list_tags = frozenset([
|
||||
'dir', 'dl', 'dt', 'dd', 'li', 'menu', 'ol', 'ul',
|
||||
])
|
||||
|
||||
table_tags = frozenset([
|
||||
'table', 'caption', 'colgroup', 'col',
|
||||
'thead', 'tfoot', 'tbody', 'tr', 'td', 'th',
|
||||
])
|
||||
|
||||
# just this one from
|
||||
# http://www.georgehernandez.com/h/XComputers/HTML/2BlockLevel.htm
|
||||
block_tags = general_block_tags | list_tags | table_tags | frozenset([
|
||||
# Partial form tags
|
||||
'fieldset', 'form', 'legend', 'optgroup', 'option',
|
||||
])
|
||||
|
||||
form_tags = frozenset([
|
||||
'form', 'button', 'fieldset', 'legend', 'input', 'label',
|
||||
'select', 'optgroup', 'option', 'textarea',
|
||||
])
|
||||
|
||||
special_inline_tags = frozenset([
|
||||
'a', 'applet', 'basefont', 'bdo', 'br', 'embed', 'font', 'iframe',
|
||||
'img', 'map', 'area', 'object', 'param', 'q', 'script',
|
||||
'span', 'sub', 'sup',
|
||||
])
|
||||
|
||||
phrase_tags = frozenset([
|
||||
'abbr', 'acronym', 'cite', 'code', 'del', 'dfn', 'em',
|
||||
'ins', 'kbd', 'samp', 'strong', 'var',
|
||||
])
|
||||
|
||||
font_style_tags = frozenset([
|
||||
'b', 'big', 'i', 's', 'small', 'strike', 'tt', 'u',
|
||||
])
|
||||
|
||||
frame_tags = frozenset([
|
||||
'frameset', 'frame', 'noframes',
|
||||
])
|
||||
|
||||
html5_tags = frozenset([
|
||||
'article', 'aside', 'audio', 'canvas', 'command', 'datalist',
|
||||
'details', 'embed', 'figcaption', 'figure', 'footer', 'header',
|
||||
'hgroup', 'keygen', 'mark', 'math', 'meter', 'nav', 'output',
|
||||
'progress', 'rp', 'rt', 'ruby', 'section', 'source', 'summary',
|
||||
'svg', 'time', 'track', 'video', 'wbr'
|
||||
])
|
||||
|
||||
# These tags aren't standard
|
||||
nonstandard_tags = frozenset(['blink', 'marquee'])
|
||||
|
||||
|
||||
tags = (top_level_tags | head_tags | general_block_tags | list_tags
|
||||
| table_tags | form_tags | special_inline_tags | phrase_tags
|
||||
| font_style_tags | nonstandard_tags | html5_tags)
|
||||
Binary file not shown.
884
acer-env/lib/python3.10/site-packages/lxml/html/diff.py
Normal file
884
acer-env/lib/python3.10/site-packages/lxml/html/diff.py
Normal file
@@ -0,0 +1,884 @@
|
||||
# cython: language_level=3
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import difflib
|
||||
from lxml import etree
|
||||
from lxml.html import fragment_fromstring
|
||||
import re
|
||||
|
||||
__all__ = ['html_annotate', 'htmldiff']
|
||||
|
||||
try:
|
||||
from html import escape as html_escape
|
||||
except ImportError:
|
||||
from cgi import escape as html_escape
|
||||
try:
|
||||
_unicode = unicode
|
||||
except NameError:
|
||||
# Python 3
|
||||
_unicode = str
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
# Python 3
|
||||
basestring = str
|
||||
|
||||
############################################################
|
||||
## Annotation
|
||||
############################################################
|
||||
|
||||
def default_markup(text, version):
|
||||
return '<span title="%s">%s</span>' % (
|
||||
html_escape(_unicode(version), 1), text)
|
||||
|
||||
def html_annotate(doclist, markup=default_markup):
|
||||
"""
|
||||
doclist should be ordered from oldest to newest, like::
|
||||
|
||||
>>> version1 = 'Hello World'
|
||||
>>> version2 = 'Goodbye World'
|
||||
>>> print(html_annotate([(version1, 'version 1'),
|
||||
... (version2, 'version 2')]))
|
||||
<span title="version 2">Goodbye</span> <span title="version 1">World</span>
|
||||
|
||||
The documents must be *fragments* (str/UTF8 or unicode), not
|
||||
complete documents
|
||||
|
||||
The markup argument is a function to markup the spans of words.
|
||||
This function is called like markup('Hello', 'version 2'), and
|
||||
returns HTML. The first argument is text and never includes any
|
||||
markup. The default uses a span with a title:
|
||||
|
||||
>>> print(default_markup('Some Text', 'by Joe'))
|
||||
<span title="by Joe">Some Text</span>
|
||||
"""
|
||||
# The basic strategy we have is to split the documents up into
|
||||
# logical tokens (which are words with attached markup). We then
|
||||
# do diffs of each of the versions to track when a token first
|
||||
# appeared in the document; the annotation attached to the token
|
||||
# is the version where it first appeared.
|
||||
tokenlist = [tokenize_annotated(doc, version)
|
||||
for doc, version in doclist]
|
||||
cur_tokens = tokenlist[0]
|
||||
for tokens in tokenlist[1:]:
|
||||
html_annotate_merge_annotations(cur_tokens, tokens)
|
||||
cur_tokens = tokens
|
||||
|
||||
# After we've tracked all the tokens, we can combine spans of text
|
||||
# that are adjacent and have the same annotation
|
||||
cur_tokens = compress_tokens(cur_tokens)
|
||||
# And finally add markup
|
||||
result = markup_serialize_tokens(cur_tokens, markup)
|
||||
return ''.join(result).strip()
|
||||
|
||||
def tokenize_annotated(doc, annotation):
|
||||
"""Tokenize a document and add an annotation attribute to each token
|
||||
"""
|
||||
tokens = tokenize(doc, include_hrefs=False)
|
||||
for tok in tokens:
|
||||
tok.annotation = annotation
|
||||
return tokens
|
||||
|
||||
def html_annotate_merge_annotations(tokens_old, tokens_new):
|
||||
"""Merge the annotations from tokens_old into tokens_new, when the
|
||||
tokens in the new document already existed in the old document.
|
||||
"""
|
||||
s = InsensitiveSequenceMatcher(a=tokens_old, b=tokens_new)
|
||||
commands = s.get_opcodes()
|
||||
|
||||
for command, i1, i2, j1, j2 in commands:
|
||||
if command == 'equal':
|
||||
eq_old = tokens_old[i1:i2]
|
||||
eq_new = tokens_new[j1:j2]
|
||||
copy_annotations(eq_old, eq_new)
|
||||
|
||||
def copy_annotations(src, dest):
|
||||
"""
|
||||
Copy annotations from the tokens listed in src to the tokens in dest
|
||||
"""
|
||||
assert len(src) == len(dest)
|
||||
for src_tok, dest_tok in zip(src, dest):
|
||||
dest_tok.annotation = src_tok.annotation
|
||||
|
||||
def compress_tokens(tokens):
|
||||
"""
|
||||
Combine adjacent tokens when there is no HTML between the tokens,
|
||||
and they share an annotation
|
||||
"""
|
||||
result = [tokens[0]]
|
||||
for tok in tokens[1:]:
|
||||
if (not result[-1].post_tags and
|
||||
not tok.pre_tags and
|
||||
result[-1].annotation == tok.annotation):
|
||||
compress_merge_back(result, tok)
|
||||
else:
|
||||
result.append(tok)
|
||||
return result
|
||||
|
||||
def compress_merge_back(tokens, tok):
|
||||
""" Merge tok into the last element of tokens (modifying the list of
|
||||
tokens in-place). """
|
||||
last = tokens[-1]
|
||||
if type(last) is not token or type(tok) is not token:
|
||||
tokens.append(tok)
|
||||
else:
|
||||
text = _unicode(last)
|
||||
if last.trailing_whitespace:
|
||||
text += last.trailing_whitespace
|
||||
text += tok
|
||||
merged = token(text,
|
||||
pre_tags=last.pre_tags,
|
||||
post_tags=tok.post_tags,
|
||||
trailing_whitespace=tok.trailing_whitespace)
|
||||
merged.annotation = last.annotation
|
||||
tokens[-1] = merged
|
||||
|
||||
def markup_serialize_tokens(tokens, markup_func):
|
||||
"""
|
||||
Serialize the list of tokens into a list of text chunks, calling
|
||||
markup_func around text to add annotations.
|
||||
"""
|
||||
for token in tokens:
|
||||
for pre in token.pre_tags:
|
||||
yield pre
|
||||
html = token.html()
|
||||
html = markup_func(html, token.annotation)
|
||||
if token.trailing_whitespace:
|
||||
html += token.trailing_whitespace
|
||||
yield html
|
||||
for post in token.post_tags:
|
||||
yield post
|
||||
|
||||
|
||||
############################################################
|
||||
## HTML Diffs
|
||||
############################################################
|
||||
|
||||
def htmldiff(old_html, new_html):
|
||||
## FIXME: this should take parsed documents too, and use their body
|
||||
## or other content.
|
||||
""" Do a diff of the old and new document. The documents are HTML
|
||||
*fragments* (str/UTF8 or unicode), they are not complete documents
|
||||
(i.e., no <html> tag).
|
||||
|
||||
Returns HTML with <ins> and <del> tags added around the
|
||||
appropriate text.
|
||||
|
||||
Markup is generally ignored, with the markup from new_html
|
||||
preserved, and possibly some markup from old_html (though it is
|
||||
considered acceptable to lose some of the old markup). Only the
|
||||
words in the HTML are diffed. The exception is <img> tags, which
|
||||
are treated like words, and the href attribute of <a> tags, which
|
||||
are noted inside the tag itself when there are changes.
|
||||
"""
|
||||
old_html_tokens = tokenize(old_html)
|
||||
new_html_tokens = tokenize(new_html)
|
||||
result = htmldiff_tokens(old_html_tokens, new_html_tokens)
|
||||
result = ''.join(result).strip()
|
||||
return fixup_ins_del_tags(result)
|
||||
|
||||
def htmldiff_tokens(html1_tokens, html2_tokens):
|
||||
""" Does a diff on the tokens themselves, returning a list of text
|
||||
chunks (not tokens).
|
||||
"""
|
||||
# There are several passes as we do the differences. The tokens
|
||||
# isolate the portion of the content we care to diff; difflib does
|
||||
# all the actual hard work at that point.
|
||||
#
|
||||
# Then we must create a valid document from pieces of both the old
|
||||
# document and the new document. We generally prefer to take
|
||||
# markup from the new document, and only do a best effort attempt
|
||||
# to keep markup from the old document; anything that we can't
|
||||
# resolve we throw away. Also we try to put the deletes as close
|
||||
# to the location where we think they would have been -- because
|
||||
# we are only keeping the markup from the new document, it can be
|
||||
# fuzzy where in the new document the old text would have gone.
|
||||
# Again we just do a best effort attempt.
|
||||
s = InsensitiveSequenceMatcher(a=html1_tokens, b=html2_tokens)
|
||||
commands = s.get_opcodes()
|
||||
result = []
|
||||
for command, i1, i2, j1, j2 in commands:
|
||||
if command == 'equal':
|
||||
result.extend(expand_tokens(html2_tokens[j1:j2], equal=True))
|
||||
continue
|
||||
if command == 'insert' or command == 'replace':
|
||||
ins_tokens = expand_tokens(html2_tokens[j1:j2])
|
||||
merge_insert(ins_tokens, result)
|
||||
if command == 'delete' or command == 'replace':
|
||||
del_tokens = expand_tokens(html1_tokens[i1:i2])
|
||||
merge_delete(del_tokens, result)
|
||||
# If deletes were inserted directly as <del> then we'd have an
|
||||
# invalid document at this point. Instead we put in special
|
||||
# markers, and when the complete diffed document has been created
|
||||
# we try to move the deletes around and resolve any problems.
|
||||
result = cleanup_delete(result)
|
||||
|
||||
return result
|
||||
|
||||
def expand_tokens(tokens, equal=False):
|
||||
"""Given a list of tokens, return a generator of the chunks of
|
||||
text for the data in the tokens.
|
||||
"""
|
||||
for token in tokens:
|
||||
for pre in token.pre_tags:
|
||||
yield pre
|
||||
if not equal or not token.hide_when_equal:
|
||||
if token.trailing_whitespace:
|
||||
yield token.html() + token.trailing_whitespace
|
||||
else:
|
||||
yield token.html()
|
||||
for post in token.post_tags:
|
||||
yield post
|
||||
|
||||
def merge_insert(ins_chunks, doc):
|
||||
""" doc is the already-handled document (as a list of text chunks);
|
||||
here we add <ins>ins_chunks</ins> to the end of that. """
|
||||
# Though we don't throw away unbalanced_start or unbalanced_end
|
||||
# (we assume there is accompanying markup later or earlier in the
|
||||
# document), we only put <ins> around the balanced portion.
|
||||
unbalanced_start, balanced, unbalanced_end = split_unbalanced(ins_chunks)
|
||||
doc.extend(unbalanced_start)
|
||||
if doc and not doc[-1].endswith(' '):
|
||||
# Fix up the case where the word before the insert didn't end with
|
||||
# a space
|
||||
doc[-1] += ' '
|
||||
doc.append('<ins>')
|
||||
if balanced and balanced[-1].endswith(' '):
|
||||
# We move space outside of </ins>
|
||||
balanced[-1] = balanced[-1][:-1]
|
||||
doc.extend(balanced)
|
||||
doc.append('</ins> ')
|
||||
doc.extend(unbalanced_end)
|
||||
|
||||
# These are sentinels to represent the start and end of a <del>
|
||||
# segment, until we do the cleanup phase to turn them into proper
|
||||
# markup:
|
||||
class DEL_START:
|
||||
pass
|
||||
class DEL_END:
|
||||
pass
|
||||
|
||||
class NoDeletes(Exception):
|
||||
""" Raised when the document no longer contains any pending deletes
|
||||
(DEL_START/DEL_END) """
|
||||
|
||||
def merge_delete(del_chunks, doc):
|
||||
""" Adds the text chunks in del_chunks to the document doc (another
|
||||
list of text chunks) with marker to show it is a delete.
|
||||
cleanup_delete later resolves these markers into <del> tags."""
|
||||
doc.append(DEL_START)
|
||||
doc.extend(del_chunks)
|
||||
doc.append(DEL_END)
|
||||
|
||||
def cleanup_delete(chunks):
|
||||
""" Cleans up any DEL_START/DEL_END markers in the document, replacing
|
||||
them with <del></del>. To do this while keeping the document
|
||||
valid, it may need to drop some tags (either start or end tags).
|
||||
|
||||
It may also move the del into adjacent tags to try to move it to a
|
||||
similar location where it was originally located (e.g., moving a
|
||||
delete into preceding <div> tag, if the del looks like (DEL_START,
|
||||
'Text</div>', DEL_END)"""
|
||||
while 1:
|
||||
# Find a pending DEL_START/DEL_END, splitting the document
|
||||
# into stuff-preceding-DEL_START, stuff-inside, and
|
||||
# stuff-following-DEL_END
|
||||
try:
|
||||
pre_delete, delete, post_delete = split_delete(chunks)
|
||||
except NoDeletes:
|
||||
# Nothing found, we've cleaned up the entire doc
|
||||
break
|
||||
# The stuff-inside-DEL_START/END may not be well balanced
|
||||
# markup. First we figure out what unbalanced portions there are:
|
||||
unbalanced_start, balanced, unbalanced_end = split_unbalanced(delete)
|
||||
# Then we move the span forward and/or backward based on these
|
||||
# unbalanced portions:
|
||||
locate_unbalanced_start(unbalanced_start, pre_delete, post_delete)
|
||||
locate_unbalanced_end(unbalanced_end, pre_delete, post_delete)
|
||||
doc = pre_delete
|
||||
if doc and not doc[-1].endswith(' '):
|
||||
# Fix up case where the word before us didn't have a trailing space
|
||||
doc[-1] += ' '
|
||||
doc.append('<del>')
|
||||
if balanced and balanced[-1].endswith(' '):
|
||||
# We move space outside of </del>
|
||||
balanced[-1] = balanced[-1][:-1]
|
||||
doc.extend(balanced)
|
||||
doc.append('</del> ')
|
||||
doc.extend(post_delete)
|
||||
chunks = doc
|
||||
return chunks
|
||||
|
||||
def split_unbalanced(chunks):
|
||||
"""Return (unbalanced_start, balanced, unbalanced_end), where each is
|
||||
a list of text and tag chunks.
|
||||
|
||||
unbalanced_start is a list of all the tags that are opened, but
|
||||
not closed in this span. Similarly, unbalanced_end is a list of
|
||||
tags that are closed but were not opened. Extracting these might
|
||||
mean some reordering of the chunks."""
|
||||
start = []
|
||||
end = []
|
||||
tag_stack = []
|
||||
balanced = []
|
||||
for chunk in chunks:
|
||||
if not chunk.startswith('<'):
|
||||
balanced.append(chunk)
|
||||
continue
|
||||
endtag = chunk[1] == '/'
|
||||
name = chunk.split()[0].strip('<>/')
|
||||
if name in empty_tags:
|
||||
balanced.append(chunk)
|
||||
continue
|
||||
if endtag:
|
||||
if tag_stack and tag_stack[-1][0] == name:
|
||||
balanced.append(chunk)
|
||||
name, pos, tag = tag_stack.pop()
|
||||
balanced[pos] = tag
|
||||
elif tag_stack:
|
||||
start.extend([tag for name, pos, tag in tag_stack])
|
||||
tag_stack = []
|
||||
end.append(chunk)
|
||||
else:
|
||||
end.append(chunk)
|
||||
else:
|
||||
tag_stack.append((name, len(balanced), chunk))
|
||||
balanced.append(None)
|
||||
start.extend(
|
||||
[chunk for name, pos, chunk in tag_stack])
|
||||
balanced = [chunk for chunk in balanced if chunk is not None]
|
||||
return start, balanced, end
|
||||
|
||||
def split_delete(chunks):
|
||||
""" Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,
|
||||
stuff_after_DEL_END). Returns the first case found (there may be
|
||||
more DEL_STARTs in stuff_after_DEL_END). Raises NoDeletes if
|
||||
there's no DEL_START found. """
|
||||
try:
|
||||
pos = chunks.index(DEL_START)
|
||||
except ValueError:
|
||||
raise NoDeletes
|
||||
pos2 = chunks.index(DEL_END)
|
||||
return chunks[:pos], chunks[pos+1:pos2], chunks[pos2+1:]
|
||||
|
||||
def locate_unbalanced_start(unbalanced_start, pre_delete, post_delete):
|
||||
""" pre_delete and post_delete implicitly point to a place in the
|
||||
document (where the two were split). This moves that point (by
|
||||
popping items from one and pushing them onto the other). It moves
|
||||
the point to try to find a place where unbalanced_start applies.
|
||||
|
||||
As an example::
|
||||
|
||||
>>> unbalanced_start = ['<div>']
|
||||
>>> doc = ['<p>', 'Text', '</p>', '<div>', 'More Text', '</div>']
|
||||
>>> pre, post = doc[:3], doc[3:]
|
||||
>>> pre, post
|
||||
(['<p>', 'Text', '</p>'], ['<div>', 'More Text', '</div>'])
|
||||
>>> locate_unbalanced_start(unbalanced_start, pre, post)
|
||||
>>> pre, post
|
||||
(['<p>', 'Text', '</p>', '<div>'], ['More Text', '</div>'])
|
||||
|
||||
As you can see, we moved the point so that the dangling <div> that
|
||||
we found will be effectively replaced by the div in the original
|
||||
document. If this doesn't work out, we just throw away
|
||||
unbalanced_start without doing anything.
|
||||
"""
|
||||
while 1:
|
||||
if not unbalanced_start:
|
||||
# We have totally succeeded in finding the position
|
||||
break
|
||||
finding = unbalanced_start[0]
|
||||
finding_name = finding.split()[0].strip('<>')
|
||||
if not post_delete:
|
||||
break
|
||||
next = post_delete[0]
|
||||
if next is DEL_START or not next.startswith('<'):
|
||||
# Reached a word, we can't move the delete text forward
|
||||
break
|
||||
if next[1] == '/':
|
||||
# Reached a closing tag, can we go further? Maybe not...
|
||||
break
|
||||
name = next.split()[0].strip('<>')
|
||||
if name == 'ins':
|
||||
# Can't move into an insert
|
||||
break
|
||||
assert name != 'del', (
|
||||
"Unexpected delete tag: %r" % next)
|
||||
if name == finding_name:
|
||||
unbalanced_start.pop(0)
|
||||
pre_delete.append(post_delete.pop(0))
|
||||
else:
|
||||
# Found a tag that doesn't match
|
||||
break
|
||||
|
||||
def locate_unbalanced_end(unbalanced_end, pre_delete, post_delete):
|
||||
""" like locate_unbalanced_start, except handling end tags and
|
||||
possibly moving the point earlier in the document. """
|
||||
while 1:
|
||||
if not unbalanced_end:
|
||||
# Success
|
||||
break
|
||||
finding = unbalanced_end[-1]
|
||||
finding_name = finding.split()[0].strip('<>/')
|
||||
if not pre_delete:
|
||||
break
|
||||
next = pre_delete[-1]
|
||||
if next is DEL_END or not next.startswith('</'):
|
||||
# A word or a start tag
|
||||
break
|
||||
name = next.split()[0].strip('<>/')
|
||||
if name == 'ins' or name == 'del':
|
||||
# Can't move into an insert or delete
|
||||
break
|
||||
if name == finding_name:
|
||||
unbalanced_end.pop()
|
||||
post_delete.insert(0, pre_delete.pop())
|
||||
else:
|
||||
# Found a tag that doesn't match
|
||||
break
|
||||
|
||||
class token(_unicode):
|
||||
""" Represents a diffable token, generally a word that is displayed to
|
||||
the user. Opening tags are attached to this token when they are
|
||||
adjacent (pre_tags) and closing tags that follow the word
|
||||
(post_tags). Some exceptions occur when there are empty tags
|
||||
adjacent to a word, so there may be close tags in pre_tags, or
|
||||
open tags in post_tags.
|
||||
|
||||
We also keep track of whether the word was originally followed by
|
||||
whitespace, even though we do not want to treat the word as
|
||||
equivalent to a similar word that does not have a trailing
|
||||
space."""
|
||||
|
||||
# When this is true, the token will be eliminated from the
|
||||
# displayed diff if no change has occurred:
|
||||
hide_when_equal = False
|
||||
|
||||
def __new__(cls, text, pre_tags=None, post_tags=None, trailing_whitespace=""):
|
||||
obj = _unicode.__new__(cls, text)
|
||||
|
||||
if pre_tags is not None:
|
||||
obj.pre_tags = pre_tags
|
||||
else:
|
||||
obj.pre_tags = []
|
||||
|
||||
if post_tags is not None:
|
||||
obj.post_tags = post_tags
|
||||
else:
|
||||
obj.post_tags = []
|
||||
|
||||
obj.trailing_whitespace = trailing_whitespace
|
||||
|
||||
return obj
|
||||
|
||||
def __repr__(self):
|
||||
return 'token(%s, %r, %r, %r)' % (_unicode.__repr__(self), self.pre_tags,
|
||||
self.post_tags, self.trailing_whitespace)
|
||||
|
||||
def html(self):
|
||||
return _unicode(self)
|
||||
|
||||
class tag_token(token):
|
||||
|
||||
""" Represents a token that is actually a tag. Currently this is just
|
||||
the <img> tag, which takes up visible space just like a word but
|
||||
is only represented in a document by a tag. """
|
||||
|
||||
def __new__(cls, tag, data, html_repr, pre_tags=None,
|
||||
post_tags=None, trailing_whitespace=""):
|
||||
obj = token.__new__(cls, "%s: %s" % (type, data),
|
||||
pre_tags=pre_tags,
|
||||
post_tags=post_tags,
|
||||
trailing_whitespace=trailing_whitespace)
|
||||
obj.tag = tag
|
||||
obj.data = data
|
||||
obj.html_repr = html_repr
|
||||
return obj
|
||||
|
||||
def __repr__(self):
|
||||
return 'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%r)' % (
|
||||
self.tag,
|
||||
self.data,
|
||||
self.html_repr,
|
||||
self.pre_tags,
|
||||
self.post_tags,
|
||||
self.trailing_whitespace)
|
||||
def html(self):
|
||||
return self.html_repr
|
||||
|
||||
class href_token(token):
|
||||
|
||||
""" Represents the href in an anchor tag. Unlike other words, we only
|
||||
show the href when it changes. """
|
||||
|
||||
hide_when_equal = True
|
||||
|
||||
def html(self):
|
||||
return ' Link: %s' % self
|
||||
|
||||
def tokenize(html, include_hrefs=True):
|
||||
"""
|
||||
Parse the given HTML and returns token objects (words with attached tags).
|
||||
|
||||
This parses only the content of a page; anything in the head is
|
||||
ignored, and the <head> and <body> elements are themselves
|
||||
optional. The content is then parsed by lxml, which ensures the
|
||||
validity of the resulting parsed document (though lxml may make
|
||||
incorrect guesses when the markup is particular bad).
|
||||
|
||||
<ins> and <del> tags are also eliminated from the document, as
|
||||
that gets confusing.
|
||||
|
||||
If include_hrefs is true, then the href attribute of <a> tags is
|
||||
included as a special kind of diffable token."""
|
||||
if etree.iselement(html):
|
||||
body_el = html
|
||||
else:
|
||||
body_el = parse_html(html, cleanup=True)
|
||||
# Then we split the document into text chunks for each tag, word, and end tag:
|
||||
chunks = flatten_el(body_el, skip_tag=True, include_hrefs=include_hrefs)
|
||||
# Finally re-joining them into token objects:
|
||||
return fixup_chunks(chunks)
|
||||
|
||||
def parse_html(html, cleanup=True):
|
||||
"""
|
||||
Parses an HTML fragment, returning an lxml element. Note that the HTML will be
|
||||
wrapped in a <div> tag that was not in the original document.
|
||||
|
||||
If cleanup is true, make sure there's no <head> or <body>, and get
|
||||
rid of any <ins> and <del> tags.
|
||||
"""
|
||||
if cleanup:
|
||||
# This removes any extra markup or structure like <head>:
|
||||
html = cleanup_html(html)
|
||||
return fragment_fromstring(html, create_parent=True)
|
||||
|
||||
_body_re = re.compile(r'<body.*?>', re.I|re.S)
|
||||
_end_body_re = re.compile(r'</body.*?>', re.I|re.S)
|
||||
_ins_del_re = re.compile(r'</?(ins|del).*?>', re.I|re.S)
|
||||
|
||||
def cleanup_html(html):
|
||||
""" This 'cleans' the HTML, meaning that any page structure is removed
|
||||
(only the contents of <body> are used, if there is any <body).
|
||||
Also <ins> and <del> tags are removed. """
|
||||
match = _body_re.search(html)
|
||||
if match:
|
||||
html = html[match.end():]
|
||||
match = _end_body_re.search(html)
|
||||
if match:
|
||||
html = html[:match.start()]
|
||||
html = _ins_del_re.sub('', html)
|
||||
return html
|
||||
|
||||
|
||||
end_whitespace_re = re.compile(r'[ \t\n\r]$')
|
||||
|
||||
def split_trailing_whitespace(word):
|
||||
"""
|
||||
This function takes a word, such as 'test\n\n' and returns ('test','\n\n')
|
||||
"""
|
||||
stripped_length = len(word.rstrip())
|
||||
return word[0:stripped_length], word[stripped_length:]
|
||||
|
||||
|
||||
def fixup_chunks(chunks):
|
||||
"""
|
||||
This function takes a list of chunks and produces a list of tokens.
|
||||
"""
|
||||
tag_accum = []
|
||||
cur_word = None
|
||||
result = []
|
||||
for chunk in chunks:
|
||||
if isinstance(chunk, tuple):
|
||||
if chunk[0] == 'img':
|
||||
src = chunk[1]
|
||||
tag, trailing_whitespace = split_trailing_whitespace(chunk[2])
|
||||
cur_word = tag_token('img', src, html_repr=tag,
|
||||
pre_tags=tag_accum,
|
||||
trailing_whitespace=trailing_whitespace)
|
||||
tag_accum = []
|
||||
result.append(cur_word)
|
||||
|
||||
elif chunk[0] == 'href':
|
||||
href = chunk[1]
|
||||
cur_word = href_token(href, pre_tags=tag_accum, trailing_whitespace=" ")
|
||||
tag_accum = []
|
||||
result.append(cur_word)
|
||||
continue
|
||||
|
||||
if is_word(chunk):
|
||||
chunk, trailing_whitespace = split_trailing_whitespace(chunk)
|
||||
cur_word = token(chunk, pre_tags=tag_accum, trailing_whitespace=trailing_whitespace)
|
||||
tag_accum = []
|
||||
result.append(cur_word)
|
||||
|
||||
elif is_start_tag(chunk):
|
||||
tag_accum.append(chunk)
|
||||
|
||||
elif is_end_tag(chunk):
|
||||
if tag_accum:
|
||||
tag_accum.append(chunk)
|
||||
else:
|
||||
assert cur_word, (
|
||||
"Weird state, cur_word=%r, result=%r, chunks=%r of %r"
|
||||
% (cur_word, result, chunk, chunks))
|
||||
cur_word.post_tags.append(chunk)
|
||||
else:
|
||||
assert False
|
||||
|
||||
if not result:
|
||||
return [token('', pre_tags=tag_accum)]
|
||||
else:
|
||||
result[-1].post_tags.extend(tag_accum)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
# All the tags in HTML that don't require end tags:
|
||||
empty_tags = (
|
||||
'param', 'img', 'area', 'br', 'basefont', 'input',
|
||||
'base', 'meta', 'link', 'col')
|
||||
|
||||
block_level_tags = (
|
||||
'address',
|
||||
'blockquote',
|
||||
'center',
|
||||
'dir',
|
||||
'div',
|
||||
'dl',
|
||||
'fieldset',
|
||||
'form',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'hr',
|
||||
'isindex',
|
||||
'menu',
|
||||
'noframes',
|
||||
'noscript',
|
||||
'ol',
|
||||
'p',
|
||||
'pre',
|
||||
'table',
|
||||
'ul',
|
||||
)
|
||||
|
||||
block_level_container_tags = (
|
||||
'dd',
|
||||
'dt',
|
||||
'frameset',
|
||||
'li',
|
||||
'tbody',
|
||||
'td',
|
||||
'tfoot',
|
||||
'th',
|
||||
'thead',
|
||||
'tr',
|
||||
)
|
||||
|
||||
|
||||
def flatten_el(el, include_hrefs, skip_tag=False):
|
||||
""" Takes an lxml element el, and generates all the text chunks for
|
||||
that tag. Each start tag is a chunk, each word is a chunk, and each
|
||||
end tag is a chunk.
|
||||
|
||||
If skip_tag is true, then the outermost container tag is
|
||||
not returned (just its contents)."""
|
||||
if not skip_tag:
|
||||
if el.tag == 'img':
|
||||
yield ('img', el.get('src'), start_tag(el))
|
||||
else:
|
||||
yield start_tag(el)
|
||||
if el.tag in empty_tags and not el.text and not len(el) and not el.tail:
|
||||
return
|
||||
start_words = split_words(el.text)
|
||||
for word in start_words:
|
||||
yield html_escape(word)
|
||||
for child in el:
|
||||
for item in flatten_el(child, include_hrefs=include_hrefs):
|
||||
yield item
|
||||
if el.tag == 'a' and el.get('href') and include_hrefs:
|
||||
yield ('href', el.get('href'))
|
||||
if not skip_tag:
|
||||
yield end_tag(el)
|
||||
end_words = split_words(el.tail)
|
||||
for word in end_words:
|
||||
yield html_escape(word)
|
||||
|
||||
split_words_re = re.compile(r'\S+(?:\s+|$)', re.U)
|
||||
|
||||
def split_words(text):
|
||||
""" Splits some text into words. Includes trailing whitespace
|
||||
on each word when appropriate. """
|
||||
if not text or not text.strip():
|
||||
return []
|
||||
|
||||
words = split_words_re.findall(text)
|
||||
return words
|
||||
|
||||
start_whitespace_re = re.compile(r'^[ \t\n\r]')
|
||||
|
||||
def start_tag(el):
|
||||
"""
|
||||
The text representation of the start tag for a tag.
|
||||
"""
|
||||
return '<%s%s>' % (
|
||||
el.tag, ''.join([' %s="%s"' % (name, html_escape(value, True))
|
||||
for name, value in el.attrib.items()]))
|
||||
|
||||
def end_tag(el):
|
||||
""" The text representation of an end tag for a tag. Includes
|
||||
trailing whitespace when appropriate. """
|
||||
if el.tail and start_whitespace_re.search(el.tail):
|
||||
extra = ' '
|
||||
else:
|
||||
extra = ''
|
||||
return '</%s>%s' % (el.tag, extra)
|
||||
|
||||
def is_word(tok):
|
||||
return not tok.startswith('<')
|
||||
|
||||
def is_end_tag(tok):
|
||||
return tok.startswith('</')
|
||||
|
||||
def is_start_tag(tok):
|
||||
return tok.startswith('<') and not tok.startswith('</')
|
||||
|
||||
def fixup_ins_del_tags(html):
|
||||
""" Given an html string, move any <ins> or <del> tags inside of any
|
||||
block-level elements, e.g. transform <ins><p>word</p></ins> to
|
||||
<p><ins>word</ins></p> """
|
||||
doc = parse_html(html, cleanup=False)
|
||||
_fixup_ins_del_tags(doc)
|
||||
html = serialize_html_fragment(doc, skip_outer=True)
|
||||
return html
|
||||
|
||||
def serialize_html_fragment(el, skip_outer=False):
|
||||
""" Serialize a single lxml element as HTML. The serialized form
|
||||
includes the elements tail.
|
||||
|
||||
If skip_outer is true, then don't serialize the outermost tag
|
||||
"""
|
||||
assert not isinstance(el, basestring), (
|
||||
"You should pass in an element, not a string like %r" % el)
|
||||
html = etree.tostring(el, method="html", encoding=_unicode)
|
||||
if skip_outer:
|
||||
# Get rid of the extra starting tag:
|
||||
html = html[html.find('>')+1:]
|
||||
# Get rid of the extra end tag:
|
||||
html = html[:html.rfind('<')]
|
||||
return html.strip()
|
||||
else:
|
||||
return html
|
||||
|
||||
def _fixup_ins_del_tags(doc):
|
||||
"""fixup_ins_del_tags that works on an lxml document in-place
|
||||
"""
|
||||
for tag in ['ins', 'del']:
|
||||
for el in doc.xpath('descendant-or-self::%s' % tag):
|
||||
if not _contains_block_level_tag(el):
|
||||
continue
|
||||
_move_el_inside_block(el, tag=tag)
|
||||
el.drop_tag()
|
||||
#_merge_element_contents(el)
|
||||
|
||||
def _contains_block_level_tag(el):
|
||||
"""True if the element contains any block-level elements, like <p>, <td>, etc.
|
||||
"""
|
||||
if el.tag in block_level_tags or el.tag in block_level_container_tags:
|
||||
return True
|
||||
for child in el:
|
||||
if _contains_block_level_tag(child):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _move_el_inside_block(el, tag):
|
||||
""" helper for _fixup_ins_del_tags; actually takes the <ins> etc tags
|
||||
and moves them inside any block-level tags. """
|
||||
for child in el:
|
||||
if _contains_block_level_tag(child):
|
||||
break
|
||||
else:
|
||||
# No block-level tags in any child
|
||||
children_tag = etree.Element(tag)
|
||||
children_tag.text = el.text
|
||||
el.text = None
|
||||
children_tag.extend(list(el))
|
||||
el[:] = [children_tag]
|
||||
return
|
||||
for child in list(el):
|
||||
if _contains_block_level_tag(child):
|
||||
_move_el_inside_block(child, tag)
|
||||
if child.tail:
|
||||
tail_tag = etree.Element(tag)
|
||||
tail_tag.text = child.tail
|
||||
child.tail = None
|
||||
el.insert(el.index(child)+1, tail_tag)
|
||||
else:
|
||||
child_tag = etree.Element(tag)
|
||||
el.replace(child, child_tag)
|
||||
child_tag.append(child)
|
||||
if el.text:
|
||||
text_tag = etree.Element(tag)
|
||||
text_tag.text = el.text
|
||||
el.text = None
|
||||
el.insert(0, text_tag)
|
||||
|
||||
def _merge_element_contents(el):
|
||||
"""
|
||||
Removes an element, but merges its contents into its place, e.g.,
|
||||
given <p>Hi <i>there!</i></p>, if you remove the <i> element you get
|
||||
<p>Hi there!</p>
|
||||
"""
|
||||
parent = el.getparent()
|
||||
text = el.text or ''
|
||||
if el.tail:
|
||||
if not len(el):
|
||||
text += el.tail
|
||||
else:
|
||||
if el[-1].tail:
|
||||
el[-1].tail += el.tail
|
||||
else:
|
||||
el[-1].tail = el.tail
|
||||
index = parent.index(el)
|
||||
if text:
|
||||
if index == 0:
|
||||
previous = None
|
||||
else:
|
||||
previous = parent[index-1]
|
||||
if previous is None:
|
||||
if parent.text:
|
||||
parent.text += text
|
||||
else:
|
||||
parent.text = text
|
||||
else:
|
||||
if previous.tail:
|
||||
previous.tail += text
|
||||
else:
|
||||
previous.tail = text
|
||||
parent[index:index+1] = el.getchildren()
|
||||
|
||||
class InsensitiveSequenceMatcher(difflib.SequenceMatcher):
|
||||
"""
|
||||
Acts like SequenceMatcher, but tries not to find very small equal
|
||||
blocks amidst large spans of changes
|
||||
"""
|
||||
|
||||
threshold = 2
|
||||
|
||||
def get_matching_blocks(self):
|
||||
size = min(len(self.b), len(self.b))
|
||||
threshold = min(self.threshold, size / 4)
|
||||
actual = difflib.SequenceMatcher.get_matching_blocks(self)
|
||||
return [item for item in actual
|
||||
if item[2] > threshold
|
||||
or not item[2]]
|
||||
|
||||
if __name__ == '__main__':
|
||||
from lxml.html import _diffcommand
|
||||
_diffcommand.main()
|
||||
|
||||
299
acer-env/lib/python3.10/site-packages/lxml/html/formfill.py
Normal file
299
acer-env/lib/python3.10/site-packages/lxml/html/formfill.py
Normal file
@@ -0,0 +1,299 @@
|
||||
from lxml.etree import XPath, ElementBase
|
||||
from lxml.html import fromstring, XHTML_NAMESPACE
|
||||
from lxml.html import _forms_xpath, _options_xpath, _nons, _transform_result
|
||||
from lxml.html import defs
|
||||
import copy
|
||||
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
# Python 3
|
||||
basestring = str
|
||||
|
||||
__all__ = ['FormNotFound', 'fill_form', 'fill_form_html',
|
||||
'insert_errors', 'insert_errors_html',
|
||||
'DefaultErrorCreator']
|
||||
|
||||
class FormNotFound(LookupError):
|
||||
"""
|
||||
Raised when no form can be found
|
||||
"""
|
||||
|
||||
_form_name_xpath = XPath('descendant-or-self::form[name=$name]|descendant-or-self::x:form[name=$name]', namespaces={'x':XHTML_NAMESPACE})
|
||||
_input_xpath = XPath('|'.join(['descendant-or-self::'+_tag for _tag in ('input','select','textarea','x:input','x:select','x:textarea')]),
|
||||
namespaces={'x':XHTML_NAMESPACE})
|
||||
_label_for_xpath = XPath('//label[@for=$for_id]|//x:label[@for=$for_id]',
|
||||
namespaces={'x':XHTML_NAMESPACE})
|
||||
_name_xpath = XPath('descendant-or-self::*[@name=$name]')
|
||||
|
||||
def fill_form(
|
||||
el,
|
||||
values,
|
||||
form_id=None,
|
||||
form_index=None,
|
||||
):
|
||||
el = _find_form(el, form_id=form_id, form_index=form_index)
|
||||
_fill_form(el, values)
|
||||
|
||||
def fill_form_html(html, values, form_id=None, form_index=None):
|
||||
result_type = type(html)
|
||||
if isinstance(html, basestring):
|
||||
doc = fromstring(html)
|
||||
else:
|
||||
doc = copy.deepcopy(html)
|
||||
fill_form(doc, values, form_id=form_id, form_index=form_index)
|
||||
return _transform_result(result_type, doc)
|
||||
|
||||
def _fill_form(el, values):
|
||||
counts = {}
|
||||
if hasattr(values, 'mixed'):
|
||||
# For Paste request parameters
|
||||
values = values.mixed()
|
||||
inputs = _input_xpath(el)
|
||||
for input in inputs:
|
||||
name = input.get('name')
|
||||
if not name:
|
||||
continue
|
||||
if _takes_multiple(input):
|
||||
value = values.get(name, [])
|
||||
if not isinstance(value, (list, tuple)):
|
||||
value = [value]
|
||||
_fill_multiple(input, value)
|
||||
elif name not in values:
|
||||
continue
|
||||
else:
|
||||
index = counts.get(name, 0)
|
||||
counts[name] = index + 1
|
||||
value = values[name]
|
||||
if isinstance(value, (list, tuple)):
|
||||
try:
|
||||
value = value[index]
|
||||
except IndexError:
|
||||
continue
|
||||
elif index > 0:
|
||||
continue
|
||||
_fill_single(input, value)
|
||||
|
||||
def _takes_multiple(input):
|
||||
if _nons(input.tag) == 'select' and input.get('multiple'):
|
||||
# FIXME: multiple="0"?
|
||||
return True
|
||||
type = input.get('type', '').lower()
|
||||
if type in ('radio', 'checkbox'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _fill_multiple(input, value):
|
||||
type = input.get('type', '').lower()
|
||||
if type == 'checkbox':
|
||||
v = input.get('value')
|
||||
if v is None:
|
||||
if not value:
|
||||
result = False
|
||||
else:
|
||||
result = value[0]
|
||||
if isinstance(value, basestring):
|
||||
# The only valid "on" value for an unnamed checkbox is 'on'
|
||||
result = result == 'on'
|
||||
_check(input, result)
|
||||
else:
|
||||
_check(input, v in value)
|
||||
elif type == 'radio':
|
||||
v = input.get('value')
|
||||
_check(input, v in value)
|
||||
else:
|
||||
assert _nons(input.tag) == 'select'
|
||||
for option in _options_xpath(input):
|
||||
v = option.get('value')
|
||||
if v is None:
|
||||
# This seems to be the default, at least on IE
|
||||
# FIXME: but I'm not sure
|
||||
v = option.text_content()
|
||||
_select(option, v in value)
|
||||
|
||||
def _check(el, check):
|
||||
if check:
|
||||
el.set('checked', '')
|
||||
else:
|
||||
if 'checked' in el.attrib:
|
||||
del el.attrib['checked']
|
||||
|
||||
def _select(el, select):
|
||||
if select:
|
||||
el.set('selected', '')
|
||||
else:
|
||||
if 'selected' in el.attrib:
|
||||
del el.attrib['selected']
|
||||
|
||||
def _fill_single(input, value):
|
||||
if _nons(input.tag) == 'textarea':
|
||||
input.text = value
|
||||
else:
|
||||
input.set('value', value)
|
||||
|
||||
def _find_form(el, form_id=None, form_index=None):
|
||||
if form_id is None and form_index is None:
|
||||
forms = _forms_xpath(el)
|
||||
for form in forms:
|
||||
return form
|
||||
raise FormNotFound(
|
||||
"No forms in page")
|
||||
if form_id is not None:
|
||||
form = el.get_element_by_id(form_id)
|
||||
if form is not None:
|
||||
return form
|
||||
forms = _form_name_xpath(el, name=form_id)
|
||||
if forms:
|
||||
return forms[0]
|
||||
else:
|
||||
raise FormNotFound(
|
||||
"No form with the name or id of %r (forms: %s)"
|
||||
% (id, ', '.join(_find_form_ids(el))))
|
||||
if form_index is not None:
|
||||
forms = _forms_xpath(el)
|
||||
try:
|
||||
return forms[form_index]
|
||||
except IndexError:
|
||||
raise FormNotFound(
|
||||
"There is no form with the index %r (%i forms found)"
|
||||
% (form_index, len(forms)))
|
||||
|
||||
def _find_form_ids(el):
|
||||
forms = _forms_xpath(el)
|
||||
if not forms:
|
||||
yield '(no forms)'
|
||||
return
|
||||
for index, form in enumerate(forms):
|
||||
if form.get('id'):
|
||||
if form.get('name'):
|
||||
yield '%s or %s' % (form.get('id'),
|
||||
form.get('name'))
|
||||
else:
|
||||
yield form.get('id')
|
||||
elif form.get('name'):
|
||||
yield form.get('name')
|
||||
else:
|
||||
yield '(unnamed form %s)' % index
|
||||
|
||||
############################################################
|
||||
## Error filling
|
||||
############################################################
|
||||
|
||||
class DefaultErrorCreator(object):
|
||||
insert_before = True
|
||||
block_inside = True
|
||||
error_container_tag = 'div'
|
||||
error_message_class = 'error-message'
|
||||
error_block_class = 'error-block'
|
||||
default_message = "Invalid"
|
||||
|
||||
def __init__(self, **kw):
|
||||
for name, value in kw.items():
|
||||
if not hasattr(self, name):
|
||||
raise TypeError(
|
||||
"Unexpected keyword argument: %s" % name)
|
||||
setattr(self, name, value)
|
||||
|
||||
def __call__(self, el, is_block, message):
|
||||
error_el = el.makeelement(self.error_container_tag)
|
||||
if self.error_message_class:
|
||||
error_el.set('class', self.error_message_class)
|
||||
if is_block and self.error_block_class:
|
||||
error_el.set('class', error_el.get('class', '')+' '+self.error_block_class)
|
||||
if message is None or message == '':
|
||||
message = self.default_message
|
||||
if isinstance(message, ElementBase):
|
||||
error_el.append(message)
|
||||
else:
|
||||
assert isinstance(message, basestring), (
|
||||
"Bad message; should be a string or element: %r" % message)
|
||||
error_el.text = message or self.default_message
|
||||
if is_block and self.block_inside:
|
||||
if self.insert_before:
|
||||
error_el.tail = el.text
|
||||
el.text = None
|
||||
el.insert(0, error_el)
|
||||
else:
|
||||
el.append(error_el)
|
||||
else:
|
||||
parent = el.getparent()
|
||||
pos = parent.index(el)
|
||||
if self.insert_before:
|
||||
parent.insert(pos, error_el)
|
||||
else:
|
||||
error_el.tail = el.tail
|
||||
el.tail = None
|
||||
parent.insert(pos+1, error_el)
|
||||
|
||||
default_error_creator = DefaultErrorCreator()
|
||||
|
||||
|
||||
def insert_errors(
|
||||
el,
|
||||
errors,
|
||||
form_id=None,
|
||||
form_index=None,
|
||||
error_class="error",
|
||||
error_creator=default_error_creator,
|
||||
):
|
||||
el = _find_form(el, form_id=form_id, form_index=form_index)
|
||||
for name, error in errors.items():
|
||||
if error is None:
|
||||
continue
|
||||
for error_el, message in _find_elements_for_name(el, name, error):
|
||||
assert isinstance(message, (basestring, type(None), ElementBase)), (
|
||||
"Bad message: %r" % message)
|
||||
_insert_error(error_el, message, error_class, error_creator)
|
||||
|
||||
def insert_errors_html(html, values, **kw):
|
||||
result_type = type(html)
|
||||
if isinstance(html, basestring):
|
||||
doc = fromstring(html)
|
||||
else:
|
||||
doc = copy.deepcopy(html)
|
||||
insert_errors(doc, values, **kw)
|
||||
return _transform_result(result_type, doc)
|
||||
|
||||
def _insert_error(el, error, error_class, error_creator):
|
||||
if _nons(el.tag) in defs.empty_tags or _nons(el.tag) == 'textarea':
|
||||
is_block = False
|
||||
else:
|
||||
is_block = True
|
||||
if _nons(el.tag) != 'form' and error_class:
|
||||
_add_class(el, error_class)
|
||||
if el.get('id'):
|
||||
labels = _label_for_xpath(el, for_id=el.get('id'))
|
||||
if labels:
|
||||
for label in labels:
|
||||
_add_class(label, error_class)
|
||||
error_creator(el, is_block, error)
|
||||
|
||||
def _add_class(el, class_name):
|
||||
if el.get('class'):
|
||||
el.set('class', el.get('class')+' '+class_name)
|
||||
else:
|
||||
el.set('class', class_name)
|
||||
|
||||
def _find_elements_for_name(form, name, error):
|
||||
if name is None:
|
||||
# An error for the entire form
|
||||
yield form, error
|
||||
return
|
||||
if name.startswith('#'):
|
||||
# By id
|
||||
el = form.get_element_by_id(name[1:])
|
||||
if el is not None:
|
||||
yield el, error
|
||||
return
|
||||
els = _name_xpath(form, name=name)
|
||||
if not els:
|
||||
# FIXME: should this raise an exception?
|
||||
return
|
||||
if not isinstance(error, (list, tuple)):
|
||||
yield els[0], error
|
||||
return
|
||||
# FIXME: if error is longer than els, should it raise an error?
|
||||
for el, err in zip(els, error):
|
||||
if err is None:
|
||||
continue
|
||||
yield el, err
|
||||
260
acer-env/lib/python3.10/site-packages/lxml/html/html5parser.py
Normal file
260
acer-env/lib/python3.10/site-packages/lxml/html/html5parser.py
Normal file
@@ -0,0 +1,260 @@
|
||||
"""
|
||||
An interface to html5lib that mimics the lxml.html interface.
|
||||
"""
|
||||
import sys
|
||||
import string
|
||||
|
||||
from html5lib import HTMLParser as _HTMLParser
|
||||
from html5lib.treebuilders.etree_lxml import TreeBuilder
|
||||
from lxml import etree
|
||||
from lxml.html import Element, XHTML_NAMESPACE, _contains_block_level_tag
|
||||
|
||||
# python3 compatibility
|
||||
try:
|
||||
_strings = basestring
|
||||
except NameError:
|
||||
_strings = (bytes, str)
|
||||
try:
|
||||
from urllib2 import urlopen
|
||||
except ImportError:
|
||||
from urllib.request import urlopen
|
||||
try:
|
||||
from urlparse import urlparse
|
||||
except ImportError:
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
class HTMLParser(_HTMLParser):
|
||||
"""An html5lib HTML parser with lxml as tree."""
|
||||
|
||||
def __init__(self, strict=False, **kwargs):
|
||||
_HTMLParser.__init__(self, strict=strict, tree=TreeBuilder, **kwargs)
|
||||
|
||||
|
||||
try:
|
||||
from html5lib import XHTMLParser as _XHTMLParser
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
class XHTMLParser(_XHTMLParser):
|
||||
"""An html5lib XHTML Parser with lxml as tree."""
|
||||
|
||||
def __init__(self, strict=False, **kwargs):
|
||||
_XHTMLParser.__init__(self, strict=strict, tree=TreeBuilder, **kwargs)
|
||||
|
||||
xhtml_parser = XHTMLParser()
|
||||
|
||||
|
||||
def _find_tag(tree, tag):
|
||||
elem = tree.find(tag)
|
||||
if elem is not None:
|
||||
return elem
|
||||
return tree.find('{%s}%s' % (XHTML_NAMESPACE, tag))
|
||||
|
||||
|
||||
def document_fromstring(html, guess_charset=None, parser=None):
|
||||
"""
|
||||
Parse a whole document into a string.
|
||||
|
||||
If `guess_charset` is true, or if the input is not Unicode but a
|
||||
byte string, the `chardet` library will perform charset guessing
|
||||
on the string.
|
||||
"""
|
||||
if not isinstance(html, _strings):
|
||||
raise TypeError('string required')
|
||||
|
||||
if parser is None:
|
||||
parser = html_parser
|
||||
|
||||
options = {}
|
||||
if guess_charset is None and isinstance(html, bytes):
|
||||
# html5lib does not accept useChardet as an argument, if it
|
||||
# detected the html argument would produce unicode objects.
|
||||
guess_charset = True
|
||||
if guess_charset is not None:
|
||||
options['useChardet'] = guess_charset
|
||||
return parser.parse(html, **options).getroot()
|
||||
|
||||
|
||||
def fragments_fromstring(html, no_leading_text=False,
|
||||
guess_charset=None, parser=None):
|
||||
"""Parses several HTML elements, returning a list of elements.
|
||||
|
||||
The first item in the list may be a string. If no_leading_text is true,
|
||||
then it will be an error if there is leading text, and it will always be
|
||||
a list of only elements.
|
||||
|
||||
If `guess_charset` is true, the `chardet` library will perform charset
|
||||
guessing on the string.
|
||||
"""
|
||||
if not isinstance(html, _strings):
|
||||
raise TypeError('string required')
|
||||
|
||||
if parser is None:
|
||||
parser = html_parser
|
||||
|
||||
options = {}
|
||||
if guess_charset is None and isinstance(html, bytes):
|
||||
# html5lib does not accept useChardet as an argument, if it
|
||||
# detected the html argument would produce unicode objects.
|
||||
guess_charset = False
|
||||
if guess_charset is not None:
|
||||
options['useChardet'] = guess_charset
|
||||
children = parser.parseFragment(html, 'div', **options)
|
||||
if children and isinstance(children[0], _strings):
|
||||
if no_leading_text:
|
||||
if children[0].strip():
|
||||
raise etree.ParserError('There is leading text: %r' %
|
||||
children[0])
|
||||
del children[0]
|
||||
return children
|
||||
|
||||
|
||||
def fragment_fromstring(html, create_parent=False,
|
||||
guess_charset=None, parser=None):
|
||||
"""Parses a single HTML element; it is an error if there is more than
|
||||
one element, or if anything but whitespace precedes or follows the
|
||||
element.
|
||||
|
||||
If 'create_parent' is true (or is a tag name) then a parent node
|
||||
will be created to encapsulate the HTML in a single element. In
|
||||
this case, leading or trailing text is allowed.
|
||||
|
||||
If `guess_charset` is true, the `chardet` library will perform charset
|
||||
guessing on the string.
|
||||
"""
|
||||
if not isinstance(html, _strings):
|
||||
raise TypeError('string required')
|
||||
|
||||
accept_leading_text = bool(create_parent)
|
||||
|
||||
elements = fragments_fromstring(
|
||||
html, guess_charset=guess_charset, parser=parser,
|
||||
no_leading_text=not accept_leading_text)
|
||||
|
||||
if create_parent:
|
||||
if not isinstance(create_parent, _strings):
|
||||
create_parent = 'div'
|
||||
new_root = Element(create_parent)
|
||||
if elements:
|
||||
if isinstance(elements[0], _strings):
|
||||
new_root.text = elements[0]
|
||||
del elements[0]
|
||||
new_root.extend(elements)
|
||||
return new_root
|
||||
|
||||
if not elements:
|
||||
raise etree.ParserError('No elements found')
|
||||
if len(elements) > 1:
|
||||
raise etree.ParserError('Multiple elements found')
|
||||
result = elements[0]
|
||||
if result.tail and result.tail.strip():
|
||||
raise etree.ParserError('Element followed by text: %r' % result.tail)
|
||||
result.tail = None
|
||||
return result
|
||||
|
||||
|
||||
def fromstring(html, guess_charset=None, parser=None):
|
||||
"""Parse the html, returning a single element/document.
|
||||
|
||||
This tries to minimally parse the chunk of text, without knowing if it
|
||||
is a fragment or a document.
|
||||
|
||||
'base_url' will set the document's base_url attribute (and the tree's
|
||||
docinfo.URL)
|
||||
|
||||
If `guess_charset` is true, or if the input is not Unicode but a
|
||||
byte string, the `chardet` library will perform charset guessing
|
||||
on the string.
|
||||
"""
|
||||
if not isinstance(html, _strings):
|
||||
raise TypeError('string required')
|
||||
doc = document_fromstring(html, parser=parser,
|
||||
guess_charset=guess_charset)
|
||||
|
||||
# document starts with doctype or <html>, full document!
|
||||
start = html[:50]
|
||||
if isinstance(start, bytes):
|
||||
# Allow text comparison in python3.
|
||||
# Decode as ascii, that also covers latin-1 and utf-8 for the
|
||||
# characters we need.
|
||||
start = start.decode('ascii', 'replace')
|
||||
|
||||
start = start.lstrip().lower()
|
||||
if start.startswith('<html') or start.startswith('<!doctype'):
|
||||
return doc
|
||||
|
||||
head = _find_tag(doc, 'head')
|
||||
|
||||
# if the head is not empty we have a full document
|
||||
if len(head):
|
||||
return doc
|
||||
|
||||
body = _find_tag(doc, 'body')
|
||||
|
||||
# The body has just one element, so it was probably a single
|
||||
# element passed in
|
||||
if (len(body) == 1 and (not body.text or not body.text.strip())
|
||||
and (not body[-1].tail or not body[-1].tail.strip())):
|
||||
return body[0]
|
||||
|
||||
# Now we have a body which represents a bunch of tags which have the
|
||||
# content that was passed in. We will create a fake container, which
|
||||
# is the body tag, except <body> implies too much structure.
|
||||
if _contains_block_level_tag(body):
|
||||
body.tag = 'div'
|
||||
else:
|
||||
body.tag = 'span'
|
||||
return body
|
||||
|
||||
|
||||
def parse(filename_url_or_file, guess_charset=None, parser=None):
|
||||
"""Parse a filename, URL, or file-like object into an HTML document
|
||||
tree. Note: this returns a tree, not an element. Use
|
||||
``parse(...).getroot()`` to get the document root.
|
||||
|
||||
If ``guess_charset`` is true, the ``useChardet`` option is passed into
|
||||
html5lib to enable character detection. This option is on by default
|
||||
when parsing from URLs, off by default when parsing from file(-like)
|
||||
objects (which tend to return Unicode more often than not), and on by
|
||||
default when parsing from a file path (which is read in binary mode).
|
||||
"""
|
||||
if parser is None:
|
||||
parser = html_parser
|
||||
if not isinstance(filename_url_or_file, _strings):
|
||||
fp = filename_url_or_file
|
||||
if guess_charset is None:
|
||||
# assume that file-like objects return Unicode more often than bytes
|
||||
guess_charset = False
|
||||
elif _looks_like_url(filename_url_or_file):
|
||||
fp = urlopen(filename_url_or_file)
|
||||
if guess_charset is None:
|
||||
# assume that URLs return bytes
|
||||
guess_charset = True
|
||||
else:
|
||||
fp = open(filename_url_or_file, 'rb')
|
||||
if guess_charset is None:
|
||||
guess_charset = True
|
||||
|
||||
options = {}
|
||||
# html5lib does not accept useChardet as an argument, if it
|
||||
# detected the html argument would produce unicode objects.
|
||||
if guess_charset:
|
||||
options['useChardet'] = guess_charset
|
||||
return parser.parse(fp, **options)
|
||||
|
||||
|
||||
def _looks_like_url(str):
|
||||
scheme = urlparse(str)[0]
|
||||
if not scheme:
|
||||
return False
|
||||
elif (sys.platform == 'win32' and
|
||||
scheme in string.ascii_letters
|
||||
and len(scheme) == 1):
|
||||
# looks like a 'normal' absolute path
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
html_parser = HTMLParser()
|
||||
314
acer-env/lib/python3.10/site-packages/lxml/html/soupparser.py
Normal file
314
acer-env/lib/python3.10/site-packages/lxml/html/soupparser.py
Normal file
@@ -0,0 +1,314 @@
|
||||
"""External interface to the BeautifulSoup HTML parser.
|
||||
"""
|
||||
|
||||
__all__ = ["fromstring", "parse", "convert_tree"]
|
||||
|
||||
import re
|
||||
from lxml import etree, html
|
||||
|
||||
try:
|
||||
from bs4 import (
|
||||
BeautifulSoup, Tag, Comment, ProcessingInstruction, NavigableString,
|
||||
Declaration, Doctype)
|
||||
_DECLARATION_OR_DOCTYPE = (Declaration, Doctype)
|
||||
except ImportError:
|
||||
from BeautifulSoup import (
|
||||
BeautifulSoup, Tag, Comment, ProcessingInstruction, NavigableString,
|
||||
Declaration)
|
||||
_DECLARATION_OR_DOCTYPE = Declaration
|
||||
|
||||
|
||||
def fromstring(data, beautifulsoup=None, makeelement=None, **bsargs):
|
||||
"""Parse a string of HTML data into an Element tree using the
|
||||
BeautifulSoup parser.
|
||||
|
||||
Returns the root ``<html>`` Element of the tree.
|
||||
|
||||
You can pass a different BeautifulSoup parser through the
|
||||
`beautifulsoup` keyword, and a diffent Element factory function
|
||||
through the `makeelement` keyword. By default, the standard
|
||||
``BeautifulSoup`` class and the default factory of `lxml.html` are
|
||||
used.
|
||||
"""
|
||||
return _parse(data, beautifulsoup, makeelement, **bsargs)
|
||||
|
||||
|
||||
def parse(file, beautifulsoup=None, makeelement=None, **bsargs):
|
||||
"""Parse a file into an ElemenTree using the BeautifulSoup parser.
|
||||
|
||||
You can pass a different BeautifulSoup parser through the
|
||||
`beautifulsoup` keyword, and a diffent Element factory function
|
||||
through the `makeelement` keyword. By default, the standard
|
||||
``BeautifulSoup`` class and the default factory of `lxml.html` are
|
||||
used.
|
||||
"""
|
||||
if not hasattr(file, 'read'):
|
||||
file = open(file)
|
||||
root = _parse(file, beautifulsoup, makeelement, **bsargs)
|
||||
return etree.ElementTree(root)
|
||||
|
||||
|
||||
def convert_tree(beautiful_soup_tree, makeelement=None):
|
||||
"""Convert a BeautifulSoup tree to a list of Element trees.
|
||||
|
||||
Returns a list instead of a single root Element to support
|
||||
HTML-like soup with more than one root element.
|
||||
|
||||
You can pass a different Element factory through the `makeelement`
|
||||
keyword.
|
||||
"""
|
||||
root = _convert_tree(beautiful_soup_tree, makeelement)
|
||||
children = root.getchildren()
|
||||
for child in children:
|
||||
root.remove(child)
|
||||
return children
|
||||
|
||||
|
||||
# helpers
|
||||
|
||||
def _parse(source, beautifulsoup, makeelement, **bsargs):
|
||||
if beautifulsoup is None:
|
||||
beautifulsoup = BeautifulSoup
|
||||
if hasattr(beautifulsoup, "HTML_ENTITIES"): # bs3
|
||||
if 'convertEntities' not in bsargs:
|
||||
bsargs['convertEntities'] = 'html'
|
||||
if hasattr(beautifulsoup, "DEFAULT_BUILDER_FEATURES"): # bs4
|
||||
if 'features' not in bsargs:
|
||||
bsargs['features'] = 'html.parser' # use Python html parser
|
||||
tree = beautifulsoup(source, **bsargs)
|
||||
root = _convert_tree(tree, makeelement)
|
||||
# from ET: wrap the document in a html root element, if necessary
|
||||
if len(root) == 1 and root[0].tag == "html":
|
||||
return root[0]
|
||||
root.tag = "html"
|
||||
return root
|
||||
|
||||
|
||||
_parse_doctype_declaration = re.compile(
|
||||
r'(?:\s|[<!])*DOCTYPE\s*HTML'
|
||||
r'(?:\s+PUBLIC)?(?:\s+(\'[^\']*\'|"[^"]*"))?'
|
||||
r'(?:\s+(\'[^\']*\'|"[^"]*"))?',
|
||||
re.IGNORECASE).match
|
||||
|
||||
|
||||
class _PseudoTag:
|
||||
# Minimal imitation of BeautifulSoup.Tag
|
||||
def __init__(self, contents):
|
||||
self.name = 'html'
|
||||
self.attrs = []
|
||||
self.contents = contents
|
||||
|
||||
def __iter__(self):
|
||||
return self.contents.__iter__()
|
||||
|
||||
|
||||
def _convert_tree(beautiful_soup_tree, makeelement):
|
||||
if makeelement is None:
|
||||
makeelement = html.html_parser.makeelement
|
||||
|
||||
# Split the tree into three parts:
|
||||
# i) everything before the root element: document type
|
||||
# declaration, comments, processing instructions, whitespace
|
||||
# ii) the root(s),
|
||||
# iii) everything after the root: comments, processing
|
||||
# instructions, whitespace
|
||||
first_element_idx = last_element_idx = None
|
||||
html_root = declaration = None
|
||||
for i, e in enumerate(beautiful_soup_tree):
|
||||
if isinstance(e, Tag):
|
||||
if first_element_idx is None:
|
||||
first_element_idx = i
|
||||
last_element_idx = i
|
||||
if html_root is None and e.name and e.name.lower() == 'html':
|
||||
html_root = e
|
||||
elif declaration is None and isinstance(e, _DECLARATION_OR_DOCTYPE):
|
||||
declaration = e
|
||||
|
||||
# For a nice, well-formatted document, the variable roots below is
|
||||
# a list consisting of a single <html> element. However, the document
|
||||
# may be a soup like '<meta><head><title>Hello</head><body>Hi
|
||||
# all<\p>'. In this example roots is a list containing meta, head
|
||||
# and body elements.
|
||||
if first_element_idx is None:
|
||||
pre_root = post_root = []
|
||||
roots = beautiful_soup_tree.contents
|
||||
else:
|
||||
pre_root = beautiful_soup_tree.contents[:first_element_idx]
|
||||
roots = beautiful_soup_tree.contents[first_element_idx:last_element_idx+1]
|
||||
post_root = beautiful_soup_tree.contents[last_element_idx+1:]
|
||||
|
||||
# Reorganize so that there is one <html> root...
|
||||
if html_root is not None:
|
||||
# ... use existing one if possible, ...
|
||||
i = roots.index(html_root)
|
||||
html_root.contents = roots[:i] + html_root.contents + roots[i+1:]
|
||||
else:
|
||||
# ... otherwise create a new one.
|
||||
html_root = _PseudoTag(roots)
|
||||
|
||||
convert_node = _init_node_converters(makeelement)
|
||||
|
||||
# Process pre_root
|
||||
res_root = convert_node(html_root)
|
||||
prev = res_root
|
||||
for e in reversed(pre_root):
|
||||
converted = convert_node(e)
|
||||
if converted is not None:
|
||||
prev.addprevious(converted)
|
||||
prev = converted
|
||||
|
||||
# ditto for post_root
|
||||
prev = res_root
|
||||
for e in post_root:
|
||||
converted = convert_node(e)
|
||||
if converted is not None:
|
||||
prev.addnext(converted)
|
||||
prev = converted
|
||||
|
||||
if declaration is not None:
|
||||
try:
|
||||
# bs4 provides full Doctype string
|
||||
doctype_string = declaration.output_ready()
|
||||
except AttributeError:
|
||||
doctype_string = declaration.string
|
||||
|
||||
match = _parse_doctype_declaration(doctype_string)
|
||||
if not match:
|
||||
# Something is wrong if we end up in here. Since soupparser should
|
||||
# tolerate errors, do not raise Exception, just let it pass.
|
||||
pass
|
||||
else:
|
||||
external_id, sys_uri = match.groups()
|
||||
docinfo = res_root.getroottree().docinfo
|
||||
# strip quotes and update DOCTYPE values (any of None, '', '...')
|
||||
docinfo.public_id = external_id and external_id[1:-1]
|
||||
docinfo.system_url = sys_uri and sys_uri[1:-1]
|
||||
|
||||
return res_root
|
||||
|
||||
|
||||
def _init_node_converters(makeelement):
|
||||
converters = {}
|
||||
ordered_node_types = []
|
||||
|
||||
def converter(*types):
|
||||
def add(handler):
|
||||
for t in types:
|
||||
converters[t] = handler
|
||||
ordered_node_types.append(t)
|
||||
return handler
|
||||
return add
|
||||
|
||||
def find_best_converter(node):
|
||||
for t in ordered_node_types:
|
||||
if isinstance(node, t):
|
||||
return converters[t]
|
||||
return None
|
||||
|
||||
def convert_node(bs_node, parent=None):
|
||||
# duplicated in convert_tag() below
|
||||
try:
|
||||
handler = converters[type(bs_node)]
|
||||
except KeyError:
|
||||
handler = converters[type(bs_node)] = find_best_converter(bs_node)
|
||||
if handler is None:
|
||||
return None
|
||||
return handler(bs_node, parent)
|
||||
|
||||
def map_attrs(bs_attrs):
|
||||
if isinstance(bs_attrs, dict): # bs4
|
||||
attribs = {}
|
||||
for k, v in bs_attrs.items():
|
||||
if isinstance(v, list):
|
||||
v = " ".join(v)
|
||||
attribs[k] = unescape(v)
|
||||
else:
|
||||
attribs = dict((k, unescape(v)) for k, v in bs_attrs)
|
||||
return attribs
|
||||
|
||||
def append_text(parent, text):
|
||||
if len(parent) == 0:
|
||||
parent.text = (parent.text or '') + text
|
||||
else:
|
||||
parent[-1].tail = (parent[-1].tail or '') + text
|
||||
|
||||
# converters are tried in order of their definition
|
||||
|
||||
@converter(Tag, _PseudoTag)
|
||||
def convert_tag(bs_node, parent):
|
||||
attrs = bs_node.attrs
|
||||
if parent is not None:
|
||||
attribs = map_attrs(attrs) if attrs else None
|
||||
res = etree.SubElement(parent, bs_node.name, attrib=attribs)
|
||||
else:
|
||||
attribs = map_attrs(attrs) if attrs else {}
|
||||
res = makeelement(bs_node.name, attrib=attribs)
|
||||
|
||||
for child in bs_node:
|
||||
# avoid double recursion by inlining convert_node(), see above
|
||||
try:
|
||||
handler = converters[type(child)]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if handler is not None:
|
||||
handler(child, res)
|
||||
continue
|
||||
convert_node(child, res)
|
||||
return res
|
||||
|
||||
@converter(Comment)
|
||||
def convert_comment(bs_node, parent):
|
||||
res = html.HtmlComment(bs_node)
|
||||
if parent is not None:
|
||||
parent.append(res)
|
||||
return res
|
||||
|
||||
@converter(ProcessingInstruction)
|
||||
def convert_pi(bs_node, parent):
|
||||
if bs_node.endswith('?'):
|
||||
# The PI is of XML style (<?as df?>) but BeautifulSoup
|
||||
# interpreted it as being SGML style (<?as df>). Fix.
|
||||
bs_node = bs_node[:-1]
|
||||
res = etree.ProcessingInstruction(*bs_node.split(' ', 1))
|
||||
if parent is not None:
|
||||
parent.append(res)
|
||||
return res
|
||||
|
||||
@converter(NavigableString)
|
||||
def convert_text(bs_node, parent):
|
||||
if parent is not None:
|
||||
append_text(parent, unescape(bs_node))
|
||||
return None
|
||||
|
||||
return convert_node
|
||||
|
||||
|
||||
# copied from ET's ElementSoup
|
||||
|
||||
try:
|
||||
from html.entities import name2codepoint # Python 3
|
||||
except ImportError:
|
||||
from htmlentitydefs import name2codepoint
|
||||
|
||||
|
||||
handle_entities = re.compile(r"&(\w+);").sub
|
||||
|
||||
|
||||
try:
|
||||
unichr
|
||||
except NameError:
|
||||
# Python 3
|
||||
unichr = chr
|
||||
|
||||
|
||||
def unescape(string):
|
||||
if not string:
|
||||
return ''
|
||||
# work around oddities in BeautifulSoup's entity handling
|
||||
def unescape_entity(m):
|
||||
try:
|
||||
return unichr(name2codepoint[m.group(1)])
|
||||
except KeyError:
|
||||
return m.group(0) # use as is
|
||||
return handle_entities(unescape_entity, string)
|
||||
@@ -0,0 +1,13 @@
|
||||
"""Doctest module for HTML comparison.
|
||||
|
||||
Usage::
|
||||
|
||||
>>> import lxml.html.usedoctest
|
||||
>>> # now do your HTML doctests ...
|
||||
|
||||
See `lxml.doctestcompare`.
|
||||
"""
|
||||
|
||||
from lxml import doctestcompare
|
||||
|
||||
doctestcompare.temp_install(html=True, del_module=__name__)
|
||||
Binary file not shown.
26
acer-env/lib/python3.10/site-packages/lxml/includes/c14n.pxd
Normal file
26
acer-env/lib/python3.10/site-packages/lxml/includes/c14n.pxd
Normal file
@@ -0,0 +1,26 @@
|
||||
from lxml.includes.tree cimport xmlDoc, xmlOutputBuffer, xmlChar
|
||||
from lxml.includes.xpath cimport xmlNodeSet
|
||||
|
||||
cdef extern from "libxml/c14n.h":
|
||||
cdef int xmlC14NDocDumpMemory(xmlDoc* doc,
|
||||
xmlNodeSet* nodes,
|
||||
int exclusive,
|
||||
xmlChar** inclusive_ns_prefixes,
|
||||
int with_comments,
|
||||
xmlChar** doc_txt_ptr) nogil
|
||||
|
||||
cdef int xmlC14NDocSave(xmlDoc* doc,
|
||||
xmlNodeSet* nodes,
|
||||
int exclusive,
|
||||
xmlChar** inclusive_ns_prefixes,
|
||||
int with_comments,
|
||||
char* filename,
|
||||
int compression) nogil
|
||||
|
||||
cdef int xmlC14NDocSaveTo(xmlDoc* doc,
|
||||
xmlNodeSet* nodes,
|
||||
int exclusive,
|
||||
xmlChar** inclusive_ns_prefixes,
|
||||
int with_comments,
|
||||
xmlOutputBuffer* buffer) nogil
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
cdef extern from "etree_defs.h":
|
||||
cdef bint ENABLE_THREADING
|
||||
cdef bint ENABLE_SCHEMATRON
|
||||
@@ -0,0 +1,18 @@
|
||||
from lxml.includes cimport tree
|
||||
from lxml.includes.tree cimport xmlDoc, xmlDtd
|
||||
|
||||
cdef extern from "libxml/valid.h" nogil:
|
||||
ctypedef void (*xmlValidityErrorFunc)(void * ctx, const char * msg, ...)
|
||||
ctypedef void (*xmlValidityWarningFunc)(void * ctx, const char * msg, ...)
|
||||
|
||||
ctypedef struct xmlValidCtxt:
|
||||
void *userData
|
||||
xmlValidityErrorFunc error
|
||||
xmlValidityWarningFunc warning
|
||||
|
||||
cdef xmlValidCtxt* xmlNewValidCtxt()
|
||||
cdef void xmlFreeValidCtxt(xmlValidCtxt* cur)
|
||||
|
||||
cdef int xmlValidateDtd(xmlValidCtxt* ctxt, xmlDoc* doc, xmlDtd* dtd)
|
||||
cdef tree.xmlElement* xmlGetDtdElementDesc(
|
||||
xmlDtd* dtd, tree.const_xmlChar* name)
|
||||
417
acer-env/lib/python3.10/site-packages/lxml/includes/etree_defs.h
Normal file
417
acer-env/lib/python3.10/site-packages/lxml/includes/etree_defs.h
Normal file
@@ -0,0 +1,417 @@
|
||||
#ifndef HAS_ETREE_DEFS_H
|
||||
#define HAS_ETREE_DEFS_H
|
||||
|
||||
/* quick check for Python/libxml2/libxslt devel setup */
|
||||
#include "Python.h"
|
||||
#ifndef PY_VERSION_HEX
|
||||
# error the development package of Python (header files etc.) is not installed correctly
|
||||
#else
|
||||
# if PY_VERSION_HEX < 0x02070000 || PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x03050000
|
||||
# error this version of lxml requires Python 2.7, 3.5 or later
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "libxml/xmlversion.h"
|
||||
#ifndef LIBXML_VERSION
|
||||
# error the development package of libxml2 (header files etc.) is not installed correctly
|
||||
#else
|
||||
#if LIBXML_VERSION < 20700
|
||||
# error minimum required version of libxml2 is 2.7.0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "libxslt/xsltconfig.h"
|
||||
#ifndef LIBXSLT_VERSION
|
||||
# error the development package of libxslt (header files etc.) is not installed correctly
|
||||
#else
|
||||
#if LIBXSLT_VERSION < 10123
|
||||
# error minimum required version of libxslt is 1.1.23
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* v_arg functions */
|
||||
#define va_int(ap) va_arg(ap, int)
|
||||
#define va_charptr(ap) va_arg(ap, char *)
|
||||
|
||||
#ifdef PYPY_VERSION
|
||||
# define IS_PYPY 1
|
||||
#else
|
||||
# define IS_PYPY 0
|
||||
#endif
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
# define IS_PYTHON2 0 /* prefer for special casing Python 2.x */
|
||||
# define IS_PYTHON3 1 /* avoid */
|
||||
#else
|
||||
# define IS_PYTHON2 1
|
||||
# define IS_PYTHON3 0
|
||||
#endif
|
||||
|
||||
#if IS_PYTHON2
|
||||
#ifndef LXML_UNICODE_STRINGS
|
||||
#define LXML_UNICODE_STRINGS 0
|
||||
#endif
|
||||
#else
|
||||
#undef LXML_UNICODE_STRINGS
|
||||
#define LXML_UNICODE_STRINGS 1
|
||||
#endif
|
||||
|
||||
#if !IS_PYPY
|
||||
# define PyWeakref_LockObject(obj) (NULL)
|
||||
#endif
|
||||
|
||||
/* Threading is not currently supported by PyPy */
|
||||
#if IS_PYPY
|
||||
# ifndef WITHOUT_THREADING
|
||||
# define WITHOUT_THREADING
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if IS_PYPY
|
||||
# undef PyFile_AsFile
|
||||
# define PyFile_AsFile(o) (NULL)
|
||||
# undef PyByteArray_Check
|
||||
# define PyByteArray_Check(o) (0)
|
||||
#elif !IS_PYTHON2
|
||||
/* Python 3+ doesn't have PyFile_*() anymore */
|
||||
# define PyFile_AsFile(o) (NULL)
|
||||
#endif
|
||||
|
||||
#if IS_PYPY
|
||||
# ifndef PyUnicode_FromFormat
|
||||
# define PyUnicode_FromFormat PyString_FromFormat
|
||||
# endif
|
||||
# if !IS_PYTHON2 && !defined(PyBytes_FromFormat)
|
||||
# ifdef PyString_FromFormat
|
||||
# define PyBytes_FromFormat PyString_FromFormat
|
||||
# else
|
||||
#include <stdarg.h>
|
||||
static PyObject* PyBytes_FromFormat(const char* format, ...) {
|
||||
PyObject *string;
|
||||
va_list vargs;
|
||||
#ifdef HAVE_STDARG_PROTOTYPES
|
||||
va_start(vargs, format);
|
||||
#else
|
||||
va_start(vargs);
|
||||
#endif
|
||||
string = PyUnicode_FromFormatV(format, vargs);
|
||||
va_end(vargs);
|
||||
if (string && PyUnicode_Check(string)) {
|
||||
PyObject *bstring = PyUnicode_AsUTF8String(string);
|
||||
Py_DECREF(string);
|
||||
string = bstring;
|
||||
}
|
||||
if (string && !PyBytes_CheckExact(string)) {
|
||||
Py_DECREF(string);
|
||||
string = NULL;
|
||||
PyErr_SetString(PyExc_TypeError, "String formatting and encoding failed to return bytes object");
|
||||
}
|
||||
return string;
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* PySlice_GetIndicesEx() has wrong signature in Py<=3.1 */
|
||||
#if PY_VERSION_HEX >= 0x03020000
|
||||
# define _lx_PySlice_GetIndicesEx(o, l, b, e, s, sl) PySlice_GetIndicesEx(o, l, b, e, s, sl)
|
||||
#else
|
||||
# define _lx_PySlice_GetIndicesEx(o, l, b, e, s, sl) PySlice_GetIndicesEx(((PySliceObject*)o), l, b, e, s, sl)
|
||||
#endif
|
||||
|
||||
#ifdef WITHOUT_THREADING
|
||||
# undef PyEval_SaveThread
|
||||
# define PyEval_SaveThread() (NULL)
|
||||
# undef PyEval_RestoreThread
|
||||
# define PyEval_RestoreThread(state) if (state); else {}
|
||||
# undef PyGILState_Ensure
|
||||
# define PyGILState_Ensure() (PyGILState_UNLOCKED)
|
||||
# undef PyGILState_Release
|
||||
# define PyGILState_Release(state) if (state); else {}
|
||||
# undef Py_UNBLOCK_THREADS
|
||||
# define Py_UNBLOCK_THREADS _save = NULL;
|
||||
# undef Py_BLOCK_THREADS
|
||||
# define Py_BLOCK_THREADS if (_save); else {}
|
||||
#endif
|
||||
|
||||
#ifdef WITHOUT_THREADING
|
||||
# define ENABLE_THREADING 0
|
||||
#else
|
||||
# define ENABLE_THREADING 1
|
||||
#endif
|
||||
|
||||
#if LIBXML_VERSION < 20704
|
||||
/* FIXME: hack to make new error reporting compile in old libxml2 versions */
|
||||
# define xmlStructuredErrorContext NULL
|
||||
# define xmlXIncludeProcessTreeFlagsData(n,o,d) xmlXIncludeProcessTreeFlags(n,o)
|
||||
#endif
|
||||
|
||||
/* schematron was added in libxml2 2.6.21 */
|
||||
#ifdef LIBXML_SCHEMATRON_ENABLED
|
||||
# define ENABLE_SCHEMATRON 1
|
||||
#else
|
||||
# define ENABLE_SCHEMATRON 0
|
||||
# define XML_SCHEMATRON_OUT_QUIET 0
|
||||
# define XML_SCHEMATRON_OUT_XML 0
|
||||
# define XML_SCHEMATRON_OUT_ERROR 0
|
||||
typedef void xmlSchematron;
|
||||
typedef void xmlSchematronParserCtxt;
|
||||
typedef void xmlSchematronValidCtxt;
|
||||
# define xmlSchematronNewDocParserCtxt(doc) NULL
|
||||
# define xmlSchematronNewParserCtxt(file) NULL
|
||||
# define xmlSchematronParse(ctxt) NULL
|
||||
# define xmlSchematronFreeParserCtxt(ctxt)
|
||||
# define xmlSchematronFree(schema)
|
||||
# define xmlSchematronNewValidCtxt(schema, options) NULL
|
||||
# define xmlSchematronValidateDoc(ctxt, doc) 0
|
||||
# define xmlSchematronFreeValidCtxt(ctxt)
|
||||
# define xmlSchematronSetValidStructuredErrors(ctxt, errorfunc, data)
|
||||
#endif
|
||||
|
||||
#if LIBXML_VERSION < 20708
|
||||
# define HTML_PARSE_NODEFDTD 4
|
||||
#endif
|
||||
#if LIBXML_VERSION < 20900
|
||||
# define XML_PARSE_BIG_LINES 4194304
|
||||
#endif
|
||||
|
||||
#include "libxml/tree.h"
|
||||
#ifndef LIBXML2_NEW_BUFFER
|
||||
typedef xmlBuffer xmlBuf;
|
||||
# define xmlBufContent(buf) xmlBufferContent(buf)
|
||||
# define xmlBufUse(buf) xmlBufferLength(buf)
|
||||
#endif
|
||||
|
||||
/* libexslt 1.1.25+ support EXSLT functions in XPath */
|
||||
#if LIBXSLT_VERSION < 10125
|
||||
#define exsltDateXpathCtxtRegister(ctxt, prefix)
|
||||
#define exsltSetsXpathCtxtRegister(ctxt, prefix)
|
||||
#define exsltMathXpathCtxtRegister(ctxt, prefix)
|
||||
#define exsltStrXpathCtxtRegister(ctxt, prefix)
|
||||
#endif
|
||||
|
||||
#define LXML_GET_XSLT_ENCODING(result_var, style) XSLT_GET_IMPORT_PTR(result_var, style, encoding)
|
||||
|
||||
/* work around MSDEV 6.0 */
|
||||
#if (_MSC_VER == 1200) && (WINVER < 0x0500)
|
||||
long _ftol( double ); //defined by VC6 C libs
|
||||
long _ftol2( double dblSource ) { return _ftol( dblSource ); }
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* Test for GCC > 2.95 */
|
||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
|
||||
#define unlikely_condition(x) __builtin_expect((x), 0)
|
||||
#else /* __GNUC__ > 2 ... */
|
||||
#define unlikely_condition(x) (x)
|
||||
#endif /* __GNUC__ > 2 ... */
|
||||
#else /* __GNUC__ */
|
||||
#define unlikely_condition(x) (x)
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifndef Py_TYPE
|
||||
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||
#endif
|
||||
|
||||
#define PY_NEW(T) \
|
||||
(((PyTypeObject*)(T))->tp_new( \
|
||||
(PyTypeObject*)(T), __pyx_empty_tuple, NULL))
|
||||
|
||||
#define _fqtypename(o) ((Py_TYPE(o))->tp_name)
|
||||
|
||||
#define lxml_malloc(count, item_size) \
|
||||
(unlikely_condition((size_t)(count) > (size_t) (PY_SSIZE_T_MAX / item_size)) ? NULL : \
|
||||
(PyMem_Malloc((count) * item_size)))
|
||||
|
||||
#define lxml_realloc(mem, count, item_size) \
|
||||
(unlikely_condition((size_t)(count) > (size_t) (PY_SSIZE_T_MAX / item_size)) ? NULL : \
|
||||
(PyMem_Realloc(mem, (count) * item_size)))
|
||||
|
||||
#define lxml_free(mem) PyMem_Free(mem)
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
#define _isString(obj) (PyString_CheckExact(obj) || \
|
||||
PyUnicode_CheckExact(obj) || \
|
||||
PyType_IsSubtype(Py_TYPE(obj), &PyBaseString_Type))
|
||||
#else
|
||||
/* builtin subtype type checks are almost as fast as exact checks in Py2.7+
|
||||
* and Unicode is more common in Py3 */
|
||||
#define _isString(obj) (PyUnicode_Check(obj) || PyBytes_Check(obj))
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX >= 0x03060000
|
||||
#define lxml_PyOS_FSPath(obj) (PyOS_FSPath(obj))
|
||||
#else
|
||||
#define lxml_PyOS_FSPath(obj) (NULL)
|
||||
#endif
|
||||
|
||||
#define _isElement(c_node) \
|
||||
(((c_node)->type == XML_ELEMENT_NODE) || \
|
||||
((c_node)->type == XML_COMMENT_NODE) || \
|
||||
((c_node)->type == XML_ENTITY_REF_NODE) || \
|
||||
((c_node)->type == XML_PI_NODE))
|
||||
|
||||
#define _isElementOrXInclude(c_node) \
|
||||
(_isElement(c_node) || \
|
||||
((c_node)->type == XML_XINCLUDE_START) || \
|
||||
((c_node)->type == XML_XINCLUDE_END))
|
||||
|
||||
#define _getNs(c_node) \
|
||||
(((c_node)->ns == 0) ? 0 : ((c_node)->ns->href))
|
||||
|
||||
|
||||
#include "string.h"
|
||||
static void* lxml_unpack_xmldoc_capsule(PyObject* capsule, int* is_owned) {
|
||||
xmlDoc *c_doc;
|
||||
void *context;
|
||||
*is_owned = 0;
|
||||
if (unlikely_condition(!PyCapsule_IsValid(capsule, (const char*)"libxml2:xmlDoc"))) {
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError,
|
||||
"Not a valid capsule. The capsule argument must be a capsule object with name libxml2:xmlDoc");
|
||||
return NULL;
|
||||
}
|
||||
c_doc = (xmlDoc*) PyCapsule_GetPointer(capsule, (const char*)"libxml2:xmlDoc");
|
||||
if (unlikely_condition(!c_doc)) return NULL;
|
||||
|
||||
if (unlikely_condition(c_doc->type != XML_DOCUMENT_NODE && c_doc->type != XML_HTML_DOCUMENT_NODE)) {
|
||||
PyErr_Format(
|
||||
PyExc_ValueError,
|
||||
"Illegal document provided: expected XML or HTML, found %d", (int)c_doc->type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context = PyCapsule_GetContext(capsule);
|
||||
if (unlikely_condition(!context && PyErr_Occurred())) return NULL;
|
||||
if (context && strcmp((const char*) context, "destructor:xmlFreeDoc") == 0) {
|
||||
/* take ownership by setting destructor to NULL */
|
||||
if (PyCapsule_SetDestructor(capsule, NULL) == 0) {
|
||||
/* ownership transferred => invalidate capsule by clearing its name */
|
||||
if (unlikely_condition(PyCapsule_SetName(capsule, NULL))) {
|
||||
/* this should never happen since everything above succeeded */
|
||||
xmlFreeDoc(c_doc);
|
||||
return NULL;
|
||||
}
|
||||
*is_owned = 1;
|
||||
}
|
||||
}
|
||||
return c_doc;
|
||||
}
|
||||
|
||||
/* Macro pair implementation of a depth first tree walker
|
||||
*
|
||||
* Calls the code block between the BEGIN and END macros for all elements
|
||||
* below c_tree_top (exclusively), starting at c_node (inclusively iff
|
||||
* 'inclusive' is 1). The _ELEMENT_ variants will only stop on nodes
|
||||
* that match _isElement(), the normal variant will stop on every node
|
||||
* except text nodes.
|
||||
*
|
||||
* To traverse the node and all of its children and siblings in Pyrex, call
|
||||
* cdef xmlNode* some_node
|
||||
* BEGIN_FOR_EACH_ELEMENT_FROM(some_node.parent, some_node, 1)
|
||||
* # do something with some_node
|
||||
* END_FOR_EACH_ELEMENT_FROM(some_node)
|
||||
*
|
||||
* To traverse only the children and siblings of a node, call
|
||||
* cdef xmlNode* some_node
|
||||
* BEGIN_FOR_EACH_ELEMENT_FROM(some_node.parent, some_node, 0)
|
||||
* # do something with some_node
|
||||
* END_FOR_EACH_ELEMENT_FROM(some_node)
|
||||
*
|
||||
* To traverse only the children, do:
|
||||
* cdef xmlNode* some_node
|
||||
* some_node = parent_node.children
|
||||
* BEGIN_FOR_EACH_ELEMENT_FROM(parent_node, some_node, 1)
|
||||
* # do something with some_node
|
||||
* END_FOR_EACH_ELEMENT_FROM(some_node)
|
||||
*
|
||||
* NOTE: 'some_node' MUST be a plain 'xmlNode*' !
|
||||
*
|
||||
* NOTE: parent modification during the walk can divert the iterator, but
|
||||
* should not segfault !
|
||||
*/
|
||||
|
||||
#define _LX__ELEMENT_MATCH(c_node, only_elements) \
|
||||
((only_elements) ? (_isElement(c_node)) : 1)
|
||||
|
||||
#define _LX__ADVANCE_TO_NEXT(c_node, only_elements) \
|
||||
while ((c_node != 0) && (!_LX__ELEMENT_MATCH(c_node, only_elements))) \
|
||||
c_node = c_node->next;
|
||||
|
||||
#define _LX__TRAVERSE_TO_NEXT(c_stop_node, c_node, only_elements) \
|
||||
{ \
|
||||
/* walk through children first */ \
|
||||
xmlNode* _lx__next = c_node->children; \
|
||||
if (_lx__next != 0) { \
|
||||
if (c_node->type == XML_ENTITY_REF_NODE || c_node->type == XML_DTD_NODE) { \
|
||||
_lx__next = 0; \
|
||||
} else { \
|
||||
_LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
|
||||
} \
|
||||
} \
|
||||
if ((_lx__next == 0) && (c_node != c_stop_node)) { \
|
||||
/* try siblings */ \
|
||||
_lx__next = c_node->next; \
|
||||
_LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
|
||||
/* back off through parents */ \
|
||||
while (_lx__next == 0) { \
|
||||
c_node = c_node->parent; \
|
||||
if (c_node == 0) \
|
||||
break; \
|
||||
if (c_node == c_stop_node) \
|
||||
break; \
|
||||
if ((only_elements) && !_isElement(c_node)) \
|
||||
break; \
|
||||
/* we already traversed the parents -> siblings */ \
|
||||
_lx__next = c_node->next; \
|
||||
_LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
|
||||
} \
|
||||
} \
|
||||
c_node = _lx__next; \
|
||||
}
|
||||
|
||||
#define _LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, only_elements) \
|
||||
{ \
|
||||
if (c_node != 0) { \
|
||||
const xmlNode* _lx__tree_top = (c_tree_top); \
|
||||
const int _lx__only_elements = (only_elements); \
|
||||
/* make sure we start at an element */ \
|
||||
if (!_LX__ELEMENT_MATCH(c_node, _lx__only_elements)) { \
|
||||
/* we skip the node, so 'inclusive' is irrelevant */ \
|
||||
if (c_node == _lx__tree_top) \
|
||||
c_node = 0; /* nothing to traverse */ \
|
||||
else { \
|
||||
c_node = c_node->next; \
|
||||
_LX__ADVANCE_TO_NEXT(c_node, _lx__only_elements) \
|
||||
} \
|
||||
} else if (! (inclusive)) { \
|
||||
/* skip the first node */ \
|
||||
_LX__TRAVERSE_TO_NEXT(_lx__tree_top, c_node, _lx__only_elements) \
|
||||
} \
|
||||
\
|
||||
/* now run the user code on the elements we find */ \
|
||||
while (c_node != 0) { \
|
||||
/* here goes the code to be run for each element */
|
||||
|
||||
#define _LX__END_FOR_EACH_FROM(c_node) \
|
||||
_LX__TRAVERSE_TO_NEXT(_lx__tree_top, c_node, _lx__only_elements) \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define BEGIN_FOR_EACH_ELEMENT_FROM(c_tree_top, c_node, inclusive) \
|
||||
_LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, 1)
|
||||
|
||||
#define END_FOR_EACH_ELEMENT_FROM(c_node) \
|
||||
_LX__END_FOR_EACH_FROM(c_node)
|
||||
|
||||
#define BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive) \
|
||||
_LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, 0)
|
||||
|
||||
#define END_FOR_EACH_FROM(c_node) \
|
||||
_LX__END_FOR_EACH_FROM(c_node)
|
||||
|
||||
|
||||
#endif /* HAS_ETREE_DEFS_H */
|
||||
@@ -0,0 +1,237 @@
|
||||
# public Cython/C interface to lxml.etree
|
||||
|
||||
from lxml.includes cimport tree
|
||||
from lxml.includes.tree cimport const_xmlChar
|
||||
|
||||
cdef extern from "lxml-version.h":
|
||||
cdef char* LXML_VERSION_STRING
|
||||
|
||||
cdef extern from "etree_defs.h":
|
||||
# test if c_node is considered an Element (i.e. Element, Comment, etc.)
|
||||
cdef bint _isElement(tree.xmlNode* c_node) nogil
|
||||
|
||||
# return the namespace URI of the node or NULL
|
||||
cdef const_xmlChar* _getNs(tree.xmlNode* node) nogil
|
||||
|
||||
# pair of macros for tree traversal
|
||||
cdef void BEGIN_FOR_EACH_ELEMENT_FROM(tree.xmlNode* tree_top,
|
||||
tree.xmlNode* start_node,
|
||||
int start_node_inclusive) nogil
|
||||
cdef void END_FOR_EACH_ELEMENT_FROM(tree.xmlNode* start_node) nogil
|
||||
|
||||
cdef extern from "etree_api.h":
|
||||
|
||||
# first function to call!
|
||||
cdef int import_lxml__etree() except -1
|
||||
|
||||
##########################################################################
|
||||
# public ElementTree API classes
|
||||
|
||||
cdef class lxml.etree._Document [ object LxmlDocument ]:
|
||||
cdef tree.xmlDoc* _c_doc
|
||||
|
||||
cdef class lxml.etree._Element [ object LxmlElement ]:
|
||||
cdef _Document _doc
|
||||
cdef tree.xmlNode* _c_node
|
||||
|
||||
cdef class lxml.etree.ElementBase(_Element) [ object LxmlElementBase ]:
|
||||
pass
|
||||
|
||||
cdef class lxml.etree._ElementTree [ object LxmlElementTree ]:
|
||||
cdef _Document _doc
|
||||
cdef _Element _context_node
|
||||
|
||||
cdef class lxml.etree.ElementClassLookup [ object LxmlElementClassLookup ]:
|
||||
cdef object (*_lookup_function)(object, _Document, tree.xmlNode*)
|
||||
|
||||
cdef class lxml.etree.FallbackElementClassLookup(ElementClassLookup) \
|
||||
[ object LxmlFallbackElementClassLookup ]:
|
||||
cdef ElementClassLookup fallback
|
||||
cdef object (*_fallback_function)(object, _Document, tree.xmlNode*)
|
||||
|
||||
##########################################################################
|
||||
# creating Element objects
|
||||
|
||||
# create an Element for a C-node in the Document
|
||||
cdef _Element elementFactory(_Document doc, tree.xmlNode* c_node)
|
||||
|
||||
# create an ElementTree for an Element
|
||||
cdef _ElementTree elementTreeFactory(_Element context_node)
|
||||
|
||||
# create an ElementTree subclass for an Element
|
||||
cdef _ElementTree newElementTree(_Element context_node, object subclass)
|
||||
|
||||
# create an ElementTree from an external document
|
||||
cdef _ElementTree adoptExternalDocument(tree.xmlDoc* c_doc, parser, bint is_owned)
|
||||
|
||||
# create a new Element for an existing or new document (doc = None)
|
||||
# builds Python object after setting text, tail, namespaces and attributes
|
||||
cdef _Element makeElement(tag, _Document doc, parser,
|
||||
text, tail, attrib, nsmap)
|
||||
|
||||
# create a new SubElement for an existing parent
|
||||
# builds Python object after setting text, tail, namespaces and attributes
|
||||
cdef _Element makeSubElement(_Element parent, tag, text, tail,
|
||||
attrib, nsmap)
|
||||
|
||||
# deep copy a node to include it in the Document
|
||||
cdef _Element deepcopyNodeToDocument(_Document doc, tree.xmlNode* c_root)
|
||||
|
||||
# set the internal lookup function for Element/Comment/PI classes
|
||||
# use setElementClassLookupFunction(NULL, None) to reset it
|
||||
# note that the lookup function *must always* return an _Element subclass!
|
||||
cdef void setElementClassLookupFunction(
|
||||
object (*function)(object, _Document, tree.xmlNode*), object state)
|
||||
|
||||
# lookup function that always returns the default Element class
|
||||
# note that the first argument is expected to be None!
|
||||
cdef object lookupDefaultElementClass(_1, _Document _2,
|
||||
tree.xmlNode* c_node)
|
||||
|
||||
# lookup function for namespace/tag specific Element classes
|
||||
# note that the first argument is expected to be None!
|
||||
cdef object lookupNamespaceElementClass(_1, _Document _2,
|
||||
tree.xmlNode* c_node)
|
||||
|
||||
# call the fallback lookup function of a FallbackElementClassLookup
|
||||
cdef object callLookupFallback(FallbackElementClassLookup lookup,
|
||||
_Document doc, tree.xmlNode* c_node)
|
||||
|
||||
##########################################################################
|
||||
# XML attribute access
|
||||
|
||||
# return an attribute value for a C attribute on a C element node
|
||||
cdef object attributeValue(tree.xmlNode* c_element,
|
||||
tree.xmlAttr* c_attrib_node)
|
||||
|
||||
# return the value of the attribute with 'ns' and 'name' (or None)
|
||||
cdef object attributeValueFromNsName(tree.xmlNode* c_element,
|
||||
const_xmlChar* c_ns, const_xmlChar* c_name)
|
||||
|
||||
# return the value of attribute "{ns}name", or the default value
|
||||
cdef object getAttributeValue(_Element element, key, default)
|
||||
|
||||
# return an iterator over attribute names (1), values (2) or items (3)
|
||||
# attributes must not be removed during iteration!
|
||||
cdef object iterattributes(_Element element, int keysvalues)
|
||||
|
||||
# return the list of all attribute names (1), values (2) or items (3)
|
||||
cdef list collectAttributes(tree.xmlNode* c_element, int keysvalues)
|
||||
|
||||
# set an attribute value on an element
|
||||
# on failure, sets an exception and returns -1
|
||||
cdef int setAttributeValue(_Element element, key, value) except -1
|
||||
|
||||
# delete an attribute
|
||||
# on failure, sets an exception and returns -1
|
||||
cdef int delAttribute(_Element element, key) except -1
|
||||
|
||||
# delete an attribute based on name and namespace URI
|
||||
# returns -1 if the attribute was not found (no exception)
|
||||
cdef int delAttributeFromNsName(tree.xmlNode* c_element,
|
||||
const_xmlChar* c_href, const_xmlChar* c_name)
|
||||
|
||||
##########################################################################
|
||||
# XML node helper functions
|
||||
|
||||
# check if the element has at least one child
|
||||
cdef bint hasChild(tree.xmlNode* c_node) nogil
|
||||
|
||||
# find child element number 'index' (supports negative indexes)
|
||||
cdef tree.xmlNode* findChild(tree.xmlNode* c_node,
|
||||
Py_ssize_t index) nogil
|
||||
|
||||
# find child element number 'index' starting at first one
|
||||
cdef tree.xmlNode* findChildForwards(tree.xmlNode* c_node,
|
||||
Py_ssize_t index) nogil
|
||||
|
||||
# find child element number 'index' starting at last one
|
||||
cdef tree.xmlNode* findChildBackwards(tree.xmlNode* c_node,
|
||||
Py_ssize_t index) nogil
|
||||
|
||||
# return next/previous sibling element of the node
|
||||
cdef tree.xmlNode* nextElement(tree.xmlNode* c_node) nogil
|
||||
cdef tree.xmlNode* previousElement(tree.xmlNode* c_node) nogil
|
||||
|
||||
##########################################################################
|
||||
# iterators (DEPRECATED API, don't use in new code!)
|
||||
|
||||
cdef class lxml.etree._ElementTagMatcher [ object LxmlElementTagMatcher ]:
|
||||
cdef char* _href
|
||||
cdef char* _name
|
||||
|
||||
# store "{ns}tag" (or None) filter for this matcher or element iterator
|
||||
# ** unless _href *and* _name are set up 'by hand', this function *must*
|
||||
# ** be called when subclassing the iterator below!
|
||||
cdef void initTagMatch(_ElementTagMatcher matcher, tag)
|
||||
|
||||
cdef class lxml.etree._ElementIterator(_ElementTagMatcher) [
|
||||
object LxmlElementIterator ]:
|
||||
cdef _Element _node
|
||||
cdef tree.xmlNode* (*_next_element)(tree.xmlNode*)
|
||||
|
||||
# store the initial node of the iterator if it matches the required tag
|
||||
# or its next matching sibling if not
|
||||
cdef void iteratorStoreNext(_ElementIterator iterator, _Element node)
|
||||
|
||||
##########################################################################
|
||||
# other helper functions
|
||||
|
||||
# check if a C node matches a tag name and namespace
|
||||
# (NULL allowed for each => always matches)
|
||||
cdef int tagMatches(tree.xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name)
|
||||
|
||||
# convert a UTF-8 char* to a Python string or unicode string
|
||||
cdef object pyunicode(const_xmlChar* s)
|
||||
|
||||
# convert the string to UTF-8 using the normal lxml.etree semantics
|
||||
cdef bytes utf8(object s)
|
||||
|
||||
# split a tag into a (URI, name) tuple, return None as URI for '{}tag'
|
||||
cdef tuple getNsTag(object tag)
|
||||
|
||||
# split a tag into a (URI, name) tuple, return b'' as URI for '{}tag'
|
||||
cdef tuple getNsTagWithEmptyNs(object tag)
|
||||
|
||||
# get the "{ns}tag" string for a C node
|
||||
cdef object namespacedName(tree.xmlNode* c_node)
|
||||
|
||||
# get the "{ns}tag" string for a href/tagname pair (c_ns may be NULL)
|
||||
cdef object namespacedNameFromNsName(const_xmlChar* c_ns, const_xmlChar* c_tag)
|
||||
|
||||
# check if the node has a text value (which may be '')
|
||||
cdef bint hasText(tree.xmlNode* c_node) nogil
|
||||
|
||||
# check if the node has a tail value (which may be '')
|
||||
cdef bint hasTail(tree.xmlNode* c_node) nogil
|
||||
|
||||
# get the text content of an element (or None)
|
||||
cdef object textOf(tree.xmlNode* c_node)
|
||||
|
||||
# get the tail content of an element (or None)
|
||||
cdef object tailOf(tree.xmlNode* c_node)
|
||||
|
||||
# set the text value of an element
|
||||
cdef int setNodeText(tree.xmlNode* c_node, text) except -1
|
||||
|
||||
# set the tail text value of an element
|
||||
cdef int setTailText(tree.xmlNode* c_node, text) except -1
|
||||
|
||||
# append an element to the children of a parent element
|
||||
# deprecated: don't use, does not propagate exceptions!
|
||||
# use appendChildToElement() instead
|
||||
cdef void appendChild(_Element parent, _Element child)
|
||||
|
||||
# added in lxml 3.3 as a safe replacement for appendChild()
|
||||
# return -1 for exception, 0 for ok
|
||||
cdef int appendChildToElement(_Element parent, _Element child) except -1
|
||||
|
||||
# recursively lookup a namespace in element or ancestors, or create it
|
||||
cdef tree.xmlNs* findOrBuildNodeNsPrefix(
|
||||
_Document doc, tree.xmlNode* c_node, const_xmlChar* href, const_xmlChar* prefix)
|
||||
|
||||
# find the Document of an Element, ElementTree or Document (itself!)
|
||||
cdef _Document documentOrRaise(object input)
|
||||
|
||||
# find the root Element of an Element (itself!), ElementTree or Document
|
||||
cdef _Element rootNodeOrRaise(object input)
|
||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU CHARSET Library.
|
||||
|
||||
The GNU CHARSET Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU CHARSET Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU CHARSET Library; see the file COPYING.LIB. If not,
|
||||
see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _LIBCHARSET_H
|
||||
#define _LIBCHARSET_H
|
||||
|
||||
#include <localcharset.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for relocatable packages. */
|
||||
|
||||
/* Sets the original and the current installation prefix of the package.
|
||||
Relocation simply replaces a pathname starting with the original prefix
|
||||
by the corresponding pathname with the current prefix instead. Both
|
||||
prefixes should be directory names without trailing slash (i.e. use ""
|
||||
instead of "/"). */
|
||||
extern void libcharset_set_relocation_prefix (const char *orig_prefix,
|
||||
const char *curr_prefix);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _LIBCHARSET_H */
|
||||
@@ -0,0 +1,137 @@
|
||||
/* Determine a canonical name for the current locale's character encoding.
|
||||
Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc.
|
||||
This file is part of the GNU CHARSET Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _LOCALCHARSET_H
|
||||
#define _LOCALCHARSET_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine the current locale's character encoding, and canonicalize it
|
||||
into one of the canonical names listed below.
|
||||
The result must not be freed; it is statically allocated. The result
|
||||
becomes invalid when setlocale() is used to change the global locale, or
|
||||
when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
|
||||
is changed; threads in multithreaded programs should not do this.
|
||||
If the canonical name cannot be determined, the result is a non-canonical
|
||||
name. */
|
||||
extern const char * locale_charset (void);
|
||||
|
||||
/* About GNU canonical names for character encodings:
|
||||
|
||||
Every canonical name must be supported by GNU libiconv. Support by GNU libc
|
||||
is also desirable.
|
||||
|
||||
The name is case insensitive. Usually an upper case MIME charset name is
|
||||
preferred.
|
||||
|
||||
The current list of these GNU canonical names is:
|
||||
|
||||
name MIME? used by which systems
|
||||
(darwin = Mac OS X, windows = native Windows)
|
||||
|
||||
ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
|
||||
ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-3 Y glibc solaris cygwin
|
||||
ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
|
||||
ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-6 Y glibc aix hpux solaris cygwin
|
||||
ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
|
||||
ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos
|
||||
ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos
|
||||
ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
|
||||
ISO-8859-14 glibc cygwin
|
||||
ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
|
||||
KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
|
||||
KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
|
||||
KOI8-T glibc
|
||||
CP437 dos
|
||||
CP775 dos
|
||||
CP850 aix osf dos
|
||||
CP852 dos
|
||||
CP855 dos
|
||||
CP856 aix
|
||||
CP857 dos
|
||||
CP861 dos
|
||||
CP862 dos
|
||||
CP864 dos
|
||||
CP865 dos
|
||||
CP866 freebsd netbsd openbsd darwin dos
|
||||
CP869 dos
|
||||
CP874 windows dos
|
||||
CP922 aix
|
||||
CP932 aix cygwin windows dos
|
||||
CP943 aix zos
|
||||
CP949 osf darwin windows dos
|
||||
CP950 windows dos
|
||||
CP1046 aix
|
||||
CP1124 aix
|
||||
CP1125 dos
|
||||
CP1129 aix
|
||||
CP1131 freebsd darwin
|
||||
CP1250 windows
|
||||
CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
|
||||
CP1252 aix windows
|
||||
CP1253 windows
|
||||
CP1254 windows
|
||||
CP1255 glibc windows
|
||||
CP1256 windows
|
||||
CP1257 windows
|
||||
GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
|
||||
EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
|
||||
EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
|
||||
EUC-TW glibc aix hpux irix osf solaris netbsd
|
||||
BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
|
||||
BIG5-HKSCS glibc hpux solaris netbsd darwin
|
||||
GBK glibc aix osf solaris freebsd darwin cygwin windows dos
|
||||
GB18030 glibc hpux solaris freebsd netbsd darwin
|
||||
SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
|
||||
JOHAB glibc solaris windows
|
||||
TIS-620 glibc aix hpux osf solaris cygwin zos
|
||||
VISCII Y glibc
|
||||
TCVN5712-1 glibc
|
||||
ARMSCII-8 glibc freebsd netbsd darwin
|
||||
GEORGIAN-PS glibc cygwin
|
||||
PT154 glibc netbsd cygwin
|
||||
HP-ROMAN8 hpux
|
||||
HP-ARABIC8 hpux
|
||||
HP-GREEK8 hpux
|
||||
HP-HEBREW8 hpux
|
||||
HP-TURKISH8 hpux
|
||||
HP-KANA8 hpux
|
||||
DEC-KANJI osf
|
||||
DEC-HANYU osf
|
||||
UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos
|
||||
|
||||
Note: Names which are not marked as being a MIME name should not be used in
|
||||
Internet protocols for information interchange (mail, news, etc.).
|
||||
|
||||
Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
|
||||
must understand both names and treat them as equivalent.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _LOCALCHARSET_H */
|
||||
@@ -0,0 +1,534 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||
* this permanently in zconf.h using "./configure --zprefix".
|
||||
*/
|
||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||
# define Z_PREFIX_SET
|
||||
|
||||
/* all linked symbols and init macros */
|
||||
# define _dist_code z__dist_code
|
||||
# define _length_code z__length_code
|
||||
# define _tr_align z__tr_align
|
||||
# define _tr_flush_bits z__tr_flush_bits
|
||||
# define _tr_flush_block z__tr_flush_block
|
||||
# define _tr_init z__tr_init
|
||||
# define _tr_stored_block z__tr_stored_block
|
||||
# define _tr_tally z__tr_tally
|
||||
# define adler32 z_adler32
|
||||
# define adler32_combine z_adler32_combine
|
||||
# define adler32_combine64 z_adler32_combine64
|
||||
# define adler32_z z_adler32_z
|
||||
# ifndef Z_SOLO
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# endif
|
||||
# define crc32 z_crc32
|
||||
# define crc32_combine z_crc32_combine
|
||||
# define crc32_combine64 z_crc32_combine64
|
||||
# define crc32_z z_crc32_z
|
||||
# define deflate z_deflate
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define deflateGetDictionary z_deflateGetDictionary
|
||||
# define deflateInit z_deflateInit
|
||||
# define deflateInit2 z_deflateInit2
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflatePending z_deflatePending
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateResetKeep z_deflateResetKeep
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateSetHeader z_deflateSetHeader
|
||||
# define deflateTune z_deflateTune
|
||||
# define deflate_copyright z_deflate_copyright
|
||||
# define get_crc_table z_get_crc_table
|
||||
# ifndef Z_SOLO
|
||||
# define gz_error z_gz_error
|
||||
# define gz_intmax z_gz_intmax
|
||||
# define gz_strwinerror z_gz_strwinerror
|
||||
# define gzbuffer z_gzbuffer
|
||||
# define gzclearerr z_gzclearerr
|
||||
# define gzclose z_gzclose
|
||||
# define gzclose_r z_gzclose_r
|
||||
# define gzclose_w z_gzclose_w
|
||||
# define gzdirect z_gzdirect
|
||||
# define gzdopen z_gzdopen
|
||||
# define gzeof z_gzeof
|
||||
# define gzerror z_gzerror
|
||||
# define gzflush z_gzflush
|
||||
# define gzfread z_gzfread
|
||||
# define gzfwrite z_gzfwrite
|
||||
# define gzgetc z_gzgetc
|
||||
# define gzgetc_ z_gzgetc_
|
||||
# define gzgets z_gzgets
|
||||
# define gzoffset z_gzoffset
|
||||
# define gzoffset64 z_gzoffset64
|
||||
# define gzopen z_gzopen
|
||||
# define gzopen64 z_gzopen64
|
||||
# ifdef _WIN32
|
||||
# define gzopen_w z_gzopen_w
|
||||
# endif
|
||||
# define gzprintf z_gzprintf
|
||||
# define gzputc z_gzputc
|
||||
# define gzputs z_gzputs
|
||||
# define gzread z_gzread
|
||||
# define gzrewind z_gzrewind
|
||||
# define gzseek z_gzseek
|
||||
# define gzseek64 z_gzseek64
|
||||
# define gzsetparams z_gzsetparams
|
||||
# define gztell z_gztell
|
||||
# define gztell64 z_gztell64
|
||||
# define gzungetc z_gzungetc
|
||||
# define gzvprintf z_gzvprintf
|
||||
# define gzwrite z_gzwrite
|
||||
# endif
|
||||
# define inflate z_inflate
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define inflateBackInit z_inflateBackInit
|
||||
# define inflateBackInit_ z_inflateBackInit_
|
||||
# define inflateCodesUsed z_inflateCodesUsed
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define inflateGetDictionary z_inflateGetDictionary
|
||||
# define inflateGetHeader z_inflateGetHeader
|
||||
# define inflateInit z_inflateInit
|
||||
# define inflateInit2 z_inflateInit2
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflateMark z_inflateMark
|
||||
# define inflatePrime z_inflatePrime
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateReset2 z_inflateReset2
|
||||
# define inflateResetKeep z_inflateResetKeep
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateUndermine z_inflateUndermine
|
||||
# define inflateValidate z_inflateValidate
|
||||
# define inflate_copyright z_inflate_copyright
|
||||
# define inflate_fast z_inflate_fast
|
||||
# define inflate_table z_inflate_table
|
||||
# ifndef Z_SOLO
|
||||
# define uncompress z_uncompress
|
||||
# define uncompress2 z_uncompress2
|
||||
# endif
|
||||
# define zError z_zError
|
||||
# ifndef Z_SOLO
|
||||
# define zcalloc z_zcalloc
|
||||
# define zcfree z_zcfree
|
||||
# endif
|
||||
# define zlibCompileFlags z_zlibCompileFlags
|
||||
# define zlibVersion z_zlibVersion
|
||||
|
||||
/* all zlib typedefs in zlib.h and zconf.h */
|
||||
# define Byte z_Byte
|
||||
# define Bytef z_Bytef
|
||||
# define alloc_func z_alloc_func
|
||||
# define charf z_charf
|
||||
# define free_func z_free_func
|
||||
# ifndef Z_SOLO
|
||||
# define gzFile z_gzFile
|
||||
# endif
|
||||
# define gz_header z_gz_header
|
||||
# define gz_headerp z_gz_headerp
|
||||
# define in_func z_in_func
|
||||
# define intf z_intf
|
||||
# define out_func z_out_func
|
||||
# define uInt z_uInt
|
||||
# define uIntf z_uIntf
|
||||
# define uLong z_uLong
|
||||
# define uLongf z_uLongf
|
||||
# define voidp z_voidp
|
||||
# define voidpc z_voidpc
|
||||
# define voidpf z_voidpf
|
||||
|
||||
/* all zlib structs in zlib.h and zconf.h */
|
||||
# define gz_header_s z_gz_header_s
|
||||
# define internal_state z_internal_state
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||
# define OS2
|
||||
#endif
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
# ifndef SYS16BIT
|
||||
# define SYS16BIT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_VERSION__
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# ifndef STDC99
|
||||
# define STDC99
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const /* note: need a more gentle solution here */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
typedef unsigned long z_size_t;
|
||||
#else
|
||||
# define z_longlong long long
|
||||
# if defined(NO_SIZE_T)
|
||||
typedef unsigned NO_SIZE_T z_size_t;
|
||||
# elif defined(STDC)
|
||||
# include <stddef.h>
|
||||
typedef size_t z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
# undef z_longlong
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# define Z_ARG(args) args
|
||||
# else
|
||||
# define Z_ARG(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR CDECL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# ifdef ZLIB_DLL
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXPORT __declspec(dllexport)
|
||||
# define ZEXPORTVA __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXPORT __declspec(dllimport)
|
||||
# define ZEXPORTVA __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (UINT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned
|
||||
# elif (ULONG_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned long
|
||||
# elif (USHRT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned short
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#if 1 /* was set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#if 1 /* was set to #if 1 by ./configure */
|
||||
# define Z_HAVE_STDARG_H
|
||||
#endif
|
||||
|
||||
#ifdef STDC
|
||||
# ifndef Z_SOLO
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifndef Z_SOLO
|
||||
# include <stdarg.h> /* for va_list */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef Z_SOLO
|
||||
# include <stddef.h> /* for wchar_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||
* though the former does not conform to the LFS document), but considering
|
||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||
* equivalently requesting no 64-bit operations
|
||||
*/
|
||||
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
#ifndef Z_SOLO
|
||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# ifndef z_off_t
|
||||
# define z_off_t off_t
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
# define Z_LARGE64
|
||||
#endif
|
||||
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||
# define Z_WANT64
|
||||
#endif
|
||||
|
||||
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
1935
acer-env/lib/python3.10/site-packages/lxml/includes/extlibs/zlib.h
Normal file
1935
acer-env/lib/python3.10/site-packages/lxml/includes/extlibs/zlib.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
from libc.string cimport const_char
|
||||
|
||||
from lxml.includes.tree cimport xmlDoc
|
||||
from lxml.includes.tree cimport xmlInputReadCallback, xmlInputCloseCallback
|
||||
from lxml.includes.xmlparser cimport xmlParserCtxt, xmlSAXHandler, xmlSAXHandlerV1
|
||||
|
||||
cdef extern from "libxml/HTMLparser.h":
|
||||
ctypedef enum htmlParserOption:
|
||||
HTML_PARSE_NOERROR # suppress error reports
|
||||
HTML_PARSE_NOWARNING # suppress warning reports
|
||||
HTML_PARSE_PEDANTIC # pedantic error reporting
|
||||
HTML_PARSE_NOBLANKS # remove blank nodes
|
||||
HTML_PARSE_NONET # Forbid network access
|
||||
# libxml2 2.6.21+ only:
|
||||
HTML_PARSE_RECOVER # Relaxed parsing
|
||||
HTML_PARSE_COMPACT # compact small text nodes
|
||||
# libxml2 2.7.7+ only:
|
||||
HTML_PARSE_NOIMPLIED # Do not add implied html/body... elements
|
||||
# libxml2 2.7.8+ only:
|
||||
HTML_PARSE_NODEFDTD # do not default a doctype if not found
|
||||
# libxml2 2.8.0+ only:
|
||||
XML_PARSE_IGNORE_ENC # ignore internal document encoding hint
|
||||
|
||||
xmlSAXHandlerV1 htmlDefaultSAXHandler
|
||||
|
||||
cdef xmlParserCtxt* htmlCreateMemoryParserCtxt(
|
||||
char* buffer, int size) nogil
|
||||
cdef xmlParserCtxt* htmlCreateFileParserCtxt(
|
||||
char* filename, char* encoding) nogil
|
||||
cdef xmlParserCtxt* htmlCreatePushParserCtxt(xmlSAXHandler* sax,
|
||||
void* user_data,
|
||||
char* chunk, int size,
|
||||
char* filename, int enc) nogil
|
||||
cdef void htmlFreeParserCtxt(xmlParserCtxt* ctxt) nogil
|
||||
cdef void htmlCtxtReset(xmlParserCtxt* ctxt) nogil
|
||||
cdef int htmlCtxtUseOptions(xmlParserCtxt* ctxt, int options) nogil
|
||||
cdef int htmlParseDocument(xmlParserCtxt* ctxt) nogil
|
||||
cdef int htmlParseChunk(xmlParserCtxt* ctxt,
|
||||
char* chunk, int size, int terminate) nogil
|
||||
|
||||
cdef xmlDoc* htmlCtxtReadFile(xmlParserCtxt* ctxt,
|
||||
char* filename, const_char* encoding,
|
||||
int options) nogil
|
||||
cdef xmlDoc* htmlCtxtReadDoc(xmlParserCtxt* ctxt,
|
||||
char* buffer, char* URL, const_char* encoding,
|
||||
int options) nogil
|
||||
cdef xmlDoc* htmlCtxtReadIO(xmlParserCtxt* ctxt,
|
||||
xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void* ioctx,
|
||||
char* URL, const_char* encoding,
|
||||
int options) nogil
|
||||
cdef xmlDoc* htmlCtxtReadMemory(xmlParserCtxt* ctxt,
|
||||
char* buffer, int size,
|
||||
char* filename, const_char* encoding,
|
||||
int options) nogil
|
||||
Binary file not shown.
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Summary: main header file
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __EXSLT_H__
|
||||
#define __EXSLT_H__
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include "exsltexports.h"
|
||||
#include <libexslt/exsltconfig.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
EXSLTPUBVAR const char *exsltLibraryVersion;
|
||||
EXSLTPUBVAR const int exsltLibexsltVersion;
|
||||
EXSLTPUBVAR const int exsltLibxsltVersion;
|
||||
EXSLTPUBVAR const int exsltLibxmlVersion;
|
||||
|
||||
/**
|
||||
* EXSLT_COMMON_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT common functions
|
||||
*/
|
||||
#define EXSLT_COMMON_NAMESPACE ((const xmlChar *) "http://exslt.org/common")
|
||||
/**
|
||||
* EXSLT_CRYPTO_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT crypto functions
|
||||
*/
|
||||
#define EXSLT_CRYPTO_NAMESPACE ((const xmlChar *) "http://exslt.org/crypto")
|
||||
/**
|
||||
* EXSLT_MATH_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT math functions
|
||||
*/
|
||||
#define EXSLT_MATH_NAMESPACE ((const xmlChar *) "http://exslt.org/math")
|
||||
/**
|
||||
* EXSLT_SETS_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT set functions
|
||||
*/
|
||||
#define EXSLT_SETS_NAMESPACE ((const xmlChar *) "http://exslt.org/sets")
|
||||
/**
|
||||
* EXSLT_FUNCTIONS_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT functions extension functions
|
||||
*/
|
||||
#define EXSLT_FUNCTIONS_NAMESPACE ((const xmlChar *) "http://exslt.org/functions")
|
||||
/**
|
||||
* EXSLT_STRINGS_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT strings functions
|
||||
*/
|
||||
#define EXSLT_STRINGS_NAMESPACE ((const xmlChar *) "http://exslt.org/strings")
|
||||
/**
|
||||
* EXSLT_DATE_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT date functions
|
||||
*/
|
||||
#define EXSLT_DATE_NAMESPACE ((const xmlChar *) "http://exslt.org/dates-and-times")
|
||||
/**
|
||||
* EXSLT_DYNAMIC_NAMESPACE:
|
||||
*
|
||||
* Namespace for EXSLT dynamic functions
|
||||
*/
|
||||
#define EXSLT_DYNAMIC_NAMESPACE ((const xmlChar *) "http://exslt.org/dynamic")
|
||||
|
||||
/**
|
||||
* SAXON_NAMESPACE:
|
||||
*
|
||||
* Namespace for SAXON extensions functions
|
||||
*/
|
||||
#define SAXON_NAMESPACE ((const xmlChar *) "http://icl.com/saxon")
|
||||
|
||||
EXSLTPUBFUN void EXSLTCALL exsltCommonRegister (void);
|
||||
#ifdef EXSLT_CRYPTO_ENABLED
|
||||
EXSLTPUBFUN void EXSLTCALL exsltCryptoRegister (void);
|
||||
#endif
|
||||
EXSLTPUBFUN void EXSLTCALL exsltMathRegister (void);
|
||||
EXSLTPUBFUN void EXSLTCALL exsltSetsRegister (void);
|
||||
EXSLTPUBFUN void EXSLTCALL exsltFuncRegister (void);
|
||||
EXSLTPUBFUN void EXSLTCALL exsltStrRegister (void);
|
||||
EXSLTPUBFUN void EXSLTCALL exsltDateRegister (void);
|
||||
EXSLTPUBFUN void EXSLTCALL exsltSaxonRegister (void);
|
||||
EXSLTPUBFUN void EXSLTCALL exsltDynRegister(void);
|
||||
|
||||
EXSLTPUBFUN void EXSLTCALL exsltRegisterAll (void);
|
||||
|
||||
EXSLTPUBFUN int EXSLTCALL exsltDateXpathCtxtRegister (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *prefix);
|
||||
EXSLTPUBFUN int EXSLTCALL exsltMathXpathCtxtRegister (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *prefix);
|
||||
EXSLTPUBFUN int EXSLTCALL exsltSetsXpathCtxtRegister (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *prefix);
|
||||
EXSLTPUBFUN int EXSLTCALL exsltStrXpathCtxtRegister (xmlXPathContextPtr ctxt,
|
||||
const xmlChar *prefix);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __EXSLT_H__ */
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* exsltconfig.h: compile-time version information for the EXSLT library
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* daniel@veillard.com
|
||||
*/
|
||||
|
||||
#ifndef __XML_EXSLTCONFIG_H__
|
||||
#define __XML_EXSLTCONFIG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LIBEXSLT_DOTTED_VERSION:
|
||||
*
|
||||
* the version string like "1.2.3"
|
||||
*/
|
||||
#define LIBEXSLT_DOTTED_VERSION "0.8.20"
|
||||
|
||||
/**
|
||||
* LIBEXSLT_VERSION:
|
||||
*
|
||||
* the version number: 1.2.3 value is 10203
|
||||
*/
|
||||
#define LIBEXSLT_VERSION 820
|
||||
|
||||
/**
|
||||
* LIBEXSLT_VERSION_STRING:
|
||||
*
|
||||
* the version number string, 1.2.3 value is "10203"
|
||||
*/
|
||||
#define LIBEXSLT_VERSION_STRING "820"
|
||||
|
||||
/**
|
||||
* LIBEXSLT_VERSION_EXTRA:
|
||||
*
|
||||
* extra version information, used to show a CVS compilation
|
||||
*/
|
||||
#define LIBEXSLT_VERSION_EXTRA ""
|
||||
|
||||
/**
|
||||
* WITH_CRYPTO:
|
||||
*
|
||||
* Whether crypto support is configured into exslt
|
||||
*/
|
||||
#if 0
|
||||
#define EXSLT_CRYPTO_ENABLED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ATTRIBUTE_UNUSED:
|
||||
*
|
||||
* This macro is used to flag unused function parameters to GCC
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
||||
#endif
|
||||
#else
|
||||
#define ATTRIBUTE_UNUSED
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_EXSLTCONFIG_H__ */
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Summary: macros for marking symbols as exportable/importable.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Igor Zlatkovic <igor@zlatkovic.com>
|
||||
*/
|
||||
|
||||
#ifndef __EXSLT_EXPORTS_H__
|
||||
#define __EXSLT_EXPORTS_H__
|
||||
|
||||
/**
|
||||
* EXSLTPUBFUN, EXSLTPUBVAR, EXSLTCALL
|
||||
*
|
||||
* Macros which declare an exportable function, an exportable variable and
|
||||
* the calling convention used for functions.
|
||||
*
|
||||
* Please use an extra block for every platform/compiler combination when
|
||||
* modifying this, rather than overlong #ifdef lines. This helps
|
||||
* readability as well as the fact that different compilers on the same
|
||||
* platform might need different definitions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* EXSLTPUBFUN:
|
||||
*
|
||||
* Macros which declare an exportable function
|
||||
*/
|
||||
#define EXSLTPUBFUN
|
||||
/**
|
||||
* EXSLTPUBVAR:
|
||||
*
|
||||
* Macros which declare an exportable variable
|
||||
*/
|
||||
#define EXSLTPUBVAR extern
|
||||
/**
|
||||
* EXSLTCALL:
|
||||
*
|
||||
* Macros which declare the called convention for exported functions
|
||||
*/
|
||||
#define EXSLTCALL
|
||||
|
||||
/** DOC_DISABLE */
|
||||
|
||||
/* Windows platform with MS compiler */
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#undef EXSLTPUBFUN
|
||||
#undef EXSLTPUBVAR
|
||||
#undef EXSLTCALL
|
||||
#if defined(IN_LIBEXSLT) && !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBFUN __declspec(dllexport)
|
||||
#define EXSLTPUBVAR __declspec(dllexport)
|
||||
#else
|
||||
#define EXSLTPUBFUN
|
||||
#if !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBVAR __declspec(dllimport) extern
|
||||
#else
|
||||
#define EXSLTPUBVAR extern
|
||||
#endif
|
||||
#endif
|
||||
#define EXSLTCALL __cdecl
|
||||
#if !defined _REENTRANT
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Windows platform with Borland compiler */
|
||||
#if defined(_WIN32) && defined(__BORLANDC__)
|
||||
#undef EXSLTPUBFUN
|
||||
#undef EXSLTPUBVAR
|
||||
#undef EXSLTCALL
|
||||
#if defined(IN_LIBEXSLT) && !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBFUN __declspec(dllexport)
|
||||
#define EXSLTPUBVAR __declspec(dllexport) extern
|
||||
#else
|
||||
#define EXSLTPUBFUN
|
||||
#if !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBVAR __declspec(dllimport) extern
|
||||
#else
|
||||
#define EXSLTPUBVAR extern
|
||||
#endif
|
||||
#endif
|
||||
#define EXSLTCALL __cdecl
|
||||
#if !defined _REENTRANT
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Windows platform with GNU compiler (Mingw) */
|
||||
#if defined(_WIN32) && defined(__MINGW32__)
|
||||
#undef EXSLTPUBFUN
|
||||
#undef EXSLTPUBVAR
|
||||
#undef EXSLTCALL
|
||||
/*
|
||||
#if defined(IN_LIBEXSLT) && !defined(LIBEXSLT_STATIC)
|
||||
*/
|
||||
#if !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBFUN __declspec(dllexport)
|
||||
#define EXSLTPUBVAR __declspec(dllexport) extern
|
||||
#else
|
||||
#define EXSLTPUBFUN
|
||||
#if !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBVAR __declspec(dllimport) extern
|
||||
#else
|
||||
#define EXSLTPUBVAR extern
|
||||
#endif
|
||||
#endif
|
||||
#define EXSLTCALL __cdecl
|
||||
#if !defined _REENTRANT
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Cygwin platform (does not define _WIN32), GNU compiler */
|
||||
#if defined(__CYGWIN__)
|
||||
#undef EXSLTPUBFUN
|
||||
#undef EXSLTPUBVAR
|
||||
#undef EXSLTCALL
|
||||
#if defined(IN_LIBEXSLT) && !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBFUN __declspec(dllexport)
|
||||
#define EXSLTPUBVAR __declspec(dllexport)
|
||||
#else
|
||||
#define EXSLTPUBFUN
|
||||
#if !defined(LIBEXSLT_STATIC)
|
||||
#define EXSLTPUBVAR __declspec(dllimport) extern
|
||||
#else
|
||||
#define EXSLTPUBVAR extern
|
||||
#endif
|
||||
#endif
|
||||
#define EXSLTCALL __cdecl
|
||||
#endif
|
||||
|
||||
/* Compatibility */
|
||||
#if !defined(LIBEXSLT_PUBLIC)
|
||||
#define LIBEXSLT_PUBLIC EXSLTPUBVAR
|
||||
#endif
|
||||
|
||||
#endif /* __EXSLT_EXPORTS_H__ */
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Summary: old DocBook SGML parser
|
||||
* Description: interface for a DocBook SGML non-verifying parser
|
||||
* This code is DEPRECATED, and should not be used anymore.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __DOCB_PARSER_H__
|
||||
#define __DOCB_PARSER_H__
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
|
||||
#ifndef IN_LIBXML
|
||||
#ifdef __GNUC__
|
||||
#warning "The DOCBparser module has been deprecated in libxml2-2.6.0"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Most of the back-end structures from XML and SGML are shared.
|
||||
*/
|
||||
typedef xmlParserCtxt docbParserCtxt;
|
||||
typedef xmlParserCtxtPtr docbParserCtxtPtr;
|
||||
typedef xmlSAXHandler docbSAXHandler;
|
||||
typedef xmlSAXHandlerPtr docbSAXHandlerPtr;
|
||||
typedef xmlParserInput docbParserInput;
|
||||
typedef xmlParserInputPtr docbParserInputPtr;
|
||||
typedef xmlDocPtr docbDocPtr;
|
||||
|
||||
/*
|
||||
* There is only few public functions.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
docbEncodeEntities(unsigned char *out,
|
||||
int *outlen,
|
||||
const unsigned char *in,
|
||||
int *inlen, int quoteChar);
|
||||
|
||||
XMLPUBFUN docbDocPtr XMLCALL
|
||||
docbSAXParseDoc (xmlChar *cur,
|
||||
const char *encoding,
|
||||
docbSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
XMLPUBFUN docbDocPtr XMLCALL
|
||||
docbParseDoc (xmlChar *cur,
|
||||
const char *encoding);
|
||||
XMLPUBFUN docbDocPtr XMLCALL
|
||||
docbSAXParseFile (const char *filename,
|
||||
const char *encoding,
|
||||
docbSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
XMLPUBFUN docbDocPtr XMLCALL
|
||||
docbParseFile (const char *filename,
|
||||
const char *encoding);
|
||||
|
||||
/**
|
||||
* Interfaces for the Push mode.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
docbFreeParserCtxt (docbParserCtxtPtr ctxt);
|
||||
XMLPUBFUN docbParserCtxtPtr XMLCALL
|
||||
docbCreatePushParserCtxt(docbSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *chunk,
|
||||
int size,
|
||||
const char *filename,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
docbParseChunk (docbParserCtxtPtr ctxt,
|
||||
const char *chunk,
|
||||
int size,
|
||||
int terminate);
|
||||
XMLPUBFUN docbParserCtxtPtr XMLCALL
|
||||
docbCreateFileParserCtxt(const char *filename,
|
||||
const char *encoding);
|
||||
XMLPUBFUN int XMLCALL
|
||||
docbParseDocument (docbParserCtxtPtr ctxt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_DOCB_ENABLED */
|
||||
|
||||
#endif /* __DOCB_PARSER_H__ */
|
||||
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Summary: interface for an HTML 4.0 non-verifying parser
|
||||
* Description: this module implements an HTML 4.0 non-verifying parser
|
||||
* with API compatible with the XML parser ones. It should
|
||||
* be able to parse "real world" HTML, even if severely
|
||||
* broken from a specification point of view.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __HTML_PARSER_H__
|
||||
#define __HTML_PARSER_H__
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Most of the back-end structures from XML and HTML are shared.
|
||||
*/
|
||||
typedef xmlParserCtxt htmlParserCtxt;
|
||||
typedef xmlParserCtxtPtr htmlParserCtxtPtr;
|
||||
typedef xmlParserNodeInfo htmlParserNodeInfo;
|
||||
typedef xmlSAXHandler htmlSAXHandler;
|
||||
typedef xmlSAXHandlerPtr htmlSAXHandlerPtr;
|
||||
typedef xmlParserInput htmlParserInput;
|
||||
typedef xmlParserInputPtr htmlParserInputPtr;
|
||||
typedef xmlDocPtr htmlDocPtr;
|
||||
typedef xmlNodePtr htmlNodePtr;
|
||||
|
||||
/*
|
||||
* Internal description of an HTML element, representing HTML 4.01
|
||||
* and XHTML 1.0 (which share the same structure).
|
||||
*/
|
||||
typedef struct _htmlElemDesc htmlElemDesc;
|
||||
typedef htmlElemDesc *htmlElemDescPtr;
|
||||
struct _htmlElemDesc {
|
||||
const char *name; /* The tag name */
|
||||
char startTag; /* Whether the start tag can be implied */
|
||||
char endTag; /* Whether the end tag can be implied */
|
||||
char saveEndTag; /* Whether the end tag should be saved */
|
||||
char empty; /* Is this an empty element ? */
|
||||
char depr; /* Is this a deprecated element ? */
|
||||
char dtd; /* 1: only in Loose DTD, 2: only Frameset one */
|
||||
char isinline; /* is this a block 0 or inline 1 element */
|
||||
const char *desc; /* the description */
|
||||
|
||||
/* NRK Jan.2003
|
||||
* New fields encapsulating HTML structure
|
||||
*
|
||||
* Bugs:
|
||||
* This is a very limited representation. It fails to tell us when
|
||||
* an element *requires* subelements (we only have whether they're
|
||||
* allowed or not), and it doesn't tell us where CDATA and PCDATA
|
||||
* are allowed. Some element relationships are not fully represented:
|
||||
* these are flagged with the word MODIFIER
|
||||
*/
|
||||
const char** subelts; /* allowed sub-elements of this element */
|
||||
const char* defaultsubelt; /* subelement for suggested auto-repair
|
||||
if necessary or NULL */
|
||||
const char** attrs_opt; /* Optional Attributes */
|
||||
const char** attrs_depr; /* Additional deprecated attributes */
|
||||
const char** attrs_req; /* Required attributes */
|
||||
};
|
||||
|
||||
/*
|
||||
* Internal description of an HTML entity.
|
||||
*/
|
||||
typedef struct _htmlEntityDesc htmlEntityDesc;
|
||||
typedef htmlEntityDesc *htmlEntityDescPtr;
|
||||
struct _htmlEntityDesc {
|
||||
unsigned int value; /* the UNICODE value for the character */
|
||||
const char *name; /* The entity name */
|
||||
const char *desc; /* the description */
|
||||
};
|
||||
|
||||
/*
|
||||
* There is only few public functions.
|
||||
*/
|
||||
XMLPUBFUN const htmlElemDesc * XMLCALL
|
||||
htmlTagLookup (const xmlChar *tag);
|
||||
XMLPUBFUN const htmlEntityDesc * XMLCALL
|
||||
htmlEntityLookup(const xmlChar *name);
|
||||
XMLPUBFUN const htmlEntityDesc * XMLCALL
|
||||
htmlEntityValueLookup(unsigned int value);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlIsAutoClosed(htmlDocPtr doc,
|
||||
htmlNodePtr elem);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlAutoCloseTag(htmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
htmlNodePtr elem);
|
||||
XMLPUBFUN const htmlEntityDesc * XMLCALL
|
||||
htmlParseEntityRef(htmlParserCtxtPtr ctxt,
|
||||
const xmlChar **str);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlParseCharRef(htmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlParseElement(htmlParserCtxtPtr ctxt);
|
||||
|
||||
XMLPUBFUN htmlParserCtxtPtr XMLCALL
|
||||
htmlNewParserCtxt(void);
|
||||
|
||||
XMLPUBFUN htmlParserCtxtPtr XMLCALL
|
||||
htmlCreateMemoryParserCtxt(const char *buffer,
|
||||
int size);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlParseDocument(htmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlSAXParseDoc (const xmlChar *cur,
|
||||
const char *encoding,
|
||||
htmlSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlParseDoc (const xmlChar *cur,
|
||||
const char *encoding);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlSAXParseFile(const char *filename,
|
||||
const char *encoding,
|
||||
htmlSAXHandlerPtr sax,
|
||||
void *userData);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlParseFile (const char *filename,
|
||||
const char *encoding);
|
||||
XMLPUBFUN int XMLCALL
|
||||
UTF8ToHtml (unsigned char *out,
|
||||
int *outlen,
|
||||
const unsigned char *in,
|
||||
int *inlen);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlEncodeEntities(unsigned char *out,
|
||||
int *outlen,
|
||||
const unsigned char *in,
|
||||
int *inlen, int quoteChar);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlIsScriptAttribute(const xmlChar *name);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlHandleOmittedElem(int val);
|
||||
|
||||
#ifdef LIBXML_PUSH_ENABLED
|
||||
/**
|
||||
* Interfaces for the Push mode.
|
||||
*/
|
||||
XMLPUBFUN htmlParserCtxtPtr XMLCALL
|
||||
htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
const char *chunk,
|
||||
int size,
|
||||
const char *filename,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlParseChunk (htmlParserCtxtPtr ctxt,
|
||||
const char *chunk,
|
||||
int size,
|
||||
int terminate);
|
||||
#endif /* LIBXML_PUSH_ENABLED */
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlFreeParserCtxt (htmlParserCtxtPtr ctxt);
|
||||
|
||||
/*
|
||||
* New set of simpler/more flexible APIs
|
||||
*/
|
||||
/**
|
||||
* xmlParserOption:
|
||||
*
|
||||
* This is the set of XML parser options that can be passed down
|
||||
* to the xmlReadDoc() and similar calls.
|
||||
*/
|
||||
typedef enum {
|
||||
HTML_PARSE_RECOVER = 1<<0, /* Relaxed parsing */
|
||||
HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */
|
||||
HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */
|
||||
HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */
|
||||
HTML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
|
||||
HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
|
||||
HTML_PARSE_NONET = 1<<11,/* Forbid network access */
|
||||
HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */
|
||||
HTML_PARSE_COMPACT = 1<<16,/* compact small text nodes */
|
||||
HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */
|
||||
} htmlParserOption;
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlCtxtReset (htmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlCtxtUseOptions (htmlParserCtxtPtr ctxt,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlReadDoc (const xmlChar *cur,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlReadFile (const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlReadMemory (const char *buffer,
|
||||
int size,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlReadFd (int fd,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlReadIO (xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *cur,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlCtxtReadFile (xmlParserCtxtPtr ctxt,
|
||||
const char *filename,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
|
||||
const char *buffer,
|
||||
int size,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlCtxtReadFd (xmlParserCtxtPtr ctxt,
|
||||
int fd,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlCtxtReadIO (xmlParserCtxtPtr ctxt,
|
||||
xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
const char *URL,
|
||||
const char *encoding,
|
||||
int options);
|
||||
|
||||
/* NRK/Jan2003: further knowledge of HTML structure
|
||||
*/
|
||||
typedef enum {
|
||||
HTML_NA = 0 , /* something we don't check at all */
|
||||
HTML_INVALID = 0x1 ,
|
||||
HTML_DEPRECATED = 0x2 ,
|
||||
HTML_VALID = 0x4 ,
|
||||
HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */
|
||||
} htmlStatus ;
|
||||
|
||||
/* Using htmlElemDesc rather than name here, to emphasise the fact
|
||||
that otherwise there's a lookup overhead
|
||||
*/
|
||||
XMLPUBFUN htmlStatus XMLCALL htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ;
|
||||
XMLPUBFUN int XMLCALL htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ;
|
||||
XMLPUBFUN htmlStatus XMLCALL htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ;
|
||||
XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ;
|
||||
/**
|
||||
* htmlDefaultSubelement:
|
||||
* @elt: HTML element
|
||||
*
|
||||
* Returns the default subelement for this element
|
||||
*/
|
||||
#define htmlDefaultSubelement(elt) elt->defaultsubelt
|
||||
/**
|
||||
* htmlElementAllowedHereDesc:
|
||||
* @parent: HTML parent element
|
||||
* @elt: HTML element
|
||||
*
|
||||
* Checks whether an HTML element description may be a
|
||||
* direct child of the specified element.
|
||||
*
|
||||
* Returns 1 if allowed; 0 otherwise.
|
||||
*/
|
||||
#define htmlElementAllowedHereDesc(parent,elt) \
|
||||
htmlElementAllowedHere((parent), (elt)->name)
|
||||
/**
|
||||
* htmlRequiredAttrs:
|
||||
* @elt: HTML element
|
||||
*
|
||||
* Returns the attributes required for the specified element.
|
||||
*/
|
||||
#define htmlRequiredAttrs(elt) (elt)->attrs_req
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_HTML_ENABLED */
|
||||
#endif /* __HTML_PARSER_H__ */
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Summary: specific APIs to process HTML tree, especially serialization
|
||||
* Description: this module implements a few function needed to process
|
||||
* tree in an HTML specific way.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __HTML_TREE_H__
|
||||
#define __HTML_TREE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* HTML_TEXT_NODE:
|
||||
*
|
||||
* Macro. A text node in a HTML document is really implemented
|
||||
* the same way as a text node in an XML document.
|
||||
*/
|
||||
#define HTML_TEXT_NODE XML_TEXT_NODE
|
||||
/**
|
||||
* HTML_ENTITY_REF_NODE:
|
||||
*
|
||||
* Macro. An entity reference in a HTML document is really implemented
|
||||
* the same way as an entity reference in an XML document.
|
||||
*/
|
||||
#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE
|
||||
/**
|
||||
* HTML_COMMENT_NODE:
|
||||
*
|
||||
* Macro. A comment in a HTML document is really implemented
|
||||
* the same way as a comment in an XML document.
|
||||
*/
|
||||
#define HTML_COMMENT_NODE XML_COMMENT_NODE
|
||||
/**
|
||||
* HTML_PRESERVE_NODE:
|
||||
*
|
||||
* Macro. A preserved node in a HTML document is really implemented
|
||||
* the same way as a CDATA section in an XML document.
|
||||
*/
|
||||
#define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE
|
||||
/**
|
||||
* HTML_PI_NODE:
|
||||
*
|
||||
* Macro. A processing instruction in a HTML document is really implemented
|
||||
* the same way as a processing instruction in an XML document.
|
||||
*/
|
||||
#define HTML_PI_NODE XML_PI_NODE
|
||||
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlNewDoc (const xmlChar *URI,
|
||||
const xmlChar *ExternalID);
|
||||
XMLPUBFUN htmlDocPtr XMLCALL
|
||||
htmlNewDocNoDtD (const xmlChar *URI,
|
||||
const xmlChar *ExternalID);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
htmlGetMetaEncoding (htmlDocPtr doc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlSetMetaEncoding (htmlDocPtr doc,
|
||||
const xmlChar *encoding);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlDocDumpMemory (xmlDocPtr cur,
|
||||
xmlChar **mem,
|
||||
int *size);
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlDocDumpMemoryFormat (xmlDocPtr cur,
|
||||
xmlChar **mem,
|
||||
int *size,
|
||||
int format);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlDocDump (FILE *f,
|
||||
xmlDocPtr cur);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlSaveFile (const char *filename,
|
||||
xmlDocPtr cur);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlNodeDump (xmlBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlNodeDumpFile (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlNodeDumpFileFormat (FILE *out,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
const char *encoding,
|
||||
int format);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlSaveFileEnc (const char *filename,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlSaveFileFormat (const char *filename,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding,
|
||||
int format);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
const char *encoding,
|
||||
int format);
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding);
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf,
|
||||
xmlDocPtr cur,
|
||||
const char *encoding,
|
||||
int format);
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlNodeDumpOutput (xmlOutputBufferPtr buf,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr cur,
|
||||
const char *encoding);
|
||||
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
htmlIsBooleanAttr (const xmlChar *name);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_HTML_ENABLED */
|
||||
|
||||
#endif /* __HTML_TREE_H__ */
|
||||
|
||||
173
acer-env/lib/python3.10/site-packages/lxml/includes/libxml/SAX.h
Normal file
173
acer-env/lib/python3.10/site-packages/lxml/includes/libxml/SAX.h
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Summary: Old SAX version 1 handler, deprecated
|
||||
* Description: DEPRECATED set of SAX version 1 interfaces used to
|
||||
* build the DOM tree.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_SAX_H__
|
||||
#define __XML_SAX_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xlink.h>
|
||||
|
||||
#ifdef LIBXML_LEGACY_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
getPublicId (void *ctx);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
getSystemId (void *ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
setDocumentLocator (void *ctx,
|
||||
xmlSAXLocatorPtr loc);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
getLineNumber (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
getColumnNumber (void *ctx);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
isStandalone (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
hasInternalSubset (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
hasExternalSubset (void *ctx);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
internalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
XMLPUBFUN void XMLCALL
|
||||
externalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
getEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
getParameterEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
resolveEntity (void *ctx,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
entityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
xmlChar *content);
|
||||
XMLPUBFUN void XMLCALL
|
||||
attributeDecl (void *ctx,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *fullname,
|
||||
int type,
|
||||
int def,
|
||||
const xmlChar *defaultValue,
|
||||
xmlEnumerationPtr tree);
|
||||
XMLPUBFUN void XMLCALL
|
||||
elementDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
xmlElementContentPtr content);
|
||||
XMLPUBFUN void XMLCALL
|
||||
notationDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
XMLPUBFUN void XMLCALL
|
||||
unparsedEntityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
const xmlChar *notationName);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
startDocument (void *ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
endDocument (void *ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
attribute (void *ctx,
|
||||
const xmlChar *fullname,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN void XMLCALL
|
||||
startElement (void *ctx,
|
||||
const xmlChar *fullname,
|
||||
const xmlChar **atts);
|
||||
XMLPUBFUN void XMLCALL
|
||||
endElement (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN void XMLCALL
|
||||
reference (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN void XMLCALL
|
||||
characters (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
XMLPUBFUN void XMLCALL
|
||||
ignorableWhitespace (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
XMLPUBFUN void XMLCALL
|
||||
processingInstruction (void *ctx,
|
||||
const xmlChar *target,
|
||||
const xmlChar *data);
|
||||
XMLPUBFUN void XMLCALL
|
||||
globalNamespace (void *ctx,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
XMLPUBFUN void XMLCALL
|
||||
setNamespace (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlNsPtr XMLCALL
|
||||
getNamespace (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
checkNamespace (void *ctx,
|
||||
xmlChar *nameSpace);
|
||||
XMLPUBFUN void XMLCALL
|
||||
namespaceDecl (void *ctx,
|
||||
const xmlChar *href,
|
||||
const xmlChar *prefix);
|
||||
XMLPUBFUN void XMLCALL
|
||||
comment (void *ctx,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN void XMLCALL
|
||||
cdataBlock (void *ctx,
|
||||
const xmlChar *value,
|
||||
int len);
|
||||
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr,
|
||||
int warning);
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
|
||||
#endif
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
|
||||
#endif
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_LEGACY_ENABLED */
|
||||
|
||||
#endif /* __XML_SAX_H__ */
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Summary: SAX2 parser interface used to build the DOM tree
|
||||
* Description: those are the default SAX2 interfaces used by
|
||||
* the library when building DOM tree.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_SAX2_H__
|
||||
#define __XML_SAX2_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xlink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlSAX2GetPublicId (void *ctx);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlSAX2GetSystemId (void *ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2SetDocumentLocator (void *ctx,
|
||||
xmlSAXLocatorPtr loc);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSAX2GetLineNumber (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSAX2GetColumnNumber (void *ctx);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSAX2IsStandalone (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSAX2HasInternalSubset (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSAX2HasExternalSubset (void *ctx);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2InternalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2ExternalSubset (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlSAX2GetEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlSAX2GetParameterEntity (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
xmlSAX2ResolveEntity (void *ctx,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2EntityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
xmlChar *content);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2AttributeDecl (void *ctx,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *fullname,
|
||||
int type,
|
||||
int def,
|
||||
const xmlChar *defaultValue,
|
||||
xmlEnumerationPtr tree);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2ElementDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
xmlElementContentPtr content);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2NotationDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2UnparsedEntityDecl (void *ctx,
|
||||
const xmlChar *name,
|
||||
const xmlChar *publicId,
|
||||
const xmlChar *systemId,
|
||||
const xmlChar *notationName);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2StartDocument (void *ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2EndDocument (void *ctx);
|
||||
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
|
||||
defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || \
|
||||
defined(LIBXML_LEGACY_ENABLED)
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2StartElement (void *ctx,
|
||||
const xmlChar *fullname,
|
||||
const xmlChar **atts);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2EndElement (void *ctx,
|
||||
const xmlChar *name);
|
||||
#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2StartElementNs (void *ctx,
|
||||
const xmlChar *localname,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *URI,
|
||||
int nb_namespaces,
|
||||
const xmlChar **namespaces,
|
||||
int nb_attributes,
|
||||
int nb_defaulted,
|
||||
const xmlChar **attributes);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2EndElementNs (void *ctx,
|
||||
const xmlChar *localname,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *URI);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2Reference (void *ctx,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2Characters (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2IgnorableWhitespace (void *ctx,
|
||||
const xmlChar *ch,
|
||||
int len);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2ProcessingInstruction (void *ctx,
|
||||
const xmlChar *target,
|
||||
const xmlChar *data);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2Comment (void *ctx,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2CDataBlock (void *ctx,
|
||||
const xmlChar *value,
|
||||
int len);
|
||||
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSAXDefaultVersion (int version);
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSAXVersion (xmlSAXHandler *hdlr,
|
||||
int version);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr,
|
||||
int warning);
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
|
||||
XMLPUBFUN void XMLCALL
|
||||
htmlDefaultSAXHandlerInit (void);
|
||||
#endif
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr);
|
||||
XMLPUBFUN void XMLCALL
|
||||
docbDefaultSAXHandlerInit (void);
|
||||
#endif
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDefaultSAXHandlerInit (void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_SAX2_H__ */
|
||||
Binary file not shown.
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Summary: Provide Canonical XML and Exclusive XML Canonicalization
|
||||
* Description: the c14n modules provides a
|
||||
*
|
||||
* "Canonical XML" implementation
|
||||
* http://www.w3.org/TR/xml-c14n
|
||||
*
|
||||
* and an
|
||||
*
|
||||
* "Exclusive XML Canonicalization" implementation
|
||||
* http://www.w3.org/TR/xml-exc-c14n
|
||||
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Aleksey Sanin <aleksey@aleksey.com>
|
||||
*/
|
||||
#ifndef __XML_C14N_H__
|
||||
#define __XML_C14N_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_C14N_ENABLED
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* XML Canonicalization
|
||||
* http://www.w3.org/TR/xml-c14n
|
||||
*
|
||||
* Exclusive XML Canonicalization
|
||||
* http://www.w3.org/TR/xml-exc-c14n
|
||||
*
|
||||
* Canonical form of an XML document could be created if and only if
|
||||
* a) default attributes (if any) are added to all nodes
|
||||
* b) all character and parsed entity references are resolved
|
||||
* In order to achieve this in libxml2 the document MUST be loaded with
|
||||
* following global settings:
|
||||
*
|
||||
* xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
|
||||
* xmlSubstituteEntitiesDefault(1);
|
||||
*
|
||||
* or corresponding parser context setting:
|
||||
* xmlParserCtxtPtr ctxt;
|
||||
*
|
||||
* ...
|
||||
* ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
|
||||
* ctxt->replaceEntities = 1;
|
||||
* ...
|
||||
*/
|
||||
|
||||
/*
|
||||
* xmlC14NMode:
|
||||
*
|
||||
* Predefined values for C14N modes
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
XML_C14N_1_0 = 0, /* Original C14N 1.0 spec */
|
||||
XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
|
||||
XML_C14N_1_1 = 2 /* C14N 1.1 spec */
|
||||
} xmlC14NMode;
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlC14NDocSaveTo (xmlDocPtr doc,
|
||||
xmlNodeSetPtr nodes,
|
||||
int mode, /* a xmlC14NMode */
|
||||
xmlChar **inclusive_ns_prefixes,
|
||||
int with_comments,
|
||||
xmlOutputBufferPtr buf);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlC14NDocDumpMemory (xmlDocPtr doc,
|
||||
xmlNodeSetPtr nodes,
|
||||
int mode, /* a xmlC14NMode */
|
||||
xmlChar **inclusive_ns_prefixes,
|
||||
int with_comments,
|
||||
xmlChar **doc_txt_ptr);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlC14NDocSave (xmlDocPtr doc,
|
||||
xmlNodeSetPtr nodes,
|
||||
int mode, /* a xmlC14NMode */
|
||||
xmlChar **inclusive_ns_prefixes,
|
||||
int with_comments,
|
||||
const char* filename,
|
||||
int compression);
|
||||
|
||||
|
||||
/**
|
||||
* This is the core C14N function
|
||||
*/
|
||||
/**
|
||||
* xmlC14NIsVisibleCallback:
|
||||
* @user_data: user data
|
||||
* @node: the current node
|
||||
* @parent: the parent node
|
||||
*
|
||||
* Signature for a C14N callback on visible nodes
|
||||
*
|
||||
* Returns 1 if the node should be included
|
||||
*/
|
||||
typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr parent);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlC14NExecute (xmlDocPtr doc,
|
||||
xmlC14NIsVisibleCallback is_visible_callback,
|
||||
void* user_data,
|
||||
int mode, /* a xmlC14NMode */
|
||||
xmlChar **inclusive_ns_prefixes,
|
||||
int with_comments,
|
||||
xmlOutputBufferPtr buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
#endif /* LIBXML_C14N_ENABLED */
|
||||
#endif /* __XML_C14N_H__ */
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* Summary: interfaces to the Catalog handling system
|
||||
* Description: the catalog module implements the support for
|
||||
* XML Catalogs and SGML catalogs
|
||||
*
|
||||
* SGML Open Technical Resolution TR9401:1997.
|
||||
* http://www.jclark.com/sp/catalog.htm
|
||||
*
|
||||
* XML Catalogs Working Draft 06 August 2001
|
||||
* http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_CATALOG_H__
|
||||
#define __XML_CATALOG_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_CATALOG_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* XML_CATALOGS_NAMESPACE:
|
||||
*
|
||||
* The namespace for the XML Catalogs elements.
|
||||
*/
|
||||
#define XML_CATALOGS_NAMESPACE \
|
||||
(const xmlChar *) "urn:oasis:names:tc:entity:xmlns:xml:catalog"
|
||||
/**
|
||||
* XML_CATALOG_PI:
|
||||
*
|
||||
* The specific XML Catalog Processing Instruction name.
|
||||
*/
|
||||
#define XML_CATALOG_PI \
|
||||
(const xmlChar *) "oasis-xml-catalog"
|
||||
|
||||
/*
|
||||
* The API is voluntarily limited to general cataloging.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_CATA_PREFER_NONE = 0,
|
||||
XML_CATA_PREFER_PUBLIC = 1,
|
||||
XML_CATA_PREFER_SYSTEM
|
||||
} xmlCatalogPrefer;
|
||||
|
||||
typedef enum {
|
||||
XML_CATA_ALLOW_NONE = 0,
|
||||
XML_CATA_ALLOW_GLOBAL = 1,
|
||||
XML_CATA_ALLOW_DOCUMENT = 2,
|
||||
XML_CATA_ALLOW_ALL = 3
|
||||
} xmlCatalogAllow;
|
||||
|
||||
typedef struct _xmlCatalog xmlCatalog;
|
||||
typedef xmlCatalog *xmlCatalogPtr;
|
||||
|
||||
/*
|
||||
* Operations on a given catalog.
|
||||
*/
|
||||
XMLPUBFUN xmlCatalogPtr XMLCALL
|
||||
xmlNewCatalog (int sgml);
|
||||
XMLPUBFUN xmlCatalogPtr XMLCALL
|
||||
xmlLoadACatalog (const char *filename);
|
||||
XMLPUBFUN xmlCatalogPtr XMLCALL
|
||||
xmlLoadSGMLSuperCatalog (const char *filename);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlConvertSGMLCatalog (xmlCatalogPtr catal);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlACatalogAdd (xmlCatalogPtr catal,
|
||||
const xmlChar *type,
|
||||
const xmlChar *orig,
|
||||
const xmlChar *replace);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlACatalogRemove (xmlCatalogPtr catal,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlACatalogResolve (xmlCatalogPtr catal,
|
||||
const xmlChar *pubID,
|
||||
const xmlChar *sysID);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlACatalogResolveSystem(xmlCatalogPtr catal,
|
||||
const xmlChar *sysID);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlACatalogResolvePublic(xmlCatalogPtr catal,
|
||||
const xmlChar *pubID);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlACatalogResolveURI (xmlCatalogPtr catal,
|
||||
const xmlChar *URI);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlACatalogDump (xmlCatalogPtr catal,
|
||||
FILE *out);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeCatalog (xmlCatalogPtr catal);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCatalogIsEmpty (xmlCatalogPtr catal);
|
||||
|
||||
/*
|
||||
* Global operations.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlInitializeCatalog (void);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlLoadCatalog (const char *filename);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlLoadCatalogs (const char *paths);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCatalogCleanup (void);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCatalogDump (FILE *out);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlCatalogResolve (const xmlChar *pubID,
|
||||
const xmlChar *sysID);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlCatalogResolveSystem (const xmlChar *sysID);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlCatalogResolvePublic (const xmlChar *pubID);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlCatalogResolveURI (const xmlChar *URI);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCatalogAdd (const xmlChar *type,
|
||||
const xmlChar *orig,
|
||||
const xmlChar *replace);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCatalogRemove (const xmlChar *value);
|
||||
XMLPUBFUN xmlDocPtr XMLCALL
|
||||
xmlParseCatalogFile (const char *filename);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCatalogConvert (void);
|
||||
|
||||
/*
|
||||
* Strictly minimal interfaces for per-document catalogs used
|
||||
* by the parser.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCatalogFreeLocal (void *catalogs);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlCatalogAddLocal (void *catalogs,
|
||||
const xmlChar *URL);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlCatalogLocalResolve (void *catalogs,
|
||||
const xmlChar *pubID,
|
||||
const xmlChar *sysID);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlCatalogLocalResolveURI(void *catalogs,
|
||||
const xmlChar *URI);
|
||||
/*
|
||||
* Preference settings.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCatalogSetDebug (int level);
|
||||
XMLPUBFUN xmlCatalogPrefer XMLCALL
|
||||
xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCatalogSetDefaults (xmlCatalogAllow allow);
|
||||
XMLPUBFUN xmlCatalogAllow XMLCALL
|
||||
xmlCatalogGetDefaults (void);
|
||||
|
||||
|
||||
/* DEPRECATED interfaces */
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlCatalogGetSystem (const xmlChar *sysID);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlCatalogGetPublic (const xmlChar *pubID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* LIBXML_CATALOG_ENABLED */
|
||||
#endif /* __XML_CATALOG_H__ */
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Summary: Unicode character range checking
|
||||
* Description: this module exports interfaces for the character
|
||||
* range validation APIs
|
||||
*
|
||||
* This file is automatically generated from the cvs source
|
||||
* definition files using the genChRanges.py Python script
|
||||
*
|
||||
* Generation date: Mon Mar 27 11:09:48 2006
|
||||
* Sources: chvalid.def
|
||||
* Author: William Brack <wbrack@mmm.com.hk>
|
||||
*/
|
||||
|
||||
#ifndef __XML_CHVALID_H__
|
||||
#define __XML_CHVALID_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define our typedefs and structures
|
||||
*
|
||||
*/
|
||||
typedef struct _xmlChSRange xmlChSRange;
|
||||
typedef xmlChSRange *xmlChSRangePtr;
|
||||
struct _xmlChSRange {
|
||||
unsigned short low;
|
||||
unsigned short high;
|
||||
};
|
||||
|
||||
typedef struct _xmlChLRange xmlChLRange;
|
||||
typedef xmlChLRange *xmlChLRangePtr;
|
||||
struct _xmlChLRange {
|
||||
unsigned int low;
|
||||
unsigned int high;
|
||||
};
|
||||
|
||||
typedef struct _xmlChRangeGroup xmlChRangeGroup;
|
||||
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
|
||||
struct _xmlChRangeGroup {
|
||||
int nbShortRange;
|
||||
int nbLongRange;
|
||||
const xmlChSRange *shortRange; /* points to an array of ranges */
|
||||
const xmlChLRange *longRange;
|
||||
};
|
||||
|
||||
/**
|
||||
* Range checking routine
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCharInRange(unsigned int val, const xmlChRangeGroup *group);
|
||||
|
||||
|
||||
/**
|
||||
* xmlIsBaseChar_ch:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsBaseChar_ch(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \
|
||||
((0x61 <= (c)) && ((c) <= 0x7a)) || \
|
||||
((0xc0 <= (c)) && ((c) <= 0xd6)) || \
|
||||
((0xd8 <= (c)) && ((c) <= 0xf6)) || \
|
||||
(0xf8 <= (c)))
|
||||
|
||||
/**
|
||||
* xmlIsBaseCharQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsBaseCharQ(c) (((c) < 0x100) ? \
|
||||
xmlIsBaseChar_ch((c)) : \
|
||||
xmlCharInRange((c), &xmlIsBaseCharGroup))
|
||||
|
||||
XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup;
|
||||
|
||||
/**
|
||||
* xmlIsBlank_ch:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsBlank_ch(c) (((c) == 0x20) || \
|
||||
((0x9 <= (c)) && ((c) <= 0xa)) || \
|
||||
((c) == 0xd))
|
||||
|
||||
/**
|
||||
* xmlIsBlankQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsBlankQ(c) (((c) < 0x100) ? \
|
||||
xmlIsBlank_ch((c)) : 0)
|
||||
|
||||
|
||||
/**
|
||||
* xmlIsChar_ch:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsChar_ch(c) (((0x9 <= (c)) && ((c) <= 0xa)) || \
|
||||
((c) == 0xd) || \
|
||||
(0x20 <= (c)))
|
||||
|
||||
/**
|
||||
* xmlIsCharQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsCharQ(c) (((c) < 0x100) ? \
|
||||
xmlIsChar_ch((c)) :\
|
||||
(((0x100 <= (c)) && ((c) <= 0xd7ff)) || \
|
||||
((0xe000 <= (c)) && ((c) <= 0xfffd)) || \
|
||||
((0x10000 <= (c)) && ((c) <= 0x10ffff))))
|
||||
|
||||
XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup;
|
||||
|
||||
/**
|
||||
* xmlIsCombiningQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsCombiningQ(c) (((c) < 0x100) ? \
|
||||
0 : \
|
||||
xmlCharInRange((c), &xmlIsCombiningGroup))
|
||||
|
||||
XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup;
|
||||
|
||||
/**
|
||||
* xmlIsDigit_ch:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsDigit_ch(c) (((0x30 <= (c)) && ((c) <= 0x39)))
|
||||
|
||||
/**
|
||||
* xmlIsDigitQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsDigitQ(c) (((c) < 0x100) ? \
|
||||
xmlIsDigit_ch((c)) : \
|
||||
xmlCharInRange((c), &xmlIsDigitGroup))
|
||||
|
||||
XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup;
|
||||
|
||||
/**
|
||||
* xmlIsExtender_ch:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsExtender_ch(c) (((c) == 0xb7))
|
||||
|
||||
/**
|
||||
* xmlIsExtenderQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsExtenderQ(c) (((c) < 0x100) ? \
|
||||
xmlIsExtender_ch((c)) : \
|
||||
xmlCharInRange((c), &xmlIsExtenderGroup))
|
||||
|
||||
XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup;
|
||||
|
||||
/**
|
||||
* xmlIsIdeographicQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsIdeographicQ(c) (((c) < 0x100) ? \
|
||||
0 :\
|
||||
(((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \
|
||||
((c) == 0x3007) || \
|
||||
((0x3021 <= (c)) && ((c) <= 0x3029))))
|
||||
|
||||
XMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup;
|
||||
XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];
|
||||
|
||||
/**
|
||||
* xmlIsPubidChar_ch:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsPubidChar_ch(c) (xmlIsPubidChar_tab[(c)])
|
||||
|
||||
/**
|
||||
* xmlIsPubidCharQ:
|
||||
* @c: char to validate
|
||||
*
|
||||
* Automatically generated by genChRanges.py
|
||||
*/
|
||||
#define xmlIsPubidCharQ(c) (((c) < 0x100) ? \
|
||||
xmlIsPubidChar_ch((c)) : 0)
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsBaseChar(unsigned int ch);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsBlank(unsigned int ch);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsChar(unsigned int ch);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsCombining(unsigned int ch);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsDigit(unsigned int ch);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsExtender(unsigned int ch);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsIdeographic(unsigned int ch);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsPubidChar(unsigned int ch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_CHVALID_H__ */
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Summary: Tree debugging APIs
|
||||
* Description: Interfaces to a set of routines used for debugging the tree
|
||||
* produced by the XML parser.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG_XML__
|
||||
#define __DEBUG_XML__
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The standard Dump routines.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpString (FILE *output,
|
||||
const xmlChar *str);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpAttr (FILE *output,
|
||||
xmlAttrPtr attr,
|
||||
int depth);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpAttrList (FILE *output,
|
||||
xmlAttrPtr attr,
|
||||
int depth);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpOneNode (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpNode (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpNodeList (FILE *output,
|
||||
xmlNodePtr node,
|
||||
int depth);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpDocumentHead(FILE *output,
|
||||
xmlDocPtr doc);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpDocument (FILE *output,
|
||||
xmlDocPtr doc);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpDTD (FILE *output,
|
||||
xmlDtdPtr dtd);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDebugDumpEntities (FILE *output,
|
||||
xmlDocPtr doc);
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* Checking routines *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlDebugCheckDocument (FILE * output,
|
||||
xmlDocPtr doc);
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* XML shell helpers *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlLsOneNode (FILE *output, xmlNodePtr node);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlLsCountNode (xmlNodePtr node);
|
||||
|
||||
XMLPUBFUN const char * XMLCALL
|
||||
xmlBoolToText (int boolval);
|
||||
|
||||
/****************************************************************
|
||||
* *
|
||||
* The XML shell related structures and functions *
|
||||
* *
|
||||
****************************************************************/
|
||||
|
||||
#ifdef LIBXML_XPATH_ENABLED
|
||||
/**
|
||||
* xmlShellReadlineFunc:
|
||||
* @prompt: a string prompt
|
||||
*
|
||||
* This is a generic signature for the XML shell input function.
|
||||
*
|
||||
* Returns a string which will be freed by the Shell.
|
||||
*/
|
||||
typedef char * (* xmlShellReadlineFunc)(char *prompt);
|
||||
|
||||
/**
|
||||
* xmlShellCtxt:
|
||||
*
|
||||
* A debugging shell context.
|
||||
* TODO: add the defined function tables.
|
||||
*/
|
||||
typedef struct _xmlShellCtxt xmlShellCtxt;
|
||||
typedef xmlShellCtxt *xmlShellCtxtPtr;
|
||||
struct _xmlShellCtxt {
|
||||
char *filename;
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr node;
|
||||
xmlXPathContextPtr pctxt;
|
||||
int loaded;
|
||||
FILE *output;
|
||||
xmlShellReadlineFunc input;
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlShellCmd:
|
||||
* @ctxt: a shell context
|
||||
* @arg: a string argument
|
||||
* @node: a first node
|
||||
* @node2: a second node
|
||||
*
|
||||
* This is a generic signature for the XML shell functions.
|
||||
*
|
||||
* Returns an int, negative returns indicating errors.
|
||||
*/
|
||||
typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlShellPrintXPathError (int errorType,
|
||||
const char *arg);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlShellPrintXPathResult(xmlXPathObjectPtr list);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellList (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellBase (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellDir (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellLoad (xmlShellCtxtPtr ctxt,
|
||||
char *filename,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlShellPrintNode (xmlNodePtr node);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellCat (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellWrite (xmlShellCtxtPtr ctxt,
|
||||
char *filename,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellSave (xmlShellCtxtPtr ctxt,
|
||||
char *filename,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellValidate (xmlShellCtxtPtr ctxt,
|
||||
char *dtd,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellDu (xmlShellCtxtPtr ctxt,
|
||||
char *arg,
|
||||
xmlNodePtr tree,
|
||||
xmlNodePtr node2);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlShellPwd (xmlShellCtxtPtr ctxt,
|
||||
char *buffer,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr node2);
|
||||
|
||||
/*
|
||||
* The Shell interface.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlShell (xmlDocPtr doc,
|
||||
char *filename,
|
||||
xmlShellReadlineFunc input,
|
||||
FILE *output);
|
||||
|
||||
#endif /* LIBXML_XPATH_ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_DEBUG_ENABLED */
|
||||
#endif /* __DEBUG_XML__ */
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Summary: string dictionary
|
||||
* Description: dictionary of reusable strings, just used to avoid allocation
|
||||
* and freeing operations.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_DICT_H__
|
||||
#define __XML_DICT_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The dictionary.
|
||||
*/
|
||||
typedef struct _xmlDict xmlDict;
|
||||
typedef xmlDict *xmlDictPtr;
|
||||
|
||||
/*
|
||||
* Initializer
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL xmlInitializeDict(void);
|
||||
|
||||
/*
|
||||
* Constructor and destructor.
|
||||
*/
|
||||
XMLPUBFUN xmlDictPtr XMLCALL
|
||||
xmlDictCreate (void);
|
||||
XMLPUBFUN size_t XMLCALL
|
||||
xmlDictSetLimit (xmlDictPtr dict,
|
||||
size_t limit);
|
||||
XMLPUBFUN size_t XMLCALL
|
||||
xmlDictGetUsage (xmlDictPtr dict);
|
||||
XMLPUBFUN xmlDictPtr XMLCALL
|
||||
xmlDictCreateSub(xmlDictPtr sub);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlDictReference(xmlDictPtr dict);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDictFree (xmlDictPtr dict);
|
||||
|
||||
/*
|
||||
* Lookup of entry in the dictionary.
|
||||
*/
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlDictLookup (xmlDictPtr dict,
|
||||
const xmlChar *name,
|
||||
int len);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlDictExists (xmlDictPtr dict,
|
||||
const xmlChar *name,
|
||||
int len);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlDictQLookup (xmlDictPtr dict,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlDictOwns (xmlDictPtr dict,
|
||||
const xmlChar *str);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlDictSize (xmlDictPtr dict);
|
||||
|
||||
/*
|
||||
* Cleanup function
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDictCleanup (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_DICT_H__ */
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Summary: interface for the encoding conversion functions
|
||||
* Description: interface for the encoding conversion functions needed for
|
||||
* XML basic encoding and iconv() support.
|
||||
*
|
||||
* Related specs are
|
||||
* rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies
|
||||
* [ISO-10646] UTF-8 and UTF-16 in Annexes
|
||||
* [ISO-8859-1] ISO Latin-1 characters codes.
|
||||
* [UNICODE] The Unicode Consortium, "The Unicode Standard --
|
||||
* Worldwide Character Encoding -- Version 1.0", Addison-
|
||||
* Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is
|
||||
* described in Unicode Technical Report #4.
|
||||
* [US-ASCII] Coded Character Set--7-bit American Standard Code for
|
||||
* Information Interchange, ANSI X3.4-1986.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_CHAR_ENCODING_H__
|
||||
#define __XML_CHAR_ENCODING_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_ICONV_ENABLED
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
#ifdef LIBXML_ICU_ENABLED
|
||||
#include <unicode/ucnv.h>
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* xmlCharEncoding:
|
||||
*
|
||||
* Predefined values for some standard encodings.
|
||||
* Libxml does not do beforehand translation on UTF8 and ISOLatinX.
|
||||
* It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default.
|
||||
*
|
||||
* Anything else would have to be translated to UTF8 before being
|
||||
* given to the parser itself. The BOM for UTF16 and the encoding
|
||||
* declaration are looked at and a converter is looked for at that
|
||||
* point. If not found the parser stops here as asked by the XML REC. A
|
||||
* converter can be registered by the user using xmlRegisterCharEncodingHandler
|
||||
* but the current form doesn't allow stateful transcoding (a serious
|
||||
* problem agreed !). If iconv has been found it will be used
|
||||
* automatically and allow stateful transcoding, the simplest is then
|
||||
* to be sure to enable iconv and to provide iconv libs for the encoding
|
||||
* support needed.
|
||||
*
|
||||
* Note that the generic "UTF-16" is not a predefined value. Instead, only
|
||||
* the specific UTF-16LE and UTF-16BE are present.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
|
||||
XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
|
||||
XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
|
||||
XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
|
||||
XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
|
||||
XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
|
||||
XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
|
||||
XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
|
||||
XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
|
||||
XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
|
||||
XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
|
||||
XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
|
||||
XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
|
||||
XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
|
||||
XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
|
||||
XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
|
||||
XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
|
||||
XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
|
||||
XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
|
||||
XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
|
||||
XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
|
||||
XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
|
||||
XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
|
||||
XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
|
||||
} xmlCharEncoding;
|
||||
|
||||
/**
|
||||
* xmlCharEncodingInputFunc:
|
||||
* @out: a pointer to an array of bytes to store the UTF-8 result
|
||||
* @outlen: the length of @out
|
||||
* @in: a pointer to an array of chars in the original encoding
|
||||
* @inlen: the length of @in
|
||||
*
|
||||
* Take a block of chars in the original encoding and try to convert
|
||||
* it to an UTF-8 block of chars out.
|
||||
*
|
||||
* Returns the number of bytes written, -1 if lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
* The value of @inlen after return is the number of octets consumed
|
||||
* if the return value is positive, else unpredictiable.
|
||||
* The value of @outlen after return is the number of octets consumed.
|
||||
*/
|
||||
typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
|
||||
const unsigned char *in, int *inlen);
|
||||
|
||||
|
||||
/**
|
||||
* xmlCharEncodingOutputFunc:
|
||||
* @out: a pointer to an array of bytes to store the result
|
||||
* @outlen: the length of @out
|
||||
* @in: a pointer to an array of UTF-8 chars
|
||||
* @inlen: the length of @in
|
||||
*
|
||||
* Take a block of UTF-8 chars in and try to convert it to another
|
||||
* encoding.
|
||||
* Note: a first call designed to produce heading info is called with
|
||||
* in = NULL. If stateful this should also initialize the encoder state.
|
||||
*
|
||||
* Returns the number of bytes written, -1 if lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
* The value of @inlen after return is the number of octets consumed
|
||||
* if the return value is positive, else unpredictiable.
|
||||
* The value of @outlen after return is the number of octets produced.
|
||||
*/
|
||||
typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
|
||||
const unsigned char *in, int *inlen);
|
||||
|
||||
|
||||
/*
|
||||
* Block defining the handlers for non UTF-8 encodings.
|
||||
* If iconv is supported, there are two extra fields.
|
||||
*/
|
||||
#ifdef LIBXML_ICU_ENABLED
|
||||
/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
|
||||
#define ICU_PIVOT_BUF_SIZE 1024
|
||||
struct _uconv_t {
|
||||
UConverter *uconv; /* for conversion between an encoding and UTF-16 */
|
||||
UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
|
||||
UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
|
||||
UChar *pivot_source;
|
||||
UChar *pivot_target;
|
||||
};
|
||||
typedef struct _uconv_t uconv_t;
|
||||
#endif
|
||||
|
||||
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
|
||||
typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
|
||||
struct _xmlCharEncodingHandler {
|
||||
char *name;
|
||||
xmlCharEncodingInputFunc input;
|
||||
xmlCharEncodingOutputFunc output;
|
||||
#ifdef LIBXML_ICONV_ENABLED
|
||||
iconv_t iconv_in;
|
||||
iconv_t iconv_out;
|
||||
#endif /* LIBXML_ICONV_ENABLED */
|
||||
#ifdef LIBXML_ICU_ENABLED
|
||||
uconv_t *uconv_in;
|
||||
uconv_t *uconv_out;
|
||||
#endif /* LIBXML_ICU_ENABLED */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/tree.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Interfaces for encoding handlers.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlInitCharEncodingHandlers (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCleanupCharEncodingHandlers (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
|
||||
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
|
||||
xmlGetCharEncodingHandler (xmlCharEncoding enc);
|
||||
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
|
||||
xmlFindCharEncodingHandler (const char *name);
|
||||
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
|
||||
xmlNewCharEncodingHandler (const char *name,
|
||||
xmlCharEncodingInputFunc input,
|
||||
xmlCharEncodingOutputFunc output);
|
||||
|
||||
/*
|
||||
* Interfaces for encoding names and aliases.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlAddEncodingAlias (const char *name,
|
||||
const char *alias);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlDelEncodingAlias (const char *alias);
|
||||
XMLPUBFUN const char * XMLCALL
|
||||
xmlGetEncodingAlias (const char *alias);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCleanupEncodingAliases (void);
|
||||
XMLPUBFUN xmlCharEncoding XMLCALL
|
||||
xmlParseCharEncoding (const char *name);
|
||||
XMLPUBFUN const char * XMLCALL
|
||||
xmlGetCharEncodingName (xmlCharEncoding enc);
|
||||
|
||||
/*
|
||||
* Interfaces directly used by the parsers.
|
||||
*/
|
||||
XMLPUBFUN xmlCharEncoding XMLCALL
|
||||
xmlDetectCharEncoding (const unsigned char *in,
|
||||
int len);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCharEncInFunc (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
|
||||
xmlBufferPtr out,
|
||||
xmlBufferPtr in);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
|
||||
|
||||
/*
|
||||
* Export a few useful functions
|
||||
*/
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN int XMLCALL
|
||||
UTF8Toisolat1 (unsigned char *out,
|
||||
int *outlen,
|
||||
const unsigned char *in,
|
||||
int *inlen);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
XMLPUBFUN int XMLCALL
|
||||
isolat1ToUTF8 (unsigned char *out,
|
||||
int *outlen,
|
||||
const unsigned char *in,
|
||||
int *inlen);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_CHAR_ENCODING_H__ */
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Summary: interface for the XML entities handling
|
||||
* Description: this module provides some of the entity API needed
|
||||
* for the parser and applications.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_ENTITIES_H__
|
||||
#define __XML_ENTITIES_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The different valid entity types.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_INTERNAL_GENERAL_ENTITY = 1,
|
||||
XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
|
||||
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
|
||||
XML_INTERNAL_PARAMETER_ENTITY = 4,
|
||||
XML_EXTERNAL_PARAMETER_ENTITY = 5,
|
||||
XML_INTERNAL_PREDEFINED_ENTITY = 6
|
||||
} xmlEntityType;
|
||||
|
||||
/*
|
||||
* An unit of storage for an entity, contains the string, the value
|
||||
* and the linkind data needed for the linking in the hash table.
|
||||
*/
|
||||
|
||||
struct _xmlEntity {
|
||||
void *_private; /* application data */
|
||||
xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
|
||||
const xmlChar *name; /* Entity name */
|
||||
struct _xmlNode *children; /* First child link */
|
||||
struct _xmlNode *last; /* Last child link */
|
||||
struct _xmlDtd *parent; /* -> DTD */
|
||||
struct _xmlNode *next; /* next sibling link */
|
||||
struct _xmlNode *prev; /* previous sibling link */
|
||||
struct _xmlDoc *doc; /* the containing document */
|
||||
|
||||
xmlChar *orig; /* content without ref substitution */
|
||||
xmlChar *content; /* content or ndata if unparsed */
|
||||
int length; /* the content length */
|
||||
xmlEntityType etype; /* The entity type */
|
||||
const xmlChar *ExternalID; /* External identifier for PUBLIC */
|
||||
const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
|
||||
|
||||
struct _xmlEntity *nexte; /* unused */
|
||||
const xmlChar *URI; /* the full URI as computed */
|
||||
int owner; /* does the entity own the childrens */
|
||||
int checked; /* was the entity content checked */
|
||||
/* this is also used to count entities
|
||||
* references done from that entity
|
||||
* and if it contains '<' */
|
||||
};
|
||||
|
||||
/*
|
||||
* All entities are stored in an hash table.
|
||||
* There is 2 separate hash tables for global and parameter entities.
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlEntitiesTable;
|
||||
typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
||||
|
||||
/*
|
||||
* External functions:
|
||||
*/
|
||||
|
||||
#ifdef LIBXML_LEGACY_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlInitializePredefinedEntities (void);
|
||||
#endif /* LIBXML_LEGACY_ENABLED */
|
||||
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlNewEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlAddDocEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlAddDtdEntity (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
int type,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID,
|
||||
const xmlChar *content);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlGetPredefinedEntity (const xmlChar *name);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlGetDocEntity (const xmlDoc *doc,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlGetDtdEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlGetParameterEntity (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
#ifdef LIBXML_LEGACY_ENABLED
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlEncodeEntities (xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
#endif /* LIBXML_LEGACY_ENABLED */
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlEncodeEntitiesReentrant(xmlDocPtr doc,
|
||||
const xmlChar *input);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlEncodeSpecialChars (const xmlDoc *doc,
|
||||
const xmlChar *input);
|
||||
XMLPUBFUN xmlEntitiesTablePtr XMLCALL
|
||||
xmlCreateEntitiesTable (void);
|
||||
#ifdef LIBXML_TREE_ENABLED
|
||||
XMLPUBFUN xmlEntitiesTablePtr XMLCALL
|
||||
xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
||||
#endif /* LIBXML_TREE_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpEntitiesTable (xmlBufferPtr buf,
|
||||
xmlEntitiesTablePtr table);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpEntityDecl (xmlBufferPtr buf,
|
||||
xmlEntityPtr ent);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
#ifdef LIBXML_LEGACY_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCleanupPredefinedEntities(void);
|
||||
#endif /* LIBXML_LEGACY_ENABLED */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
# endif /* __XML_ENTITIES_H__ */
|
||||
@@ -0,0 +1,508 @@
|
||||
/*
|
||||
* Summary: interface for all global variables of the library
|
||||
* Description: all the global variables and thread handling for
|
||||
* those variables is handled by this module.
|
||||
*
|
||||
* The bottom of this file is automatically generated by build_glob.py
|
||||
* based on the description file global.data
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Gary Pennington <Gary.Pennington@uk.sun.com>, Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_GLOBALS_H
|
||||
#define __XML_GLOBALS_H
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/SAX2.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
XMLPUBFUN void XMLCALL xmlInitGlobals(void);
|
||||
XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
|
||||
|
||||
/**
|
||||
* xmlParserInputBufferCreateFilenameFunc:
|
||||
* @URI: the URI to read from
|
||||
* @enc: the requested source encoding
|
||||
*
|
||||
* Signature for the function doing the lookup for a suitable input method
|
||||
* corresponding to an URI.
|
||||
*
|
||||
* Returns the new xmlParserInputBufferPtr in case of success or NULL if no
|
||||
* method was found.
|
||||
*/
|
||||
typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
|
||||
/**
|
||||
* xmlOutputBufferCreateFilenameFunc:
|
||||
* @URI: the URI to write to
|
||||
* @enc: the requested target encoding
|
||||
*
|
||||
* Signature for the function doing the lookup for a suitable output method
|
||||
* corresponding to an URI.
|
||||
*
|
||||
* Returns the new xmlOutputBufferPtr in case of success or NULL if no
|
||||
* method was found.
|
||||
*/
|
||||
typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,
|
||||
xmlCharEncodingHandlerPtr encoder,
|
||||
int compression);
|
||||
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
|
||||
XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc
|
||||
XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func);
|
||||
|
||||
/*
|
||||
* Externally global symbols which need to be protected for backwards
|
||||
* compatibility support.
|
||||
*/
|
||||
|
||||
#undef docbDefaultSAXHandler
|
||||
#undef htmlDefaultSAXHandler
|
||||
#undef oldXMLWDcompatibility
|
||||
#undef xmlBufferAllocScheme
|
||||
#undef xmlDefaultBufferSize
|
||||
#undef xmlDefaultSAXHandler
|
||||
#undef xmlDefaultSAXLocator
|
||||
#undef xmlDoValidityCheckingDefaultValue
|
||||
#undef xmlFree
|
||||
#undef xmlGenericError
|
||||
#undef xmlStructuredError
|
||||
#undef xmlGenericErrorContext
|
||||
#undef xmlStructuredErrorContext
|
||||
#undef xmlGetWarningsDefaultValue
|
||||
#undef xmlIndentTreeOutput
|
||||
#undef xmlTreeIndentString
|
||||
#undef xmlKeepBlanksDefaultValue
|
||||
#undef xmlLineNumbersDefaultValue
|
||||
#undef xmlLoadExtDtdDefaultValue
|
||||
#undef xmlMalloc
|
||||
#undef xmlMallocAtomic
|
||||
#undef xmlMemStrdup
|
||||
#undef xmlParserDebugEntities
|
||||
#undef xmlParserVersion
|
||||
#undef xmlPedanticParserDefaultValue
|
||||
#undef xmlRealloc
|
||||
#undef xmlSaveNoEmptyTags
|
||||
#undef xmlSubstituteEntitiesDefaultValue
|
||||
#undef xmlRegisterNodeDefaultValue
|
||||
#undef xmlDeregisterNodeDefaultValue
|
||||
#undef xmlLastError
|
||||
#undef xmlParserInputBufferCreateFilenameValue
|
||||
#undef xmlOutputBufferCreateFilenameValue
|
||||
|
||||
/**
|
||||
* xmlRegisterNodeFunc:
|
||||
* @node: the current node
|
||||
*
|
||||
* Signature for the registration callback of a created node
|
||||
*/
|
||||
typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
|
||||
/**
|
||||
* xmlDeregisterNodeFunc:
|
||||
* @node: the current node
|
||||
*
|
||||
* Signature for the deregistration callback of a discarded node
|
||||
*/
|
||||
typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
|
||||
|
||||
typedef struct _xmlGlobalState xmlGlobalState;
|
||||
typedef xmlGlobalState *xmlGlobalStatePtr;
|
||||
struct _xmlGlobalState
|
||||
{
|
||||
const char *xmlParserVersion;
|
||||
|
||||
xmlSAXLocator xmlDefaultSAXLocator;
|
||||
xmlSAXHandlerV1 xmlDefaultSAXHandler;
|
||||
xmlSAXHandlerV1 docbDefaultSAXHandler;
|
||||
xmlSAXHandlerV1 htmlDefaultSAXHandler;
|
||||
|
||||
xmlFreeFunc xmlFree;
|
||||
xmlMallocFunc xmlMalloc;
|
||||
xmlStrdupFunc xmlMemStrdup;
|
||||
xmlReallocFunc xmlRealloc;
|
||||
|
||||
xmlGenericErrorFunc xmlGenericError;
|
||||
xmlStructuredErrorFunc xmlStructuredError;
|
||||
void *xmlGenericErrorContext;
|
||||
|
||||
int oldXMLWDcompatibility;
|
||||
|
||||
xmlBufferAllocationScheme xmlBufferAllocScheme;
|
||||
int xmlDefaultBufferSize;
|
||||
|
||||
int xmlSubstituteEntitiesDefaultValue;
|
||||
int xmlDoValidityCheckingDefaultValue;
|
||||
int xmlGetWarningsDefaultValue;
|
||||
int xmlKeepBlanksDefaultValue;
|
||||
int xmlLineNumbersDefaultValue;
|
||||
int xmlLoadExtDtdDefaultValue;
|
||||
int xmlParserDebugEntities;
|
||||
int xmlPedanticParserDefaultValue;
|
||||
|
||||
int xmlSaveNoEmptyTags;
|
||||
int xmlIndentTreeOutput;
|
||||
const char *xmlTreeIndentString;
|
||||
|
||||
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
|
||||
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
||||
|
||||
xmlMallocFunc xmlMallocAtomic;
|
||||
xmlError xmlLastError;
|
||||
|
||||
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
|
||||
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
|
||||
|
||||
void *xmlStructuredErrorContext;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/threads.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs);
|
||||
|
||||
XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
|
||||
|
||||
XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);
|
||||
|
||||
XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func);
|
||||
XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
|
||||
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL
|
||||
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL
|
||||
xmlThrDefParserInputBufferCreateFilenameDefault(
|
||||
xmlParserInputBufferCreateFilenameFunc func);
|
||||
|
||||
/** DOC_DISABLE */
|
||||
/*
|
||||
* In general the memory allocation entry points are not kept
|
||||
* thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
|
||||
* - xmlMalloc
|
||||
* - xmlMallocAtomic
|
||||
* - xmlRealloc
|
||||
* - xmlMemStrdup
|
||||
* - xmlFree
|
||||
*/
|
||||
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void);
|
||||
#define xmlMalloc \
|
||||
(*(__xmlMalloc()))
|
||||
#else
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void);
|
||||
#define xmlMallocAtomic \
|
||||
(*(__xmlMallocAtomic()))
|
||||
#else
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void);
|
||||
#define xmlRealloc \
|
||||
(*(__xmlRealloc()))
|
||||
#else
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void);
|
||||
#define xmlFree \
|
||||
(*(__xmlFree()))
|
||||
#else
|
||||
XMLPUBVAR xmlFreeFunc xmlFree;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void);
|
||||
#define xmlMemStrdup \
|
||||
(*(__xmlMemStrdup()))
|
||||
#else
|
||||
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
|
||||
#endif
|
||||
|
||||
#else /* !LIBXML_THREAD_ALLOC_ENABLED */
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
XMLPUBVAR xmlFreeFunc xmlFree;
|
||||
XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
|
||||
#endif /* LIBXML_THREAD_ALLOC_ENABLED */
|
||||
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define docbDefaultSAXHandler \
|
||||
(*(__docbDefaultSAXHandler()))
|
||||
#else
|
||||
XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define htmlDefaultSAXHandler \
|
||||
(*(__htmlDefaultSAXHandler()))
|
||||
#else
|
||||
XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlError * XMLCALL __xmlLastError(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlLastError \
|
||||
(*(__xmlLastError()))
|
||||
#else
|
||||
XMLPUBVAR xmlError xmlLastError;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Everything starting from the line below is
|
||||
* Automatically generated by build_glob.py.
|
||||
* Do not modify the previous line.
|
||||
*/
|
||||
|
||||
|
||||
XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define oldXMLWDcompatibility \
|
||||
(*(__oldXMLWDcompatibility()))
|
||||
#else
|
||||
XMLPUBVAR int oldXMLWDcompatibility;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlBufferAllocScheme \
|
||||
(*(__xmlBufferAllocScheme()))
|
||||
#else
|
||||
XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;
|
||||
#endif
|
||||
XMLPUBFUN xmlBufferAllocationScheme XMLCALL
|
||||
xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDefaultBufferSize \
|
||||
(*(__xmlDefaultBufferSize()))
|
||||
#else
|
||||
XMLPUBVAR int xmlDefaultBufferSize;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v);
|
||||
|
||||
XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDefaultSAXHandler \
|
||||
(*(__xmlDefaultSAXHandler()))
|
||||
#else
|
||||
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDefaultSAXLocator \
|
||||
(*(__xmlDefaultSAXLocator()))
|
||||
#else
|
||||
XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDoValidityCheckingDefaultValue \
|
||||
(*(__xmlDoValidityCheckingDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlDoValidityCheckingDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlGenericError \
|
||||
(*(__xmlGenericError()))
|
||||
#else
|
||||
XMLPUBVAR xmlGenericErrorFunc xmlGenericError;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlStructuredError \
|
||||
(*(__xmlStructuredError()))
|
||||
#else
|
||||
XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlGenericErrorContext \
|
||||
(*(__xmlGenericErrorContext()))
|
||||
#else
|
||||
XMLPUBVAR void * xmlGenericErrorContext;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlStructuredErrorContext \
|
||||
(*(__xmlStructuredErrorContext()))
|
||||
#else
|
||||
XMLPUBVAR void * xmlStructuredErrorContext;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlGetWarningsDefaultValue \
|
||||
(*(__xmlGetWarningsDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlGetWarningsDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlIndentTreeOutput \
|
||||
(*(__xmlIndentTreeOutput()))
|
||||
#else
|
||||
XMLPUBVAR int xmlIndentTreeOutput;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v);
|
||||
|
||||
XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlTreeIndentString \
|
||||
(*(__xmlTreeIndentString()))
|
||||
#else
|
||||
XMLPUBVAR const char * xmlTreeIndentString;
|
||||
#endif
|
||||
XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlKeepBlanksDefaultValue \
|
||||
(*(__xmlKeepBlanksDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlKeepBlanksDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlLineNumbersDefaultValue \
|
||||
(*(__xmlLineNumbersDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlLineNumbersDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlLoadExtDtdDefaultValue \
|
||||
(*(__xmlLoadExtDtdDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlLoadExtDtdDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlParserDebugEntities \
|
||||
(*(__xmlParserDebugEntities()))
|
||||
#else
|
||||
XMLPUBVAR int xmlParserDebugEntities;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v);
|
||||
|
||||
XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlParserVersion \
|
||||
(*(__xmlParserVersion()))
|
||||
#else
|
||||
XMLPUBVAR const char * xmlParserVersion;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlPedanticParserDefaultValue \
|
||||
(*(__xmlPedanticParserDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlPedanticParserDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlSaveNoEmptyTags \
|
||||
(*(__xmlSaveNoEmptyTags()))
|
||||
#else
|
||||
XMLPUBVAR int xmlSaveNoEmptyTags;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v);
|
||||
|
||||
XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlSubstituteEntitiesDefaultValue \
|
||||
(*(__xmlSubstituteEntitiesDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR int xmlSubstituteEntitiesDefaultValue;
|
||||
#endif
|
||||
XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v);
|
||||
|
||||
XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlRegisterNodeDefaultValue \
|
||||
(*(__xmlRegisterNodeDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlDeregisterNodeDefaultValue \
|
||||
(*(__xmlDeregisterNodeDefaultValue()))
|
||||
#else
|
||||
XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL \
|
||||
__xmlParserInputBufferCreateFilenameValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlParserInputBufferCreateFilenameValue \
|
||||
(*(__xmlParserInputBufferCreateFilenameValue()))
|
||||
#else
|
||||
XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
|
||||
#endif
|
||||
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void);
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define xmlOutputBufferCreateFilenameValue \
|
||||
(*(__xmlOutputBufferCreateFilenameValue()))
|
||||
#else
|
||||
XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_GLOBALS_H */
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Summary: Chained hash tables
|
||||
* Description: This module implements the hash table support used in
|
||||
* various places in the library.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Bjorn Reese <bjorn.reese@systematic.dk>
|
||||
*/
|
||||
|
||||
#ifndef __XML_HASH_H__
|
||||
#define __XML_HASH_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The hash table.
|
||||
*/
|
||||
typedef struct _xmlHashTable xmlHashTable;
|
||||
typedef xmlHashTable *xmlHashTablePtr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/dict.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Recent version of gcc produce a warning when a function pointer is assigned
|
||||
* to an object pointer, or vice versa. The following macro is a dirty hack
|
||||
* to allow suppression of the warning. If your architecture has function
|
||||
* pointers which are a different size than a void pointer, there may be some
|
||||
* serious trouble within the library.
|
||||
*/
|
||||
/**
|
||||
* XML_CAST_FPTR:
|
||||
* @fptr: pointer to a function
|
||||
*
|
||||
* Macro to do a casting from an object pointer to a
|
||||
* function pointer without encountering a warning from
|
||||
* gcc
|
||||
*
|
||||
* #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
|
||||
* This macro violated ISO C aliasing rules (gcc4 on s390 broke)
|
||||
* so it is disabled now
|
||||
*/
|
||||
|
||||
#define XML_CAST_FPTR(fptr) fptr
|
||||
|
||||
|
||||
/*
|
||||
* function types:
|
||||
*/
|
||||
/**
|
||||
* xmlHashDeallocator:
|
||||
* @payload: the data in the hash
|
||||
* @name: the name associated
|
||||
*
|
||||
* Callback to free data from a hash.
|
||||
*/
|
||||
typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);
|
||||
/**
|
||||
* xmlHashCopier:
|
||||
* @payload: the data in the hash
|
||||
* @name: the name associated
|
||||
*
|
||||
* Callback to copy data from a hash.
|
||||
*
|
||||
* Returns a copy of the data or NULL in case of error.
|
||||
*/
|
||||
typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);
|
||||
/**
|
||||
* xmlHashScanner:
|
||||
* @payload: the data in the hash
|
||||
* @data: extra scanner data
|
||||
* @name: the name associated
|
||||
*
|
||||
* Callback when scanning data in a hash with the simple scanner.
|
||||
*/
|
||||
typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);
|
||||
/**
|
||||
* xmlHashScannerFull:
|
||||
* @payload: the data in the hash
|
||||
* @data: extra scanner data
|
||||
* @name: the name associated
|
||||
* @name2: the second name associated
|
||||
* @name3: the third name associated
|
||||
*
|
||||
* Callback when scanning data in a hash with the full scanner.
|
||||
*/
|
||||
typedef void (*xmlHashScannerFull)(void *payload, void *data,
|
||||
const xmlChar *name, const xmlChar *name2,
|
||||
const xmlChar *name3);
|
||||
|
||||
/*
|
||||
* Constructor and destructor.
|
||||
*/
|
||||
XMLPUBFUN xmlHashTablePtr XMLCALL
|
||||
xmlHashCreate (int size);
|
||||
XMLPUBFUN xmlHashTablePtr XMLCALL
|
||||
xmlHashCreateDict(int size,
|
||||
xmlDictPtr dict);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlHashFree (xmlHashTablePtr table,
|
||||
xmlHashDeallocator f);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlHashDefaultDeallocator(void *entry,
|
||||
const xmlChar *name);
|
||||
|
||||
/*
|
||||
* Add a new entry to the hash table.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashAddEntry (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
void *userdata);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashUpdateEntry(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashAddEntry2(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashUpdateEntry2(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashAddEntry3(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashUpdateEntry3(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
void *userdata,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Remove an entry from the hash table.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
|
||||
xmlHashDeallocator f);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, xmlHashDeallocator f);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
|
||||
const xmlChar *name2, const xmlChar *name3,
|
||||
xmlHashDeallocator f);
|
||||
|
||||
/*
|
||||
* Retrieve the userdata.
|
||||
*/
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlHashLookup (xmlHashTablePtr table,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlHashLookup2 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlHashLookup3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlHashQLookup (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlHashQLookup2 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *prefix2);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlHashQLookup3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *prefix2,
|
||||
const xmlChar *name3,
|
||||
const xmlChar *prefix3);
|
||||
|
||||
/*
|
||||
* Helpers.
|
||||
*/
|
||||
XMLPUBFUN xmlHashTablePtr XMLCALL
|
||||
xmlHashCopy (xmlHashTablePtr table,
|
||||
xmlHashCopier f);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlHashSize (xmlHashTablePtr table);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlHashScan (xmlHashTablePtr table,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlHashScan3 (xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
xmlHashScanner f,
|
||||
void *data);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlHashScanFull (xmlHashTablePtr table,
|
||||
xmlHashScannerFull f,
|
||||
void *data);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlHashScanFull3(xmlHashTablePtr table,
|
||||
const xmlChar *name,
|
||||
const xmlChar *name2,
|
||||
const xmlChar *name3,
|
||||
xmlHashScannerFull f,
|
||||
void *data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ! __XML_HASH_H__ */
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Summary: lists interfaces
|
||||
* Description: this module implement the list support used in
|
||||
* various place in the library.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Gary Pennington <Gary.Pennington@uk.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __XML_LINK_INCLUDE__
|
||||
#define __XML_LINK_INCLUDE__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _xmlLink xmlLink;
|
||||
typedef xmlLink *xmlLinkPtr;
|
||||
|
||||
typedef struct _xmlList xmlList;
|
||||
typedef xmlList *xmlListPtr;
|
||||
|
||||
/**
|
||||
* xmlListDeallocator:
|
||||
* @lk: the data to deallocate
|
||||
*
|
||||
* Callback function used to free data from a list.
|
||||
*/
|
||||
typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
|
||||
/**
|
||||
* xmlListDataCompare:
|
||||
* @data0: the first data
|
||||
* @data1: the second data
|
||||
*
|
||||
* Callback function used to compare 2 data.
|
||||
*
|
||||
* Returns 0 is equality, -1 or 1 otherwise depending on the ordering.
|
||||
*/
|
||||
typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
|
||||
/**
|
||||
* xmlListWalker:
|
||||
* @data: the data found in the list
|
||||
* @user: extra user provided data to the walker
|
||||
*
|
||||
* Callback function used when walking a list with xmlListWalk().
|
||||
*
|
||||
* Returns 0 to stop walking the list, 1 otherwise.
|
||||
*/
|
||||
typedef int (*xmlListWalker) (const void *data, void *user);
|
||||
|
||||
/* Creation/Deletion */
|
||||
XMLPUBFUN xmlListPtr XMLCALL
|
||||
xmlListCreate (xmlListDeallocator deallocator,
|
||||
xmlListDataCompare compare);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListDelete (xmlListPtr l);
|
||||
|
||||
/* Basic Operators */
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlListSearch (xmlListPtr l,
|
||||
void *data);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlListReverseSearch (xmlListPtr l,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListInsert (xmlListPtr l,
|
||||
void *data) ;
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListAppend (xmlListPtr l,
|
||||
void *data) ;
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListRemoveFirst (xmlListPtr l,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListRemoveLast (xmlListPtr l,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListRemoveAll (xmlListPtr l,
|
||||
void *data);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListClear (xmlListPtr l);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListEmpty (xmlListPtr l);
|
||||
XMLPUBFUN xmlLinkPtr XMLCALL
|
||||
xmlListFront (xmlListPtr l);
|
||||
XMLPUBFUN xmlLinkPtr XMLCALL
|
||||
xmlListEnd (xmlListPtr l);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListSize (xmlListPtr l);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListPopFront (xmlListPtr l);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListPopBack (xmlListPtr l);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListPushFront (xmlListPtr l,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListPushBack (xmlListPtr l,
|
||||
void *data);
|
||||
|
||||
/* Advanced Operators */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListReverse (xmlListPtr l);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListSort (xmlListPtr l);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
void *user);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListReverseWalk (xmlListPtr l,
|
||||
xmlListWalker walker,
|
||||
void *user);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlListMerge (xmlListPtr l1,
|
||||
xmlListPtr l2);
|
||||
XMLPUBFUN xmlListPtr XMLCALL
|
||||
xmlListDup (const xmlListPtr old);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlListCopy (xmlListPtr cur,
|
||||
const xmlListPtr old);
|
||||
/* Link operators */
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlLinkGetData (xmlLinkPtr lk);
|
||||
|
||||
/* xmlListUnique() */
|
||||
/* xmlListSwap */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_LINK_INCLUDE__ */
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Summary: minimal FTP implementation
|
||||
* Description: minimal FTP implementation allowing to fetch resources
|
||||
* like external subset.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __NANO_FTP_H__
|
||||
#define __NANO_FTP_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_FTP_ENABLED
|
||||
|
||||
/* Needed for portability to Windows 64 bits */
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
/**
|
||||
* SOCKET:
|
||||
*
|
||||
* macro used to provide portability of code to windows sockets
|
||||
*/
|
||||
#define SOCKET int
|
||||
/**
|
||||
* INVALID_SOCKET:
|
||||
*
|
||||
* macro used to provide portability of code to windows sockets
|
||||
* the value to be used when the socket is not valid
|
||||
*/
|
||||
#undef INVALID_SOCKET
|
||||
#define INVALID_SOCKET (-1)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ftpListCallback:
|
||||
* @userData: user provided data for the callback
|
||||
* @filename: the file name (including "->" when links are shown)
|
||||
* @attrib: the attribute string
|
||||
* @owner: the owner string
|
||||
* @group: the group string
|
||||
* @size: the file size
|
||||
* @links: the link count
|
||||
* @year: the year
|
||||
* @month: the month
|
||||
* @day: the day
|
||||
* @hour: the hour
|
||||
* @minute: the minute
|
||||
*
|
||||
* A callback for the xmlNanoFTPList command.
|
||||
* Note that only one of year and day:minute are specified.
|
||||
*/
|
||||
typedef void (*ftpListCallback) (void *userData,
|
||||
const char *filename, const char *attrib,
|
||||
const char *owner, const char *group,
|
||||
unsigned long size, int links, int year,
|
||||
const char *month, int day, int hour,
|
||||
int minute);
|
||||
/**
|
||||
* ftpDataCallback:
|
||||
* @userData: the user provided context
|
||||
* @data: the data received
|
||||
* @len: its size in bytes
|
||||
*
|
||||
* A callback for the xmlNanoFTPGet command.
|
||||
*/
|
||||
typedef void (*ftpDataCallback) (void *userData,
|
||||
const char *data,
|
||||
int len);
|
||||
|
||||
/*
|
||||
* Init
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoFTPInit (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoFTPCleanup (void);
|
||||
|
||||
/*
|
||||
* Creating/freeing contexts.
|
||||
*/
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlNanoFTPNewCtxt (const char *URL);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoFTPFreeCtxt (void * ctx);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlNanoFTPConnectTo (const char *server,
|
||||
int port);
|
||||
/*
|
||||
* Opening/closing session connections.
|
||||
*/
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlNanoFTPOpen (const char *URL);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPConnect (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPClose (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPQuit (void *ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoFTPScanProxy (const char *URL);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoFTPProxy (const char *host,
|
||||
int port,
|
||||
const char *user,
|
||||
const char *passwd,
|
||||
int type);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPUpdateURL (void *ctx,
|
||||
const char *URL);
|
||||
|
||||
/*
|
||||
* Rather internal commands.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPGetResponse (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPCheckResponse (void *ctx);
|
||||
|
||||
/*
|
||||
* CD/DIR/GET handlers.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPCwd (void *ctx,
|
||||
const char *directory);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPDele (void *ctx,
|
||||
const char *file);
|
||||
|
||||
XMLPUBFUN SOCKET XMLCALL
|
||||
xmlNanoFTPGetConnection (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPCloseConnection(void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPList (void *ctx,
|
||||
ftpListCallback callback,
|
||||
void *userData,
|
||||
const char *filename);
|
||||
XMLPUBFUN SOCKET XMLCALL
|
||||
xmlNanoFTPGetSocket (void *ctx,
|
||||
const char *filename);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPGet (void *ctx,
|
||||
ftpDataCallback callback,
|
||||
void *userData,
|
||||
const char *filename);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoFTPRead (void *ctx,
|
||||
void *dest,
|
||||
int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* LIBXML_FTP_ENABLED */
|
||||
#endif /* __NANO_FTP_H__ */
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Summary: minimal HTTP implementation
|
||||
* Description: minimal HTTP implementation allowing to fetch resources
|
||||
* like external subset.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __NANO_HTTP_H__
|
||||
#define __NANO_HTTP_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_HTTP_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoHTTPInit (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoHTTPCleanup (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoHTTPScanProxy (const char *URL);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoHTTPFetch (const char *URL,
|
||||
const char *filename,
|
||||
char **contentType);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlNanoHTTPMethod (const char *URL,
|
||||
const char *method,
|
||||
const char *input,
|
||||
char **contentType,
|
||||
const char *headers,
|
||||
int ilen);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlNanoHTTPMethodRedir (const char *URL,
|
||||
const char *method,
|
||||
const char *input,
|
||||
char **contentType,
|
||||
char **redir,
|
||||
const char *headers,
|
||||
int ilen);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlNanoHTTPOpen (const char *URL,
|
||||
char **contentType);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlNanoHTTPOpenRedir (const char *URL,
|
||||
char **contentType,
|
||||
char **redir);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoHTTPReturnCode (void *ctx);
|
||||
XMLPUBFUN const char * XMLCALL
|
||||
xmlNanoHTTPAuthHeader (void *ctx);
|
||||
XMLPUBFUN const char * XMLCALL
|
||||
xmlNanoHTTPRedir (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoHTTPContentLength( void * ctx );
|
||||
XMLPUBFUN const char * XMLCALL
|
||||
xmlNanoHTTPEncoding (void *ctx);
|
||||
XMLPUBFUN const char * XMLCALL
|
||||
xmlNanoHTTPMimeType (void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoHTTPRead (void *ctx,
|
||||
void *dest,
|
||||
int len);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoHTTPSave (void *ctxt,
|
||||
const char *filename);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlNanoHTTPClose (void *ctx);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_HTTP_ENABLED */
|
||||
#endif /* __NANO_HTTP_H__ */
|
||||
1243
acer-env/lib/python3.10/site-packages/lxml/includes/libxml/parser.h
Normal file
1243
acer-env/lib/python3.10/site-packages/lxml/includes/libxml/parser.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,644 @@
|
||||
/*
|
||||
* Summary: internals routines and limits exported by the parser.
|
||||
* Description: this module exports a number of internal parsing routines
|
||||
* they are not really all intended for applications but
|
||||
* can prove useful doing low level processing.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_PARSER_INTERNALS_H__
|
||||
#define __XML_PARSER_INTERNALS_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/chvalid.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlParserMaxDepth:
|
||||
*
|
||||
* arbitrary depth limit for the XML documents that we allow to
|
||||
* process. This is not a limitation of the parser but a safety
|
||||
* boundary feature, use XML_PARSE_HUGE option to override it.
|
||||
*/
|
||||
XMLPUBVAR unsigned int xmlParserMaxDepth;
|
||||
|
||||
/**
|
||||
* XML_MAX_TEXT_LENGTH:
|
||||
*
|
||||
* Maximum size allowed for a single text node when building a tree.
|
||||
* This is not a limitation of the parser but a safety boundary feature,
|
||||
* use XML_PARSE_HUGE option to override it.
|
||||
* Introduced in 2.9.0
|
||||
*/
|
||||
#define XML_MAX_TEXT_LENGTH 10000000
|
||||
|
||||
/**
|
||||
* XML_MAX_NAME_LENGTH:
|
||||
*
|
||||
* Maximum size allowed for a markup identifier.
|
||||
* This is not a limitation of the parser but a safety boundary feature,
|
||||
* use XML_PARSE_HUGE option to override it.
|
||||
* Note that with the use of parsing dictionaries overriding the limit
|
||||
* may result in more runtime memory usage in face of "unfriendly' content
|
||||
* Introduced in 2.9.0
|
||||
*/
|
||||
#define XML_MAX_NAME_LENGTH 50000
|
||||
|
||||
/**
|
||||
* XML_MAX_DICTIONARY_LIMIT:
|
||||
*
|
||||
* Maximum size allowed by the parser for a dictionary by default
|
||||
* This is not a limitation of the parser but a safety boundary feature,
|
||||
* use XML_PARSE_HUGE option to override it.
|
||||
* Introduced in 2.9.0
|
||||
*/
|
||||
#define XML_MAX_DICTIONARY_LIMIT 10000000
|
||||
|
||||
/**
|
||||
* XML_MAX_LOOKUP_LIMIT:
|
||||
*
|
||||
* Maximum size allowed by the parser for ahead lookup
|
||||
* This is an upper boundary enforced by the parser to avoid bad
|
||||
* behaviour on "unfriendly' content
|
||||
* Introduced in 2.9.0
|
||||
*/
|
||||
#define XML_MAX_LOOKUP_LIMIT 10000000
|
||||
|
||||
/**
|
||||
* XML_MAX_NAMELEN:
|
||||
*
|
||||
* Identifiers can be longer, but this will be more costly
|
||||
* at runtime.
|
||||
*/
|
||||
#define XML_MAX_NAMELEN 100
|
||||
|
||||
/**
|
||||
* INPUT_CHUNK:
|
||||
*
|
||||
* The parser tries to always have that amount of input ready.
|
||||
* One of the point is providing context when reporting errors.
|
||||
*/
|
||||
#define INPUT_CHUNK 250
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* UNICODE version of the macros. *
|
||||
* *
|
||||
************************************************************************/
|
||||
/**
|
||||
* IS_BYTE_CHAR:
|
||||
* @c: an byte value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
* [2] Char ::= #x9 | #xA | #xD | [#x20...]
|
||||
* any byte character in the accepted range
|
||||
*/
|
||||
#define IS_BYTE_CHAR(c) xmlIsChar_ch(c)
|
||||
|
||||
/**
|
||||
* IS_CHAR:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
* [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
|
||||
* | [#x10000-#x10FFFF]
|
||||
* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
|
||||
*/
|
||||
#define IS_CHAR(c) xmlIsCharQ(c)
|
||||
|
||||
/**
|
||||
* IS_CHAR_CH:
|
||||
* @c: an xmlChar (usually an unsigned char)
|
||||
*
|
||||
* Behaves like IS_CHAR on single-byte value
|
||||
*/
|
||||
#define IS_CHAR_CH(c) xmlIsChar_ch(c)
|
||||
|
||||
/**
|
||||
* IS_BLANK:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
* [3] S ::= (#x20 | #x9 | #xD | #xA)+
|
||||
*/
|
||||
#define IS_BLANK(c) xmlIsBlankQ(c)
|
||||
|
||||
/**
|
||||
* IS_BLANK_CH:
|
||||
* @c: an xmlChar value (normally unsigned char)
|
||||
*
|
||||
* Behaviour same as IS_BLANK
|
||||
*/
|
||||
#define IS_BLANK_CH(c) xmlIsBlank_ch(c)
|
||||
|
||||
/**
|
||||
* IS_BASECHAR:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
* [85] BaseChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_BASECHAR(c) xmlIsBaseCharQ(c)
|
||||
|
||||
/**
|
||||
* IS_DIGIT:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
* [88] Digit ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_DIGIT(c) xmlIsDigitQ(c)
|
||||
|
||||
/**
|
||||
* IS_DIGIT_CH:
|
||||
* @c: an xmlChar value (usually an unsigned char)
|
||||
*
|
||||
* Behaves like IS_DIGIT but with a single byte argument
|
||||
*/
|
||||
#define IS_DIGIT_CH(c) xmlIsDigit_ch(c)
|
||||
|
||||
/**
|
||||
* IS_COMBINING:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
* [87] CombiningChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_COMBINING(c) xmlIsCombiningQ(c)
|
||||
|
||||
/**
|
||||
* IS_COMBINING_CH:
|
||||
* @c: an xmlChar (usually an unsigned char)
|
||||
*
|
||||
* Always false (all combining chars > 0xff)
|
||||
*/
|
||||
#define IS_COMBINING_CH(c) 0
|
||||
|
||||
/**
|
||||
* IS_EXTENDER:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
*
|
||||
* [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
|
||||
* #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |
|
||||
* [#x309D-#x309E] | [#x30FC-#x30FE]
|
||||
*/
|
||||
#define IS_EXTENDER(c) xmlIsExtenderQ(c)
|
||||
|
||||
/**
|
||||
* IS_EXTENDER_CH:
|
||||
* @c: an xmlChar value (usually an unsigned char)
|
||||
*
|
||||
* Behaves like IS_EXTENDER but with a single-byte argument
|
||||
*/
|
||||
#define IS_EXTENDER_CH(c) xmlIsExtender_ch(c)
|
||||
|
||||
/**
|
||||
* IS_IDEOGRAPHIC:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
*
|
||||
* [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
|
||||
*/
|
||||
#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c)
|
||||
|
||||
/**
|
||||
* IS_LETTER:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
*
|
||||
* [84] Letter ::= BaseChar | Ideographic
|
||||
*/
|
||||
#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
|
||||
|
||||
/**
|
||||
* IS_LETTER_CH:
|
||||
* @c: an xmlChar value (normally unsigned char)
|
||||
*
|
||||
* Macro behaves like IS_LETTER, but only check base chars
|
||||
*
|
||||
*/
|
||||
#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c)
|
||||
|
||||
/**
|
||||
* IS_ASCII_LETTER:
|
||||
* @c: an xmlChar value
|
||||
*
|
||||
* Macro to check [a-zA-Z]
|
||||
*
|
||||
*/
|
||||
#define IS_ASCII_LETTER(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \
|
||||
((0x61 <= (c)) && ((c) <= 0x7a)))
|
||||
|
||||
/**
|
||||
* IS_ASCII_DIGIT:
|
||||
* @c: an xmlChar value
|
||||
*
|
||||
* Macro to check [0-9]
|
||||
*
|
||||
*/
|
||||
#define IS_ASCII_DIGIT(c) ((0x30 <= (c)) && ((c) <= 0x39))
|
||||
|
||||
/**
|
||||
* IS_PUBIDCHAR:
|
||||
* @c: an UNICODE value (int)
|
||||
*
|
||||
* Macro to check the following production in the XML spec:
|
||||
*
|
||||
*
|
||||
* [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
|
||||
*/
|
||||
#define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c)
|
||||
|
||||
/**
|
||||
* IS_PUBIDCHAR_CH:
|
||||
* @c: an xmlChar value (normally unsigned char)
|
||||
*
|
||||
* Same as IS_PUBIDCHAR but for single-byte value
|
||||
*/
|
||||
#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c)
|
||||
|
||||
/**
|
||||
* SKIP_EOL:
|
||||
* @p: and UTF8 string pointer
|
||||
*
|
||||
* Skips the end of line chars.
|
||||
*/
|
||||
#define SKIP_EOL(p) \
|
||||
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
|
||||
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
|
||||
|
||||
/**
|
||||
* MOVETO_ENDTAG:
|
||||
* @p: and UTF8 string pointer
|
||||
*
|
||||
* Skips to the next '>' char.
|
||||
*/
|
||||
#define MOVETO_ENDTAG(p) \
|
||||
while ((*p) && (*(p) != '>')) (p)++
|
||||
|
||||
/**
|
||||
* MOVETO_STARTTAG:
|
||||
* @p: and UTF8 string pointer
|
||||
*
|
||||
* Skips to the next '<' char.
|
||||
*/
|
||||
#define MOVETO_STARTTAG(p) \
|
||||
while ((*p) && (*(p) != '<')) (p)++
|
||||
|
||||
/**
|
||||
* Global variables used for predefined strings.
|
||||
*/
|
||||
XMLPUBVAR const xmlChar xmlStringText[];
|
||||
XMLPUBVAR const xmlChar xmlStringTextNoenc[];
|
||||
XMLPUBVAR const xmlChar xmlStringComment[];
|
||||
|
||||
/*
|
||||
* Function to finish the work of the macros where needed.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL xmlIsLetter (int c);
|
||||
|
||||
/**
|
||||
* Parser context.
|
||||
*/
|
||||
XMLPUBFUN xmlParserCtxtPtr XMLCALL
|
||||
xmlCreateFileParserCtxt (const char *filename);
|
||||
XMLPUBFUN xmlParserCtxtPtr XMLCALL
|
||||
xmlCreateURLParserCtxt (const char *filename,
|
||||
int options);
|
||||
XMLPUBFUN xmlParserCtxtPtr XMLCALL
|
||||
xmlCreateMemoryParserCtxt(const char *buffer,
|
||||
int size);
|
||||
XMLPUBFUN xmlParserCtxtPtr XMLCALL
|
||||
xmlCreateEntityParserCtxt(const xmlChar *URL,
|
||||
const xmlChar *ID,
|
||||
const xmlChar *base);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlCharEncodingHandlerPtr handler);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr input,
|
||||
xmlCharEncodingHandlerPtr handler);
|
||||
|
||||
#ifdef IN_LIBXML
|
||||
/* internal error reporting */
|
||||
XMLPUBFUN void XMLCALL
|
||||
__xmlErrEncoding (xmlParserCtxtPtr ctxt,
|
||||
xmlParserErrors xmlerr,
|
||||
const char *msg,
|
||||
const xmlChar * str1,
|
||||
const xmlChar * str2) LIBXML_ATTR_FORMAT(3,0);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Input Streams.
|
||||
*/
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *buffer);
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPushInput (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr input);
|
||||
XMLPUBFUN xmlChar XMLCALL
|
||||
xmlPopInput (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeInputStream (xmlParserInputPtr input);
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
xmlNewInputFromFile (xmlParserCtxtPtr ctxt,
|
||||
const char *filename);
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
xmlNewInputStream (xmlParserCtxtPtr ctxt);
|
||||
|
||||
/**
|
||||
* Namespaces.
|
||||
*/
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlSplitQName (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlChar **prefix);
|
||||
|
||||
/**
|
||||
* Generic production rules.
|
||||
*/
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlParseName (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseNmtoken (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseEntityValue (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **orig);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseAttValue (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseSystemLiteral (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParsePubidLiteral (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseCharData (xmlParserCtxtPtr ctxt,
|
||||
int cdata);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseExternalID (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **publicID,
|
||||
int strict);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseComment (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlParsePITarget (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParsePI (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseNotationDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseEntityDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseDefaultDecl (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **value);
|
||||
XMLPUBFUN xmlEnumerationPtr XMLCALL
|
||||
xmlParseNotationType (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlEnumerationPtr XMLCALL
|
||||
xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseEnumeratedType (xmlParserCtxtPtr ctxt,
|
||||
xmlEnumerationPtr *tree);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseAttributeType (xmlParserCtxtPtr ctxt,
|
||||
xmlEnumerationPtr *tree);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlElementContentPtr XMLCALL
|
||||
xmlParseElementMixedContentDecl
|
||||
(xmlParserCtxtPtr ctxt,
|
||||
int inputchk);
|
||||
XMLPUBFUN xmlElementContentPtr XMLCALL
|
||||
xmlParseElementChildrenContentDecl
|
||||
(xmlParserCtxtPtr ctxt,
|
||||
int inputchk);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *name,
|
||||
xmlElementContentPtr *result);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseElementDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseMarkupDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseCharRef (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlEntityPtr XMLCALL
|
||||
xmlParseEntityRef (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseReference (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParsePEReference (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt);
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlParseAttribute (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **value);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlParseStartTag (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseEndTag (xmlParserCtxtPtr ctxt);
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseCDSect (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseContent (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseElement (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseVersionNum (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseVersionInfo (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseEncName (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlParseEncodingDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseSDDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseXMLDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseTextDecl (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseMisc (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseExternalSubset (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *ExternalID,
|
||||
const xmlChar *SystemID);
|
||||
/**
|
||||
* XML_SUBSTITUTE_NONE:
|
||||
*
|
||||
* If no entities need to be substituted.
|
||||
*/
|
||||
#define XML_SUBSTITUTE_NONE 0
|
||||
/**
|
||||
* XML_SUBSTITUTE_REF:
|
||||
*
|
||||
* Whether general entities need to be substituted.
|
||||
*/
|
||||
#define XML_SUBSTITUTE_REF 1
|
||||
/**
|
||||
* XML_SUBSTITUTE_PEREF:
|
||||
*
|
||||
* Whether parameter entities need to be substituted.
|
||||
*/
|
||||
#define XML_SUBSTITUTE_PEREF 2
|
||||
/**
|
||||
* XML_SUBSTITUTE_BOTH:
|
||||
*
|
||||
* Both general and parameter entities need to be substituted.
|
||||
*/
|
||||
#define XML_SUBSTITUTE_BOTH 3
|
||||
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *str,
|
||||
int what,
|
||||
xmlChar end,
|
||||
xmlChar end2,
|
||||
xmlChar end3);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *str,
|
||||
int len,
|
||||
int what,
|
||||
xmlChar end,
|
||||
xmlChar end2,
|
||||
xmlChar end3);
|
||||
|
||||
/*
|
||||
* Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt,
|
||||
xmlNodePtr value);
|
||||
XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr value);
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN const xmlChar * XMLCALL namePop (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *value);
|
||||
|
||||
/*
|
||||
* other commodities shared between parser.c and parserInternals.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
|
||||
const xmlChar *cur,
|
||||
int *len);
|
||||
XMLPUBFUN void XMLCALL xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang);
|
||||
|
||||
/*
|
||||
* Really core function shared with HTML parser.
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt,
|
||||
int *len);
|
||||
XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out,
|
||||
int val);
|
||||
XMLPUBFUN int XMLCALL xmlCopyChar (int len,
|
||||
xmlChar *out,
|
||||
int val);
|
||||
XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in);
|
||||
|
||||
#ifdef LIBXML_HTML_ENABLED
|
||||
/*
|
||||
* Actually comes from the HTML parser but launched from the init stuff.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL htmlInitAutoClose (void);
|
||||
XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename,
|
||||
const char *encoding);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Specific function to keep track of entities references
|
||||
* and used by the XSLT debugger.
|
||||
*/
|
||||
#ifdef LIBXML_LEGACY_ENABLED
|
||||
/**
|
||||
* xmlEntityReferenceFunc:
|
||||
* @ent: the entity
|
||||
* @firstNode: the fist node in the chunk
|
||||
* @lastNode: the last nod in the chunk
|
||||
*
|
||||
* Callback function used when one needs to be able to track back the
|
||||
* provenance of a chunk of nodes inherited from an entity replacement.
|
||||
*/
|
||||
typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent,
|
||||
xmlNodePtr firstNode,
|
||||
xmlNodePtr lastNode);
|
||||
|
||||
XMLPUBFUN void XMLCALL xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func);
|
||||
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlParseQuotedString (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlParseNamespace (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlScanName (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
|
||||
xmlChar **prefix);
|
||||
/**
|
||||
* Entities
|
||||
*/
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||
int len,
|
||||
int what,
|
||||
xmlChar end,
|
||||
xmlChar end2,
|
||||
xmlChar end3);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlHandleEntity (xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
|
||||
#endif /* LIBXML_LEGACY_ENABLED */
|
||||
|
||||
#ifdef IN_LIBXML
|
||||
/*
|
||||
* internal only
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlErrMemory (xmlParserCtxtPtr ctxt,
|
||||
const char *extra);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_PARSER_INTERNALS_H__ */
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Summary: implementation of the Relax-NG validation
|
||||
* Description: implementation of the Relax-NG validation
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_RELAX_NG__
|
||||
#define __XML_RELAX_NG__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _xmlRelaxNG xmlRelaxNG;
|
||||
typedef xmlRelaxNG *xmlRelaxNGPtr;
|
||||
|
||||
|
||||
/**
|
||||
* xmlRelaxNGValidityErrorFunc:
|
||||
* @ctx: the validation context
|
||||
* @msg: the message
|
||||
* @...: extra arguments
|
||||
*
|
||||
* Signature of an error callback from a Relax-NG validation
|
||||
*/
|
||||
typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx,
|
||||
const char *msg,
|
||||
...) LIBXML_ATTR_FORMAT(2,3);
|
||||
|
||||
/**
|
||||
* xmlRelaxNGValidityWarningFunc:
|
||||
* @ctx: the validation context
|
||||
* @msg: the message
|
||||
* @...: extra arguments
|
||||
*
|
||||
* Signature of a warning callback from a Relax-NG validation
|
||||
*/
|
||||
typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx,
|
||||
const char *msg,
|
||||
...) LIBXML_ATTR_FORMAT(2,3);
|
||||
|
||||
/**
|
||||
* A schemas validation context
|
||||
*/
|
||||
typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt;
|
||||
typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr;
|
||||
|
||||
typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt;
|
||||
typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr;
|
||||
|
||||
/*
|
||||
* xmlRelaxNGValidErr:
|
||||
*
|
||||
* List of possible Relax NG validation errors
|
||||
*/
|
||||
typedef enum {
|
||||
XML_RELAXNG_OK = 0,
|
||||
XML_RELAXNG_ERR_MEMORY,
|
||||
XML_RELAXNG_ERR_TYPE,
|
||||
XML_RELAXNG_ERR_TYPEVAL,
|
||||
XML_RELAXNG_ERR_DUPID,
|
||||
XML_RELAXNG_ERR_TYPECMP,
|
||||
XML_RELAXNG_ERR_NOSTATE,
|
||||
XML_RELAXNG_ERR_NODEFINE,
|
||||
XML_RELAXNG_ERR_LISTEXTRA,
|
||||
XML_RELAXNG_ERR_LISTEMPTY,
|
||||
XML_RELAXNG_ERR_INTERNODATA,
|
||||
XML_RELAXNG_ERR_INTERSEQ,
|
||||
XML_RELAXNG_ERR_INTEREXTRA,
|
||||
XML_RELAXNG_ERR_ELEMNAME,
|
||||
XML_RELAXNG_ERR_ATTRNAME,
|
||||
XML_RELAXNG_ERR_ELEMNONS,
|
||||
XML_RELAXNG_ERR_ATTRNONS,
|
||||
XML_RELAXNG_ERR_ELEMWRONGNS,
|
||||
XML_RELAXNG_ERR_ATTRWRONGNS,
|
||||
XML_RELAXNG_ERR_ELEMEXTRANS,
|
||||
XML_RELAXNG_ERR_ATTREXTRANS,
|
||||
XML_RELAXNG_ERR_ELEMNOTEMPTY,
|
||||
XML_RELAXNG_ERR_NOELEM,
|
||||
XML_RELAXNG_ERR_NOTELEM,
|
||||
XML_RELAXNG_ERR_ATTRVALID,
|
||||
XML_RELAXNG_ERR_CONTENTVALID,
|
||||
XML_RELAXNG_ERR_EXTRACONTENT,
|
||||
XML_RELAXNG_ERR_INVALIDATTR,
|
||||
XML_RELAXNG_ERR_DATAELEM,
|
||||
XML_RELAXNG_ERR_VALELEM,
|
||||
XML_RELAXNG_ERR_LISTELEM,
|
||||
XML_RELAXNG_ERR_DATATYPE,
|
||||
XML_RELAXNG_ERR_VALUE,
|
||||
XML_RELAXNG_ERR_LIST,
|
||||
XML_RELAXNG_ERR_NOGRAMMAR,
|
||||
XML_RELAXNG_ERR_EXTRADATA,
|
||||
XML_RELAXNG_ERR_LACKDATA,
|
||||
XML_RELAXNG_ERR_INTERNAL,
|
||||
XML_RELAXNG_ERR_ELEMWRONG,
|
||||
XML_RELAXNG_ERR_TEXTWRONG
|
||||
} xmlRelaxNGValidErr;
|
||||
|
||||
/*
|
||||
* xmlRelaxNGParserFlags:
|
||||
*
|
||||
* List of possible Relax NG Parser flags
|
||||
*/
|
||||
typedef enum {
|
||||
XML_RELAXNGP_NONE = 0,
|
||||
XML_RELAXNGP_FREE_DOC = 1,
|
||||
XML_RELAXNGP_CRNG = 2
|
||||
} xmlRelaxNGParserFlag;
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGInitTypes (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGCleanupTypes (void);
|
||||
|
||||
/*
|
||||
* Interfaces for parsing.
|
||||
*/
|
||||
XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
|
||||
xmlRelaxNGNewParserCtxt (const char *URL);
|
||||
XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
|
||||
xmlRelaxNGNewMemParserCtxt (const char *buffer,
|
||||
int size);
|
||||
XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
|
||||
xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt,
|
||||
int flag);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
xmlRelaxNGValidityErrorFunc err,
|
||||
xmlRelaxNGValidityWarningFunc warn,
|
||||
void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
|
||||
xmlRelaxNGValidityErrorFunc *err,
|
||||
xmlRelaxNGValidityWarningFunc *warn,
|
||||
void **ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGSetParserStructuredErrors(
|
||||
xmlRelaxNGParserCtxtPtr ctxt,
|
||||
xmlStructuredErrorFunc serror,
|
||||
void *ctx);
|
||||
XMLPUBFUN xmlRelaxNGPtr XMLCALL
|
||||
xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGFree (xmlRelaxNGPtr schema);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGDump (FILE *output,
|
||||
xmlRelaxNGPtr schema);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGDumpTree (FILE * output,
|
||||
xmlRelaxNGPtr schema);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
/*
|
||||
* Interfaces for validating
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlRelaxNGValidityErrorFunc err,
|
||||
xmlRelaxNGValidityWarningFunc warn,
|
||||
void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlRelaxNGValidityErrorFunc *err,
|
||||
xmlRelaxNGValidityWarningFunc *warn,
|
||||
void **ctx);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlStructuredErrorFunc serror, void *ctx);
|
||||
XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
|
||||
xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
/*
|
||||
* Interfaces for progressive validation when possible
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt,
|
||||
const xmlChar *data,
|
||||
int len);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_SCHEMAS_ENABLED */
|
||||
|
||||
#endif /* __XML_RELAX_NG__ */
|
||||
@@ -0,0 +1,958 @@
|
||||
/*
|
||||
* Summary: internal interfaces for XML Schemas
|
||||
* Description: internal interfaces for the XML Schemas handling
|
||||
* and schema validity checking
|
||||
* The Schemas development is a Work In Progress.
|
||||
* Some of those interfaces are not guaranteed to be API or ABI stable !
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_SCHEMA_INTERNALS_H__
|
||||
#define __XML_SCHEMA_INTERNALS_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
|
||||
#include <libxml/xmlregexp.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/dict.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
XML_SCHEMAS_UNKNOWN = 0,
|
||||
XML_SCHEMAS_STRING = 1,
|
||||
XML_SCHEMAS_NORMSTRING = 2,
|
||||
XML_SCHEMAS_DECIMAL = 3,
|
||||
XML_SCHEMAS_TIME = 4,
|
||||
XML_SCHEMAS_GDAY = 5,
|
||||
XML_SCHEMAS_GMONTH = 6,
|
||||
XML_SCHEMAS_GMONTHDAY = 7,
|
||||
XML_SCHEMAS_GYEAR = 8,
|
||||
XML_SCHEMAS_GYEARMONTH = 9,
|
||||
XML_SCHEMAS_DATE = 10,
|
||||
XML_SCHEMAS_DATETIME = 11,
|
||||
XML_SCHEMAS_DURATION = 12,
|
||||
XML_SCHEMAS_FLOAT = 13,
|
||||
XML_SCHEMAS_DOUBLE = 14,
|
||||
XML_SCHEMAS_BOOLEAN = 15,
|
||||
XML_SCHEMAS_TOKEN = 16,
|
||||
XML_SCHEMAS_LANGUAGE = 17,
|
||||
XML_SCHEMAS_NMTOKEN = 18,
|
||||
XML_SCHEMAS_NMTOKENS = 19,
|
||||
XML_SCHEMAS_NAME = 20,
|
||||
XML_SCHEMAS_QNAME = 21,
|
||||
XML_SCHEMAS_NCNAME = 22,
|
||||
XML_SCHEMAS_ID = 23,
|
||||
XML_SCHEMAS_IDREF = 24,
|
||||
XML_SCHEMAS_IDREFS = 25,
|
||||
XML_SCHEMAS_ENTITY = 26,
|
||||
XML_SCHEMAS_ENTITIES = 27,
|
||||
XML_SCHEMAS_NOTATION = 28,
|
||||
XML_SCHEMAS_ANYURI = 29,
|
||||
XML_SCHEMAS_INTEGER = 30,
|
||||
XML_SCHEMAS_NPINTEGER = 31,
|
||||
XML_SCHEMAS_NINTEGER = 32,
|
||||
XML_SCHEMAS_NNINTEGER = 33,
|
||||
XML_SCHEMAS_PINTEGER = 34,
|
||||
XML_SCHEMAS_INT = 35,
|
||||
XML_SCHEMAS_UINT = 36,
|
||||
XML_SCHEMAS_LONG = 37,
|
||||
XML_SCHEMAS_ULONG = 38,
|
||||
XML_SCHEMAS_SHORT = 39,
|
||||
XML_SCHEMAS_USHORT = 40,
|
||||
XML_SCHEMAS_BYTE = 41,
|
||||
XML_SCHEMAS_UBYTE = 42,
|
||||
XML_SCHEMAS_HEXBINARY = 43,
|
||||
XML_SCHEMAS_BASE64BINARY = 44,
|
||||
XML_SCHEMAS_ANYTYPE = 45,
|
||||
XML_SCHEMAS_ANYSIMPLETYPE = 46
|
||||
} xmlSchemaValType;
|
||||
|
||||
/*
|
||||
* XML Schemas defines multiple type of types.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */
|
||||
XML_SCHEMA_TYPE_ANY,
|
||||
XML_SCHEMA_TYPE_FACET,
|
||||
XML_SCHEMA_TYPE_SIMPLE,
|
||||
XML_SCHEMA_TYPE_COMPLEX,
|
||||
XML_SCHEMA_TYPE_SEQUENCE = 6,
|
||||
XML_SCHEMA_TYPE_CHOICE,
|
||||
XML_SCHEMA_TYPE_ALL,
|
||||
XML_SCHEMA_TYPE_SIMPLE_CONTENT,
|
||||
XML_SCHEMA_TYPE_COMPLEX_CONTENT,
|
||||
XML_SCHEMA_TYPE_UR,
|
||||
XML_SCHEMA_TYPE_RESTRICTION,
|
||||
XML_SCHEMA_TYPE_EXTENSION,
|
||||
XML_SCHEMA_TYPE_ELEMENT,
|
||||
XML_SCHEMA_TYPE_ATTRIBUTE,
|
||||
XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
|
||||
XML_SCHEMA_TYPE_GROUP,
|
||||
XML_SCHEMA_TYPE_NOTATION,
|
||||
XML_SCHEMA_TYPE_LIST,
|
||||
XML_SCHEMA_TYPE_UNION,
|
||||
XML_SCHEMA_TYPE_ANY_ATTRIBUTE,
|
||||
XML_SCHEMA_TYPE_IDC_UNIQUE,
|
||||
XML_SCHEMA_TYPE_IDC_KEY,
|
||||
XML_SCHEMA_TYPE_IDC_KEYREF,
|
||||
XML_SCHEMA_TYPE_PARTICLE = 25,
|
||||
XML_SCHEMA_TYPE_ATTRIBUTE_USE,
|
||||
XML_SCHEMA_FACET_MININCLUSIVE = 1000,
|
||||
XML_SCHEMA_FACET_MINEXCLUSIVE,
|
||||
XML_SCHEMA_FACET_MAXINCLUSIVE,
|
||||
XML_SCHEMA_FACET_MAXEXCLUSIVE,
|
||||
XML_SCHEMA_FACET_TOTALDIGITS,
|
||||
XML_SCHEMA_FACET_FRACTIONDIGITS,
|
||||
XML_SCHEMA_FACET_PATTERN,
|
||||
XML_SCHEMA_FACET_ENUMERATION,
|
||||
XML_SCHEMA_FACET_WHITESPACE,
|
||||
XML_SCHEMA_FACET_LENGTH,
|
||||
XML_SCHEMA_FACET_MAXLENGTH,
|
||||
XML_SCHEMA_FACET_MINLENGTH,
|
||||
XML_SCHEMA_EXTRA_QNAMEREF = 2000,
|
||||
XML_SCHEMA_EXTRA_ATTR_USE_PROHIB
|
||||
} xmlSchemaTypeType;
|
||||
|
||||
typedef enum {
|
||||
XML_SCHEMA_CONTENT_UNKNOWN = 0,
|
||||
XML_SCHEMA_CONTENT_EMPTY = 1,
|
||||
XML_SCHEMA_CONTENT_ELEMENTS,
|
||||
XML_SCHEMA_CONTENT_MIXED,
|
||||
XML_SCHEMA_CONTENT_SIMPLE,
|
||||
XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */
|
||||
XML_SCHEMA_CONTENT_BASIC,
|
||||
XML_SCHEMA_CONTENT_ANY
|
||||
} xmlSchemaContentType;
|
||||
|
||||
typedef struct _xmlSchemaVal xmlSchemaVal;
|
||||
typedef xmlSchemaVal *xmlSchemaValPtr;
|
||||
|
||||
typedef struct _xmlSchemaType xmlSchemaType;
|
||||
typedef xmlSchemaType *xmlSchemaTypePtr;
|
||||
|
||||
typedef struct _xmlSchemaFacet xmlSchemaFacet;
|
||||
typedef xmlSchemaFacet *xmlSchemaFacetPtr;
|
||||
|
||||
/**
|
||||
* Annotation
|
||||
*/
|
||||
typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
|
||||
typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
|
||||
struct _xmlSchemaAnnot {
|
||||
struct _xmlSchemaAnnot *next;
|
||||
xmlNodePtr content; /* the annotation */
|
||||
};
|
||||
|
||||
/**
|
||||
* XML_SCHEMAS_ANYATTR_SKIP:
|
||||
*
|
||||
* Skip unknown attribute from validation
|
||||
* Obsolete, not used anymore.
|
||||
*/
|
||||
#define XML_SCHEMAS_ANYATTR_SKIP 1
|
||||
/**
|
||||
* XML_SCHEMAS_ANYATTR_LAX:
|
||||
*
|
||||
* Ignore validation non definition on attributes
|
||||
* Obsolete, not used anymore.
|
||||
*/
|
||||
#define XML_SCHEMAS_ANYATTR_LAX 2
|
||||
/**
|
||||
* XML_SCHEMAS_ANYATTR_STRICT:
|
||||
*
|
||||
* Apply strict validation rules on attributes
|
||||
* Obsolete, not used anymore.
|
||||
*/
|
||||
#define XML_SCHEMAS_ANYATTR_STRICT 3
|
||||
/**
|
||||
* XML_SCHEMAS_ANY_SKIP:
|
||||
*
|
||||
* Skip unknown attribute from validation
|
||||
*/
|
||||
#define XML_SCHEMAS_ANY_SKIP 1
|
||||
/**
|
||||
* XML_SCHEMAS_ANY_LAX:
|
||||
*
|
||||
* Used by wildcards.
|
||||
* Validate if type found, don't worry if not found
|
||||
*/
|
||||
#define XML_SCHEMAS_ANY_LAX 2
|
||||
/**
|
||||
* XML_SCHEMAS_ANY_STRICT:
|
||||
*
|
||||
* Used by wildcards.
|
||||
* Apply strict validation rules
|
||||
*/
|
||||
#define XML_SCHEMAS_ANY_STRICT 3
|
||||
/**
|
||||
* XML_SCHEMAS_ATTR_USE_PROHIBITED:
|
||||
*
|
||||
* Used by wildcards.
|
||||
* The attribute is prohibited.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0
|
||||
/**
|
||||
* XML_SCHEMAS_ATTR_USE_REQUIRED:
|
||||
*
|
||||
* The attribute is required.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTR_USE_REQUIRED 1
|
||||
/**
|
||||
* XML_SCHEMAS_ATTR_USE_OPTIONAL:
|
||||
*
|
||||
* The attribute is optional.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2
|
||||
/**
|
||||
* XML_SCHEMAS_ATTR_GLOBAL:
|
||||
*
|
||||
* allow elements in no namespace
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTR_GLOBAL 1 << 0
|
||||
/**
|
||||
* XML_SCHEMAS_ATTR_NSDEFAULT:
|
||||
*
|
||||
* allow elements in no namespace
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
|
||||
/**
|
||||
* XML_SCHEMAS_ATTR_INTERNAL_RESOLVED:
|
||||
*
|
||||
* this is set when the "type" and "ref" references
|
||||
* have been resolved.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8
|
||||
/**
|
||||
* XML_SCHEMAS_ATTR_FIXED:
|
||||
*
|
||||
* the attribute has a fixed value
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTR_FIXED 1 << 9
|
||||
|
||||
/**
|
||||
* xmlSchemaAttribute:
|
||||
* An attribute definition.
|
||||
*/
|
||||
|
||||
typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
|
||||
typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
|
||||
struct _xmlSchemaAttribute {
|
||||
xmlSchemaTypeType type;
|
||||
struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */
|
||||
const xmlChar *name; /* the name of the declaration */
|
||||
const xmlChar *id; /* Deprecated; not used */
|
||||
const xmlChar *ref; /* Deprecated; not used */
|
||||
const xmlChar *refNs; /* Deprecated; not used */
|
||||
const xmlChar *typeName; /* the local name of the type definition */
|
||||
const xmlChar *typeNs; /* the ns URI of the type definition */
|
||||
xmlSchemaAnnotPtr annot;
|
||||
|
||||
xmlSchemaTypePtr base; /* Deprecated; not used */
|
||||
int occurs; /* Deprecated; not used */
|
||||
const xmlChar *defValue; /* The initial value of the value constraint */
|
||||
xmlSchemaTypePtr subtypes; /* the type definition */
|
||||
xmlNodePtr node;
|
||||
const xmlChar *targetNamespace;
|
||||
int flags;
|
||||
const xmlChar *refPrefix; /* Deprecated; not used */
|
||||
xmlSchemaValPtr defVal; /* The compiled value constraint */
|
||||
xmlSchemaAttributePtr refDecl; /* Deprecated; not used */
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlSchemaAttributeLink:
|
||||
* Used to build a list of attribute uses on complexType definitions.
|
||||
* WARNING: Deprecated; not used.
|
||||
*/
|
||||
typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink;
|
||||
typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr;
|
||||
struct _xmlSchemaAttributeLink {
|
||||
struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */
|
||||
struct _xmlSchemaAttribute *attr;/* the linked attribute */
|
||||
};
|
||||
|
||||
/**
|
||||
* XML_SCHEMAS_WILDCARD_COMPLETE:
|
||||
*
|
||||
* If the wildcard is complete.
|
||||
*/
|
||||
#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0
|
||||
|
||||
/**
|
||||
* xmlSchemaCharValueLink:
|
||||
* Used to build a list of namespaces on wildcards.
|
||||
*/
|
||||
typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs;
|
||||
typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr;
|
||||
struct _xmlSchemaWildcardNs {
|
||||
struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */
|
||||
const xmlChar *value;/* the value */
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlSchemaWildcard.
|
||||
* A wildcard.
|
||||
*/
|
||||
typedef struct _xmlSchemaWildcard xmlSchemaWildcard;
|
||||
typedef xmlSchemaWildcard *xmlSchemaWildcardPtr;
|
||||
struct _xmlSchemaWildcard {
|
||||
xmlSchemaTypeType type; /* The kind of type */
|
||||
const xmlChar *id; /* Deprecated; not used */
|
||||
xmlSchemaAnnotPtr annot;
|
||||
xmlNodePtr node;
|
||||
int minOccurs; /* Deprecated; not used */
|
||||
int maxOccurs; /* Deprecated; not used */
|
||||
int processContents;
|
||||
int any; /* Indicates if the ns constraint is of ##any */
|
||||
xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */
|
||||
xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/**
|
||||
* XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:
|
||||
*
|
||||
* The attribute wildcard has been built.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0
|
||||
/**
|
||||
* XML_SCHEMAS_ATTRGROUP_GLOBAL:
|
||||
*
|
||||
* The attribute group has been defined.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1
|
||||
/**
|
||||
* XML_SCHEMAS_ATTRGROUP_MARKED:
|
||||
*
|
||||
* Marks the attr group as marked; used for circular checks.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2
|
||||
|
||||
/**
|
||||
* XML_SCHEMAS_ATTRGROUP_REDEFINED:
|
||||
*
|
||||
* The attr group was redefined.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3
|
||||
/**
|
||||
* XML_SCHEMAS_ATTRGROUP_HAS_REFS:
|
||||
*
|
||||
* Whether this attr. group contains attr. group references.
|
||||
*/
|
||||
#define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4
|
||||
|
||||
/**
|
||||
* An attribute group definition.
|
||||
*
|
||||
* xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
|
||||
* must be kept similar
|
||||
*/
|
||||
typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
|
||||
typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
|
||||
struct _xmlSchemaAttributeGroup {
|
||||
xmlSchemaTypeType type; /* The kind of type */
|
||||
struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
|
||||
const xmlChar *name;
|
||||
const xmlChar *id;
|
||||
const xmlChar *ref; /* Deprecated; not used */
|
||||
const xmlChar *refNs; /* Deprecated; not used */
|
||||
xmlSchemaAnnotPtr annot;
|
||||
|
||||
xmlSchemaAttributePtr attributes; /* Deprecated; not used */
|
||||
xmlNodePtr node;
|
||||
int flags;
|
||||
xmlSchemaWildcardPtr attributeWildcard;
|
||||
const xmlChar *refPrefix; /* Deprecated; not used */
|
||||
xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */
|
||||
const xmlChar *targetNamespace;
|
||||
void *attrUses;
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlSchemaTypeLink:
|
||||
* Used to build a list of types (e.g. member types of
|
||||
* simpleType with variety "union").
|
||||
*/
|
||||
typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink;
|
||||
typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr;
|
||||
struct _xmlSchemaTypeLink {
|
||||
struct _xmlSchemaTypeLink *next;/* the next type link ... */
|
||||
xmlSchemaTypePtr type;/* the linked type */
|
||||
};
|
||||
|
||||
/**
|
||||
* xmlSchemaFacetLink:
|
||||
* Used to build a list of facets.
|
||||
*/
|
||||
typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink;
|
||||
typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr;
|
||||
struct _xmlSchemaFacetLink {
|
||||
struct _xmlSchemaFacetLink *next;/* the next facet link ... */
|
||||
xmlSchemaFacetPtr facet;/* the linked facet */
|
||||
};
|
||||
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_MIXED:
|
||||
*
|
||||
* the element content type is mixed
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_MIXED 1 << 0
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:
|
||||
*
|
||||
* the simple or complex type has a derivation method of "extension".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION:
|
||||
*
|
||||
* the simple or complex type has a derivation method of "restriction".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_GLOBAL:
|
||||
*
|
||||
* the type is global
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_GLOBAL 1 << 3
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD:
|
||||
*
|
||||
* the complexType owns an attribute wildcard, i.e.
|
||||
* it can be freed by the complexType
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 /* Obsolete. */
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_VARIETY_ABSENT:
|
||||
*
|
||||
* the simpleType has a variety of "absent".
|
||||
* TODO: Actually not necessary :-/, since if
|
||||
* none of the variety flags occur then it's
|
||||
* automatically absent.
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_VARIETY_LIST:
|
||||
*
|
||||
* the simpleType has a variety of "list".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_VARIETY_UNION:
|
||||
*
|
||||
* the simpleType has a variety of "union".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_VARIETY_ATOMIC:
|
||||
*
|
||||
* the simpleType has a variety of "union".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_FINAL_EXTENSION:
|
||||
*
|
||||
* the complexType has a final of "extension".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_FINAL_RESTRICTION:
|
||||
*
|
||||
* the simpleType/complexType has a final of "restriction".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_FINAL_LIST:
|
||||
*
|
||||
* the simpleType has a final of "list".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_FINAL_UNION:
|
||||
*
|
||||
* the simpleType has a final of "union".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_FINAL_DEFAULT:
|
||||
*
|
||||
* the simpleType has a final of "default".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE:
|
||||
*
|
||||
* Marks the item as a builtin primitive.
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_MARKED:
|
||||
*
|
||||
* Marks the item as marked; used for circular checks.
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_MARKED 1 << 16
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_BLOCK_DEFAULT:
|
||||
*
|
||||
* the complexType did not specify 'block' so use the default of the
|
||||
* <schema> item.
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_BLOCK_EXTENSION:
|
||||
*
|
||||
* the complexType has a 'block' of "extension".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_BLOCK_RESTRICTION:
|
||||
*
|
||||
* the complexType has a 'block' of "restriction".
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_ABSTRACT:
|
||||
*
|
||||
* the simple/complexType is abstract.
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_FACETSNEEDVALUE:
|
||||
*
|
||||
* indicates if the facets need a computed value
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_FACETSNEEDVALUE 1 << 21
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_INTERNAL_RESOLVED:
|
||||
*
|
||||
* indicates that the type was typefixed
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED 1 << 22
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_INTERNAL_INVALID:
|
||||
*
|
||||
* indicates that the type is invalid
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_INTERNAL_INVALID 1 << 23
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE:
|
||||
*
|
||||
* a whitespace-facet value of "preserve"
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE 1 << 24
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_WHITESPACE_REPLACE:
|
||||
*
|
||||
* a whitespace-facet value of "replace"
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE 1 << 25
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE:
|
||||
*
|
||||
* a whitespace-facet value of "collapse"
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE 1 << 26
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_HAS_FACETS:
|
||||
*
|
||||
* has facets
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_HAS_FACETS 1 << 27
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_NORMVALUENEEDED:
|
||||
*
|
||||
* indicates if the facets (pattern) need a normalized value
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_NORMVALUENEEDED 1 << 28
|
||||
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_FIXUP_1:
|
||||
*
|
||||
* First stage of fixup was done.
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_FIXUP_1 1 << 29
|
||||
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_REDEFINED:
|
||||
*
|
||||
* The type was redefined.
|
||||
*/
|
||||
#define XML_SCHEMAS_TYPE_REDEFINED 1 << 30
|
||||
/**
|
||||
* XML_SCHEMAS_TYPE_REDEFINING:
|
||||
*
|
||||
* The type redefines an other type.
|
||||
*/
|
||||
/* #define XML_SCHEMAS_TYPE_REDEFINING 1 << 31 */
|
||||
|
||||
/**
|
||||
* _xmlSchemaType:
|
||||
*
|
||||
* Schemas type definition.
|
||||
*/
|
||||
struct _xmlSchemaType {
|
||||
xmlSchemaTypeType type; /* The kind of type */
|
||||
struct _xmlSchemaType *next; /* the next type if in a sequence ... */
|
||||
const xmlChar *name;
|
||||
const xmlChar *id ; /* Deprecated; not used */
|
||||
const xmlChar *ref; /* Deprecated; not used */
|
||||
const xmlChar *refNs; /* Deprecated; not used */
|
||||
xmlSchemaAnnotPtr annot;
|
||||
xmlSchemaTypePtr subtypes;
|
||||
xmlSchemaAttributePtr attributes; /* Deprecated; not used */
|
||||
xmlNodePtr node;
|
||||
int minOccurs; /* Deprecated; not used */
|
||||
int maxOccurs; /* Deprecated; not used */
|
||||
|
||||
int flags;
|
||||
xmlSchemaContentType contentType;
|
||||
const xmlChar *base; /* Base type's local name */
|
||||
const xmlChar *baseNs; /* Base type's target namespace */
|
||||
xmlSchemaTypePtr baseType; /* The base type component */
|
||||
xmlSchemaFacetPtr facets; /* Local facets */
|
||||
struct _xmlSchemaType *redef; /* Deprecated; not used */
|
||||
int recurse; /* Obsolete */
|
||||
xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */
|
||||
xmlSchemaWildcardPtr attributeWildcard;
|
||||
int builtInType; /* Type of built-in types. */
|
||||
xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */
|
||||
xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */
|
||||
const xmlChar *refPrefix; /* Deprecated; not used */
|
||||
xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types.
|
||||
Could we use @subtypes for this? */
|
||||
xmlRegexpPtr contModel; /* Holds the automaton of the content model */
|
||||
const xmlChar *targetNamespace;
|
||||
void *attrUses;
|
||||
};
|
||||
|
||||
/*
|
||||
* xmlSchemaElement:
|
||||
* An element definition.
|
||||
*
|
||||
* xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
|
||||
* structures must be kept similar
|
||||
*/
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_NILLABLE:
|
||||
*
|
||||
* the element is nillable
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_GLOBAL:
|
||||
*
|
||||
* the element is global
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_DEFAULT:
|
||||
*
|
||||
* the element has a default value
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_FIXED:
|
||||
*
|
||||
* the element has a fixed value
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_FIXED 1 << 3
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_ABSTRACT:
|
||||
*
|
||||
* the element is abstract
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_TOPLEVEL:
|
||||
*
|
||||
* the element is top level
|
||||
* obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_REF:
|
||||
*
|
||||
* the element is a reference to a type
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_REF 1 << 6
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_NSDEFAULT:
|
||||
*
|
||||
* allow elements in no namespace
|
||||
* Obsolete, not used anymore.
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_INTERNAL_RESOLVED:
|
||||
*
|
||||
* this is set when "type", "ref", "substitutionGroup"
|
||||
* references have been resolved.
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_CIRCULAR:
|
||||
*
|
||||
* a helper flag for the search of circular references.
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_BLOCK_ABSENT:
|
||||
*
|
||||
* the "block" attribute is absent
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_BLOCK_EXTENSION:
|
||||
*
|
||||
* disallowed substitutions are absent
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:
|
||||
*
|
||||
* disallowed substitutions: "restriction"
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:
|
||||
*
|
||||
* disallowed substitutions: "substitution"
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_FINAL_ABSENT:
|
||||
*
|
||||
* substitution group exclusions are absent
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_FINAL_EXTENSION:
|
||||
*
|
||||
* substitution group exclusions: "extension"
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_FINAL_RESTRICTION:
|
||||
*
|
||||
* substitution group exclusions: "restriction"
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD:
|
||||
*
|
||||
* the declaration is a substitution group head
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD 1 << 17
|
||||
/**
|
||||
* XML_SCHEMAS_ELEM_INTERNAL_CHECKED:
|
||||
*
|
||||
* this is set when the elem decl has been checked against
|
||||
* all constraints
|
||||
*/
|
||||
#define XML_SCHEMAS_ELEM_INTERNAL_CHECKED 1 << 18
|
||||
|
||||
typedef struct _xmlSchemaElement xmlSchemaElement;
|
||||
typedef xmlSchemaElement *xmlSchemaElementPtr;
|
||||
struct _xmlSchemaElement {
|
||||
xmlSchemaTypeType type; /* The kind of type */
|
||||
struct _xmlSchemaType *next; /* Not used? */
|
||||
const xmlChar *name;
|
||||
const xmlChar *id; /* Deprecated; not used */
|
||||
const xmlChar *ref; /* Deprecated; not used */
|
||||
const xmlChar *refNs; /* Deprecated; not used */
|
||||
xmlSchemaAnnotPtr annot;
|
||||
xmlSchemaTypePtr subtypes; /* the type definition */
|
||||
xmlSchemaAttributePtr attributes;
|
||||
xmlNodePtr node;
|
||||
int minOccurs; /* Deprecated; not used */
|
||||
int maxOccurs; /* Deprecated; not used */
|
||||
|
||||
int flags;
|
||||
const xmlChar *targetNamespace;
|
||||
const xmlChar *namedType;
|
||||
const xmlChar *namedTypeNs;
|
||||
const xmlChar *substGroup;
|
||||
const xmlChar *substGroupNs;
|
||||
const xmlChar *scope;
|
||||
const xmlChar *value; /* The original value of the value constraint. */
|
||||
struct _xmlSchemaElement *refDecl; /* This will now be used for the
|
||||
substitution group affiliation */
|
||||
xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */
|
||||
xmlSchemaContentType contentType;
|
||||
const xmlChar *refPrefix; /* Deprecated; not used */
|
||||
xmlSchemaValPtr defVal; /* The compiled value constraint. */
|
||||
void *idcs; /* The identity-constraint defs */
|
||||
};
|
||||
|
||||
/*
|
||||
* XML_SCHEMAS_FACET_UNKNOWN:
|
||||
*
|
||||
* unknown facet handling
|
||||
*/
|
||||
#define XML_SCHEMAS_FACET_UNKNOWN 0
|
||||
/*
|
||||
* XML_SCHEMAS_FACET_PRESERVE:
|
||||
*
|
||||
* preserve the type of the facet
|
||||
*/
|
||||
#define XML_SCHEMAS_FACET_PRESERVE 1
|
||||
/*
|
||||
* XML_SCHEMAS_FACET_REPLACE:
|
||||
*
|
||||
* replace the type of the facet
|
||||
*/
|
||||
#define XML_SCHEMAS_FACET_REPLACE 2
|
||||
/*
|
||||
* XML_SCHEMAS_FACET_COLLAPSE:
|
||||
*
|
||||
* collapse the types of the facet
|
||||
*/
|
||||
#define XML_SCHEMAS_FACET_COLLAPSE 3
|
||||
/**
|
||||
* A facet definition.
|
||||
*/
|
||||
struct _xmlSchemaFacet {
|
||||
xmlSchemaTypeType type; /* The kind of type */
|
||||
struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
|
||||
const xmlChar *value; /* The original value */
|
||||
const xmlChar *id; /* Obsolete */
|
||||
xmlSchemaAnnotPtr annot;
|
||||
xmlNodePtr node;
|
||||
int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */
|
||||
int whitespace;
|
||||
xmlSchemaValPtr val; /* The compiled value */
|
||||
xmlRegexpPtr regexp; /* The regex for patterns */
|
||||
};
|
||||
|
||||
/**
|
||||
* A notation definition.
|
||||
*/
|
||||
typedef struct _xmlSchemaNotation xmlSchemaNotation;
|
||||
typedef xmlSchemaNotation *xmlSchemaNotationPtr;
|
||||
struct _xmlSchemaNotation {
|
||||
xmlSchemaTypeType type; /* The kind of type */
|
||||
const xmlChar *name;
|
||||
xmlSchemaAnnotPtr annot;
|
||||
const xmlChar *identifier;
|
||||
const xmlChar *targetNamespace;
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO: Actually all those flags used for the schema should sit
|
||||
* on the schema parser context, since they are used only
|
||||
* during parsing an XML schema document, and not available
|
||||
* on the component level as per spec.
|
||||
*/
|
||||
/**
|
||||
* XML_SCHEMAS_QUALIF_ELEM:
|
||||
*
|
||||
* Reflects elementFormDefault == qualified in
|
||||
* an XML schema document.
|
||||
*/
|
||||
#define XML_SCHEMAS_QUALIF_ELEM 1 << 0
|
||||
/**
|
||||
* XML_SCHEMAS_QUALIF_ATTR:
|
||||
*
|
||||
* Reflects attributeFormDefault == qualified in
|
||||
* an XML schema document.
|
||||
*/
|
||||
#define XML_SCHEMAS_QUALIF_ATTR 1 << 1
|
||||
/**
|
||||
* XML_SCHEMAS_FINAL_DEFAULT_EXTENSION:
|
||||
*
|
||||
* the schema has "extension" in the set of finalDefault.
|
||||
*/
|
||||
#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2
|
||||
/**
|
||||
* XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION:
|
||||
*
|
||||
* the schema has "restriction" in the set of finalDefault.
|
||||
*/
|
||||
#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3
|
||||
/**
|
||||
* XML_SCHEMAS_FINAL_DEFAULT_LIST:
|
||||
*
|
||||
* the schema has "list" in the set of finalDefault.
|
||||
*/
|
||||
#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4
|
||||
/**
|
||||
* XML_SCHEMAS_FINAL_DEFAULT_UNION:
|
||||
*
|
||||
* the schema has "union" in the set of finalDefault.
|
||||
*/
|
||||
#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5
|
||||
/**
|
||||
* XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION:
|
||||
*
|
||||
* the schema has "extension" in the set of blockDefault.
|
||||
*/
|
||||
#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6
|
||||
/**
|
||||
* XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION:
|
||||
*
|
||||
* the schema has "restriction" in the set of blockDefault.
|
||||
*/
|
||||
#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7
|
||||
/**
|
||||
* XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION:
|
||||
*
|
||||
* the schema has "substitution" in the set of blockDefault.
|
||||
*/
|
||||
#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8
|
||||
/**
|
||||
* XML_SCHEMAS_INCLUDING_CONVERT_NS:
|
||||
*
|
||||
* the schema is currently including an other schema with
|
||||
* no target namespace.
|
||||
*/
|
||||
#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9
|
||||
/**
|
||||
* _xmlSchema:
|
||||
*
|
||||
* A Schemas definition
|
||||
*/
|
||||
struct _xmlSchema {
|
||||
const xmlChar *name; /* schema name */
|
||||
const xmlChar *targetNamespace; /* the target namespace */
|
||||
const xmlChar *version;
|
||||
const xmlChar *id; /* Obsolete */
|
||||
xmlDocPtr doc;
|
||||
xmlSchemaAnnotPtr annot;
|
||||
int flags;
|
||||
|
||||
xmlHashTablePtr typeDecl;
|
||||
xmlHashTablePtr attrDecl;
|
||||
xmlHashTablePtr attrgrpDecl;
|
||||
xmlHashTablePtr elemDecl;
|
||||
xmlHashTablePtr notaDecl;
|
||||
|
||||
xmlHashTablePtr schemasImports;
|
||||
|
||||
void *_private; /* unused by the library for users or bindings */
|
||||
xmlHashTablePtr groupDecl;
|
||||
xmlDictPtr dict;
|
||||
void *includes; /* the includes, this is opaque for now */
|
||||
int preserve; /* whether to free the document */
|
||||
int counter; /* used to give anonymous components unique names */
|
||||
xmlHashTablePtr idcDef; /* All identity-constraint defs. */
|
||||
void *volatiles; /* Obsolete */
|
||||
};
|
||||
|
||||
XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
|
||||
XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_SCHEMAS_ENABLED */
|
||||
#endif /* __XML_SCHEMA_INTERNALS_H__ */
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Summary: XML Schemastron implementation
|
||||
* Description: interface to the XML Schematron validity checking.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_SCHEMATRON_H__
|
||||
#define __XML_SCHEMATRON_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef LIBXML_SCHEMATRON_ENABLED
|
||||
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */
|
||||
XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */
|
||||
XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */
|
||||
XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */
|
||||
XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */
|
||||
XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */
|
||||
XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */
|
||||
} xmlSchematronValidOptions;
|
||||
|
||||
/**
|
||||
* The schemas related types are kept internal
|
||||
*/
|
||||
typedef struct _xmlSchematron xmlSchematron;
|
||||
typedef xmlSchematron *xmlSchematronPtr;
|
||||
|
||||
/**
|
||||
* xmlSchematronValidityErrorFunc:
|
||||
* @ctx: the validation context
|
||||
* @msg: the message
|
||||
* @...: extra arguments
|
||||
*
|
||||
* Signature of an error callback from a Schematron validation
|
||||
*/
|
||||
typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...);
|
||||
|
||||
/**
|
||||
* xmlSchematronValidityWarningFunc:
|
||||
* @ctx: the validation context
|
||||
* @msg: the message
|
||||
* @...: extra arguments
|
||||
*
|
||||
* Signature of a warning callback from a Schematron validation
|
||||
*/
|
||||
typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...);
|
||||
|
||||
/**
|
||||
* A schemas validation context
|
||||
*/
|
||||
typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt;
|
||||
typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr;
|
||||
|
||||
typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt;
|
||||
typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr;
|
||||
|
||||
/*
|
||||
* Interfaces for parsing.
|
||||
*/
|
||||
XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
|
||||
xmlSchematronNewParserCtxt (const char *URL);
|
||||
XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
|
||||
xmlSchematronNewMemParserCtxt(const char *buffer,
|
||||
int size);
|
||||
XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
|
||||
xmlSchematronNewDocParserCtxt(xmlDocPtr doc);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt);
|
||||
/*****
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt,
|
||||
xmlSchematronValidityErrorFunc err,
|
||||
xmlSchematronValidityWarningFunc warn,
|
||||
void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt,
|
||||
xmlSchematronValidityErrorFunc * err,
|
||||
xmlSchematronValidityWarningFunc * warn,
|
||||
void **ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt);
|
||||
*****/
|
||||
XMLPUBFUN xmlSchematronPtr XMLCALL
|
||||
xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchematronFree (xmlSchematronPtr schema);
|
||||
/*
|
||||
* Interfaces for validating
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchematronSetValidStructuredErrors(
|
||||
xmlSchematronValidCtxtPtr ctxt,
|
||||
xmlStructuredErrorFunc serror,
|
||||
void *ctx);
|
||||
/******
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt,
|
||||
xmlSchematronValidityErrorFunc err,
|
||||
xmlSchematronValidityWarningFunc warn,
|
||||
void *ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt,
|
||||
xmlSchematronValidityErrorFunc *err,
|
||||
xmlSchematronValidityWarningFunc *warn,
|
||||
void **ctx);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt,
|
||||
int options);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt,
|
||||
xmlNodePtr elem);
|
||||
*******/
|
||||
|
||||
XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL
|
||||
xmlSchematronNewValidCtxt (xmlSchematronPtr schema,
|
||||
int options);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt,
|
||||
xmlDocPtr instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_SCHEMATRON_ENABLED */
|
||||
#endif /* __XML_SCHEMATRON_H__ */
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Summary: interfaces for thread handling
|
||||
* Description: set of generic threading related routines
|
||||
* should work with pthreads, Windows native or TLS threads
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_THREADS_H__
|
||||
#define __XML_THREADS_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* xmlMutex are a simple mutual exception locks.
|
||||
*/
|
||||
typedef struct _xmlMutex xmlMutex;
|
||||
typedef xmlMutex *xmlMutexPtr;
|
||||
|
||||
/*
|
||||
* xmlRMutex are reentrant mutual exception locks.
|
||||
*/
|
||||
typedef struct _xmlRMutex xmlRMutex;
|
||||
typedef xmlRMutex *xmlRMutexPtr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <libxml/globals.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
XMLPUBFUN xmlMutexPtr XMLCALL
|
||||
xmlNewMutex (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlMutexLock (xmlMutexPtr tok);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlMutexUnlock (xmlMutexPtr tok);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeMutex (xmlMutexPtr tok);
|
||||
|
||||
XMLPUBFUN xmlRMutexPtr XMLCALL
|
||||
xmlNewRMutex (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRMutexLock (xmlRMutexPtr tok);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRMutexUnlock (xmlRMutexPtr tok);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeRMutex (xmlRMutexPtr tok);
|
||||
|
||||
/*
|
||||
* Library wide APIs.
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlInitThreads (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlLockLibrary (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlUnlockLibrary(void);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlGetThreadId (void);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsMainThread (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCleanupThreads(void);
|
||||
XMLPUBFUN xmlGlobalStatePtr XMLCALL
|
||||
xmlGetGlobalState(void);
|
||||
|
||||
#ifdef HAVE_PTHREAD_H
|
||||
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
||||
#if defined(LIBXML_STATIC_FOR_DLL)
|
||||
int XMLCALL
|
||||
xmlDllMain(void *hinstDLL, unsigned long fdwReason,
|
||||
void *lpvReserved);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __XML_THREADS_H__ */
|
||||
1311
acer-env/lib/python3.10/site-packages/lxml/includes/libxml/tree.h
Normal file
1311
acer-env/lib/python3.10/site-packages/lxml/includes/libxml/tree.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Summary: library of generic URI related routines
|
||||
* Description: library of generic URI related routines
|
||||
* Implements RFC 2396
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_URI_H__
|
||||
#define __XML_URI_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlURI:
|
||||
*
|
||||
* A parsed URI reference. This is a struct containing the various fields
|
||||
* as described in RFC 2396 but separated for further processing.
|
||||
*
|
||||
* Note: query is a deprecated field which is incorrectly unescaped.
|
||||
* query_raw takes precedence over query if the former is set.
|
||||
* See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127
|
||||
*/
|
||||
typedef struct _xmlURI xmlURI;
|
||||
typedef xmlURI *xmlURIPtr;
|
||||
struct _xmlURI {
|
||||
char *scheme; /* the URI scheme */
|
||||
char *opaque; /* opaque part */
|
||||
char *authority; /* the authority part */
|
||||
char *server; /* the server part */
|
||||
char *user; /* the user part */
|
||||
int port; /* the port number */
|
||||
char *path; /* the path string */
|
||||
char *query; /* the query string (deprecated - use with caution) */
|
||||
char *fragment; /* the fragment identifier */
|
||||
int cleanup; /* parsing potentially unclean URI */
|
||||
char *query_raw; /* the query string (as it appears in the URI) */
|
||||
};
|
||||
|
||||
/*
|
||||
* This function is in tree.h:
|
||||
* xmlChar * xmlNodeGetBase (xmlDocPtr doc,
|
||||
* xmlNodePtr cur);
|
||||
*/
|
||||
XMLPUBFUN xmlURIPtr XMLCALL
|
||||
xmlCreateURI (void);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlBuildURI (const xmlChar *URI,
|
||||
const xmlChar *base);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlBuildRelativeURI (const xmlChar *URI,
|
||||
const xmlChar *base);
|
||||
XMLPUBFUN xmlURIPtr XMLCALL
|
||||
xmlParseURI (const char *str);
|
||||
XMLPUBFUN xmlURIPtr XMLCALL
|
||||
xmlParseURIRaw (const char *str,
|
||||
int raw);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParseURIReference (xmlURIPtr uri,
|
||||
const char *str);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlSaveUri (xmlURIPtr uri);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlPrintURI (FILE *stream,
|
||||
xmlURIPtr uri);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlURIEscapeStr (const xmlChar *str,
|
||||
const xmlChar *list);
|
||||
XMLPUBFUN char * XMLCALL
|
||||
xmlURIUnescapeString (const char *str,
|
||||
int len,
|
||||
char *target);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNormalizeURIPath (char *path);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlURIEscape (const xmlChar *str);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeURI (xmlURIPtr uri);
|
||||
XMLPUBFUN xmlChar* XMLCALL
|
||||
xmlCanonicPath (const xmlChar *path);
|
||||
XMLPUBFUN xmlChar* XMLCALL
|
||||
xmlPathToURI (const xmlChar *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_URI_H__ */
|
||||
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* Summary: The DTD validation
|
||||
* Description: API for the DTD handling and the validity checking
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __XML_VALID_H__
|
||||
#define __XML_VALID_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/list.h>
|
||||
#include <libxml/xmlautomata.h>
|
||||
#include <libxml/xmlregexp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Validation state added for non-determinist content model.
|
||||
*/
|
||||
typedef struct _xmlValidState xmlValidState;
|
||||
typedef xmlValidState *xmlValidStatePtr;
|
||||
|
||||
/**
|
||||
* xmlValidityErrorFunc:
|
||||
* @ctx: usually an xmlValidCtxtPtr to a validity error context,
|
||||
* but comes from ctxt->userData (which normally contains such
|
||||
* a pointer); ctxt->userData can be changed by the user.
|
||||
* @msg: the string to format *printf like vararg
|
||||
* @...: remaining arguments to the format
|
||||
*
|
||||
* Callback called when a validity error is found. This is a message
|
||||
* oriented function similar to an *printf function.
|
||||
*/
|
||||
typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
|
||||
const char *msg,
|
||||
...) LIBXML_ATTR_FORMAT(2,3);
|
||||
|
||||
/**
|
||||
* xmlValidityWarningFunc:
|
||||
* @ctx: usually an xmlValidCtxtPtr to a validity error context,
|
||||
* but comes from ctxt->userData (which normally contains such
|
||||
* a pointer); ctxt->userData can be changed by the user.
|
||||
* @msg: the string to format *printf like vararg
|
||||
* @...: remaining arguments to the format
|
||||
*
|
||||
* Callback called when a validity warning is found. This is a message
|
||||
* oriented function similar to an *printf function.
|
||||
*/
|
||||
typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,
|
||||
const char *msg,
|
||||
...) LIBXML_ATTR_FORMAT(2,3);
|
||||
|
||||
#ifdef IN_LIBXML
|
||||
/**
|
||||
* XML_CTXT_FINISH_DTD_0:
|
||||
*
|
||||
* Special value for finishDtd field when embedded in an xmlParserCtxt
|
||||
*/
|
||||
#define XML_CTXT_FINISH_DTD_0 0xabcd1234
|
||||
/**
|
||||
* XML_CTXT_FINISH_DTD_1:
|
||||
*
|
||||
* Special value for finishDtd field when embedded in an xmlParserCtxt
|
||||
*/
|
||||
#define XML_CTXT_FINISH_DTD_1 0xabcd1235
|
||||
#endif
|
||||
|
||||
/*
|
||||
* xmlValidCtxt:
|
||||
* An xmlValidCtxt is used for error reporting when validating.
|
||||
*/
|
||||
typedef struct _xmlValidCtxt xmlValidCtxt;
|
||||
typedef xmlValidCtxt *xmlValidCtxtPtr;
|
||||
struct _xmlValidCtxt {
|
||||
void *userData; /* user specific data block */
|
||||
xmlValidityErrorFunc error; /* the callback in case of errors */
|
||||
xmlValidityWarningFunc warning; /* the callback in case of warning */
|
||||
|
||||
/* Node analysis stack used when validating within entities */
|
||||
xmlNodePtr node; /* Current parsed Node */
|
||||
int nodeNr; /* Depth of the parsing stack */
|
||||
int nodeMax; /* Max depth of the parsing stack */
|
||||
xmlNodePtr *nodeTab; /* array of nodes */
|
||||
|
||||
unsigned int finishDtd; /* finished validating the Dtd ? */
|
||||
xmlDocPtr doc; /* the document */
|
||||
int valid; /* temporary validity check result */
|
||||
|
||||
/* state state used for non-determinist content validation */
|
||||
xmlValidState *vstate; /* current state */
|
||||
int vstateNr; /* Depth of the validation stack */
|
||||
int vstateMax; /* Max depth of the validation stack */
|
||||
xmlValidState *vstateTab; /* array of validation states */
|
||||
|
||||
#ifdef LIBXML_REGEXP_ENABLED
|
||||
xmlAutomataPtr am; /* the automata */
|
||||
xmlAutomataStatePtr state; /* used to build the automata */
|
||||
#else
|
||||
void *am;
|
||||
void *state;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* ALL notation declarations are stored in a table.
|
||||
* There is one table per DTD.
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlNotationTable;
|
||||
typedef xmlNotationTable *xmlNotationTablePtr;
|
||||
|
||||
/*
|
||||
* ALL element declarations are stored in a table.
|
||||
* There is one table per DTD.
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlElementTable;
|
||||
typedef xmlElementTable *xmlElementTablePtr;
|
||||
|
||||
/*
|
||||
* ALL attribute declarations are stored in a table.
|
||||
* There is one table per DTD.
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlAttributeTable;
|
||||
typedef xmlAttributeTable *xmlAttributeTablePtr;
|
||||
|
||||
/*
|
||||
* ALL IDs attributes are stored in a table.
|
||||
* There is one table per document.
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlIDTable;
|
||||
typedef xmlIDTable *xmlIDTablePtr;
|
||||
|
||||
/*
|
||||
* ALL Refs attributes are stored in a table.
|
||||
* There is one table per document.
|
||||
*/
|
||||
|
||||
typedef struct _xmlHashTable xmlRefTable;
|
||||
typedef xmlRefTable *xmlRefTablePtr;
|
||||
|
||||
/* Notation */
|
||||
XMLPUBFUN xmlNotationPtr XMLCALL
|
||||
xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *name,
|
||||
const xmlChar *PublicID,
|
||||
const xmlChar *SystemID);
|
||||
#ifdef LIBXML_TREE_ENABLED
|
||||
XMLPUBFUN xmlNotationTablePtr XMLCALL
|
||||
xmlCopyNotationTable (xmlNotationTablePtr table);
|
||||
#endif /* LIBXML_TREE_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeNotationTable (xmlNotationTablePtr table);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpNotationDecl (xmlBufferPtr buf,
|
||||
xmlNotationPtr nota);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpNotationTable (xmlBufferPtr buf,
|
||||
xmlNotationTablePtr table);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
/* Element Content */
|
||||
/* the non Doc version are being deprecated */
|
||||
XMLPUBFUN xmlElementContentPtr XMLCALL
|
||||
xmlNewElementContent (const xmlChar *name,
|
||||
xmlElementContentType type);
|
||||
XMLPUBFUN xmlElementContentPtr XMLCALL
|
||||
xmlCopyElementContent (xmlElementContentPtr content);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeElementContent (xmlElementContentPtr cur);
|
||||
/* the new versions with doc argument */
|
||||
XMLPUBFUN xmlElementContentPtr XMLCALL
|
||||
xmlNewDocElementContent (xmlDocPtr doc,
|
||||
const xmlChar *name,
|
||||
xmlElementContentType type);
|
||||
XMLPUBFUN xmlElementContentPtr XMLCALL
|
||||
xmlCopyDocElementContent(xmlDocPtr doc,
|
||||
xmlElementContentPtr content);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeDocElementContent(xmlDocPtr doc,
|
||||
xmlElementContentPtr cur);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSnprintfElementContent(char *buf,
|
||||
int size,
|
||||
xmlElementContentPtr content,
|
||||
int englob);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
/* DEPRECATED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlSprintfElementContent(char *buf,
|
||||
xmlElementContentPtr content,
|
||||
int englob);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
/* DEPRECATED */
|
||||
|
||||
/* Element */
|
||||
XMLPUBFUN xmlElementPtr XMLCALL
|
||||
xmlAddElementDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *name,
|
||||
xmlElementTypeVal type,
|
||||
xmlElementContentPtr content);
|
||||
#ifdef LIBXML_TREE_ENABLED
|
||||
XMLPUBFUN xmlElementTablePtr XMLCALL
|
||||
xmlCopyElementTable (xmlElementTablePtr table);
|
||||
#endif /* LIBXML_TREE_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeElementTable (xmlElementTablePtr table);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpElementTable (xmlBufferPtr buf,
|
||||
xmlElementTablePtr table);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpElementDecl (xmlBufferPtr buf,
|
||||
xmlElementPtr elem);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
/* Enumeration */
|
||||
XMLPUBFUN xmlEnumerationPtr XMLCALL
|
||||
xmlCreateEnumeration (const xmlChar *name);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeEnumeration (xmlEnumerationPtr cur);
|
||||
#ifdef LIBXML_TREE_ENABLED
|
||||
XMLPUBFUN xmlEnumerationPtr XMLCALL
|
||||
xmlCopyEnumeration (xmlEnumerationPtr cur);
|
||||
#endif /* LIBXML_TREE_ENABLED */
|
||||
|
||||
/* Attribute */
|
||||
XMLPUBFUN xmlAttributePtr XMLCALL
|
||||
xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDtdPtr dtd,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns,
|
||||
xmlAttributeType type,
|
||||
xmlAttributeDefault def,
|
||||
const xmlChar *defaultValue,
|
||||
xmlEnumerationPtr tree);
|
||||
#ifdef LIBXML_TREE_ENABLED
|
||||
XMLPUBFUN xmlAttributeTablePtr XMLCALL
|
||||
xmlCopyAttributeTable (xmlAttributeTablePtr table);
|
||||
#endif /* LIBXML_TREE_ENABLED */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeAttributeTable (xmlAttributeTablePtr table);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpAttributeTable (xmlBufferPtr buf,
|
||||
xmlAttributeTablePtr table);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlDumpAttributeDecl (xmlBufferPtr buf,
|
||||
xmlAttributePtr attr);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
/* IDs */
|
||||
XMLPUBFUN xmlIDPtr XMLCALL
|
||||
xmlAddID (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
xmlAttrPtr attr);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeIDTable (xmlIDTablePtr table);
|
||||
XMLPUBFUN xmlAttrPtr XMLCALL
|
||||
xmlGetID (xmlDocPtr doc,
|
||||
const xmlChar *ID);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsID (xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRemoveID (xmlDocPtr doc,
|
||||
xmlAttrPtr attr);
|
||||
|
||||
/* IDREFs */
|
||||
XMLPUBFUN xmlRefPtr XMLCALL
|
||||
xmlAddRef (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *value,
|
||||
xmlAttrPtr attr);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeRefTable (xmlRefTablePtr table);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsRef (xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRemoveRef (xmlDocPtr doc,
|
||||
xmlAttrPtr attr);
|
||||
XMLPUBFUN xmlListPtr XMLCALL
|
||||
xmlGetRefs (xmlDocPtr doc,
|
||||
const xmlChar *ID);
|
||||
|
||||
/**
|
||||
* The public function calls related to validity checking.
|
||||
*/
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
/* Allocate/Release Validation Contexts */
|
||||
XMLPUBFUN xmlValidCtxtPtr XMLCALL
|
||||
xmlNewValidCtxt(void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeValidCtxt(xmlValidCtxtPtr);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateRoot (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlElementPtr elem);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlValidNormalizeAttributeValue(xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlAttributePtr attr);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateAttributeValue(xmlAttributeType type,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNotationPtr nota);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateDtd (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlDtdPtr dtd);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateDocument (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateOneElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
xmlAttrPtr attr,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
const xmlChar *prefix,
|
||||
xmlNsPtr ns,
|
||||
const xmlChar *value);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc);
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
|
||||
#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
const xmlChar *notationName);
|
||||
#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIsMixedElement (xmlDocPtr doc,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlAttributePtr XMLCALL
|
||||
xmlGetDtdAttrDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlAttributePtr XMLCALL
|
||||
xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *elem,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix);
|
||||
XMLPUBFUN xmlNotationPtr XMLCALL
|
||||
xmlGetDtdNotationDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *name);
|
||||
XMLPUBFUN xmlElementPtr XMLCALL
|
||||
xmlGetDtdQElementDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *name,
|
||||
const xmlChar *prefix);
|
||||
XMLPUBFUN xmlElementPtr XMLCALL
|
||||
xmlGetDtdElementDesc (xmlDtdPtr dtd,
|
||||
const xmlChar *name);
|
||||
|
||||
#ifdef LIBXML_VALID_ENABLED
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidGetPotentialChildren(xmlElementContent *ctree,
|
||||
const xmlChar **names,
|
||||
int *len,
|
||||
int max);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidGetValidElements(xmlNode *prev,
|
||||
xmlNode *next,
|
||||
const xmlChar **names,
|
||||
int max);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateNameValue (const xmlChar *value);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateNamesValue (const xmlChar *value);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateNmtokenValue (const xmlChar *value);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidateNmtokensValue(const xmlChar *value);
|
||||
|
||||
#ifdef LIBXML_REGEXP_ENABLED
|
||||
/*
|
||||
* Validation based on the regexp support
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
|
||||
xmlElementPtr elem);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidatePushElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
const xmlChar *qname);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidatePushCData (xmlValidCtxtPtr ctxt,
|
||||
const xmlChar *data,
|
||||
int len);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlValidatePopElement (xmlValidCtxtPtr ctxt,
|
||||
xmlDocPtr doc,
|
||||
xmlNodePtr elem,
|
||||
const xmlChar *qname);
|
||||
#endif /* LIBXML_REGEXP_ENABLED */
|
||||
#endif /* LIBXML_VALID_ENABLED */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __XML_VALID_H__ */
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Summary: implementation of XInclude
|
||||
* Description: API to handle XInclude processing,
|
||||
* implements the
|
||||
* World Wide Web Consortium Last Call Working Draft 10 November 2003
|
||||
* http://www.w3.org/TR/2003/WD-xinclude-20031110
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_XINCLUDE_H__
|
||||
#define __XML_XINCLUDE_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* XINCLUDE_NS:
|
||||
*
|
||||
* Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude
|
||||
*/
|
||||
#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2003/XInclude"
|
||||
/**
|
||||
* XINCLUDE_OLD_NS:
|
||||
*
|
||||
* Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude
|
||||
*/
|
||||
#define XINCLUDE_OLD_NS (const xmlChar *) "http://www.w3.org/2001/XInclude"
|
||||
/**
|
||||
* XINCLUDE_NODE:
|
||||
*
|
||||
* Macro defining "include"
|
||||
*/
|
||||
#define XINCLUDE_NODE (const xmlChar *) "include"
|
||||
/**
|
||||
* XINCLUDE_FALLBACK:
|
||||
*
|
||||
* Macro defining "fallback"
|
||||
*/
|
||||
#define XINCLUDE_FALLBACK (const xmlChar *) "fallback"
|
||||
/**
|
||||
* XINCLUDE_HREF:
|
||||
*
|
||||
* Macro defining "href"
|
||||
*/
|
||||
#define XINCLUDE_HREF (const xmlChar *) "href"
|
||||
/**
|
||||
* XINCLUDE_PARSE:
|
||||
*
|
||||
* Macro defining "parse"
|
||||
*/
|
||||
#define XINCLUDE_PARSE (const xmlChar *) "parse"
|
||||
/**
|
||||
* XINCLUDE_PARSE_XML:
|
||||
*
|
||||
* Macro defining "xml"
|
||||
*/
|
||||
#define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
|
||||
/**
|
||||
* XINCLUDE_PARSE_TEXT:
|
||||
*
|
||||
* Macro defining "text"
|
||||
*/
|
||||
#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
|
||||
/**
|
||||
* XINCLUDE_PARSE_ENCODING:
|
||||
*
|
||||
* Macro defining "encoding"
|
||||
*/
|
||||
#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding"
|
||||
/**
|
||||
* XINCLUDE_PARSE_XPOINTER:
|
||||
*
|
||||
* Macro defining "xpointer"
|
||||
*/
|
||||
#define XINCLUDE_PARSE_XPOINTER (const xmlChar *) "xpointer"
|
||||
|
||||
typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt;
|
||||
typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;
|
||||
|
||||
/*
|
||||
* standalone processing
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcess (xmlDocPtr doc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessFlags (xmlDocPtr doc,
|
||||
int flags);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessFlagsData(xmlDocPtr doc,
|
||||
int flags,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree,
|
||||
int flags,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessTree (xmlNodePtr tree);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessTreeFlags(xmlNodePtr tree,
|
||||
int flags);
|
||||
/*
|
||||
* contextual processing
|
||||
*/
|
||||
XMLPUBFUN xmlXIncludeCtxtPtr XMLCALL
|
||||
xmlXIncludeNewContext (xmlDocPtr doc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeSetFlags (xmlXIncludeCtxtPtr ctxt,
|
||||
int flags);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessNode (xmlXIncludeCtxtPtr ctxt,
|
||||
xmlNodePtr tree);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_XINCLUDE_ENABLED */
|
||||
|
||||
#endif /* __XML_XINCLUDE_H__ */
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Summary: unfinished XLink detection module
|
||||
* Description: unfinished XLink detection module
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_XLINK_H__
|
||||
#define __XML_XLINK_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_XPTR_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Various defines for the various Link properties.
|
||||
*
|
||||
* NOTE: the link detection layer will try to resolve QName expansion
|
||||
* of namespaces. If "foo" is the prefix for "http://foo.com/"
|
||||
* then the link detection layer will expand role="foo:myrole"
|
||||
* to "http://foo.com/:myrole".
|
||||
* NOTE: the link detection layer will expand URI-References found on
|
||||
* href attributes by using the base mechanism if found.
|
||||
*/
|
||||
typedef xmlChar *xlinkHRef;
|
||||
typedef xmlChar *xlinkRole;
|
||||
typedef xmlChar *xlinkTitle;
|
||||
|
||||
typedef enum {
|
||||
XLINK_TYPE_NONE = 0,
|
||||
XLINK_TYPE_SIMPLE,
|
||||
XLINK_TYPE_EXTENDED,
|
||||
XLINK_TYPE_EXTENDED_SET
|
||||
} xlinkType;
|
||||
|
||||
typedef enum {
|
||||
XLINK_SHOW_NONE = 0,
|
||||
XLINK_SHOW_NEW,
|
||||
XLINK_SHOW_EMBED,
|
||||
XLINK_SHOW_REPLACE
|
||||
} xlinkShow;
|
||||
|
||||
typedef enum {
|
||||
XLINK_ACTUATE_NONE = 0,
|
||||
XLINK_ACTUATE_AUTO,
|
||||
XLINK_ACTUATE_ONREQUEST
|
||||
} xlinkActuate;
|
||||
|
||||
/**
|
||||
* xlinkNodeDetectFunc:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node to check
|
||||
*
|
||||
* This is the prototype for the link detection routine.
|
||||
* It calls the default link detection callbacks upon link detection.
|
||||
*/
|
||||
typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);
|
||||
|
||||
/*
|
||||
* The link detection module interact with the upper layers using
|
||||
* a set of callback registered at parsing time.
|
||||
*/
|
||||
|
||||
/**
|
||||
* xlinkSimpleLinkFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @href: the target of the link
|
||||
* @role: the role string
|
||||
* @title: the link title
|
||||
*
|
||||
* This is the prototype for a simple link detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkSimpleLinkFunk) (void *ctx,
|
||||
xmlNodePtr node,
|
||||
const xlinkHRef href,
|
||||
const xlinkRole role,
|
||||
const xlinkTitle title);
|
||||
|
||||
/**
|
||||
* xlinkExtendedLinkFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @nbLocators: the number of locators detected on the link
|
||||
* @hrefs: pointer to the array of locator hrefs
|
||||
* @roles: pointer to the array of locator roles
|
||||
* @nbArcs: the number of arcs detected on the link
|
||||
* @from: pointer to the array of source roles found on the arcs
|
||||
* @to: pointer to the array of target roles found on the arcs
|
||||
* @show: array of values for the show attributes found on the arcs
|
||||
* @actuate: array of values for the actuate attributes found on the arcs
|
||||
* @nbTitles: the number of titles detected on the link
|
||||
* @title: array of titles detected on the link
|
||||
* @langs: array of xml:lang values for the titles
|
||||
*
|
||||
* This is the prototype for a extended link detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkExtendedLinkFunk)(void *ctx,
|
||||
xmlNodePtr node,
|
||||
int nbLocators,
|
||||
const xlinkHRef *hrefs,
|
||||
const xlinkRole *roles,
|
||||
int nbArcs,
|
||||
const xlinkRole *from,
|
||||
const xlinkRole *to,
|
||||
xlinkShow *show,
|
||||
xlinkActuate *actuate,
|
||||
int nbTitles,
|
||||
const xlinkTitle *titles,
|
||||
const xmlChar **langs);
|
||||
|
||||
/**
|
||||
* xlinkExtendedLinkSetFunk:
|
||||
* @ctx: user data pointer
|
||||
* @node: the node carrying the link
|
||||
* @nbLocators: the number of locators detected on the link
|
||||
* @hrefs: pointer to the array of locator hrefs
|
||||
* @roles: pointer to the array of locator roles
|
||||
* @nbTitles: the number of titles detected on the link
|
||||
* @title: array of titles detected on the link
|
||||
* @langs: array of xml:lang values for the titles
|
||||
*
|
||||
* This is the prototype for a extended link set detection callback.
|
||||
*/
|
||||
typedef void
|
||||
(*xlinkExtendedLinkSetFunk) (void *ctx,
|
||||
xmlNodePtr node,
|
||||
int nbLocators,
|
||||
const xlinkHRef *hrefs,
|
||||
const xlinkRole *roles,
|
||||
int nbTitles,
|
||||
const xlinkTitle *titles,
|
||||
const xmlChar **langs);
|
||||
|
||||
/**
|
||||
* This is the structure containing a set of Links detection callbacks.
|
||||
*
|
||||
* There is no default xlink callbacks, if one want to get link
|
||||
* recognition activated, those call backs must be provided before parsing.
|
||||
*/
|
||||
typedef struct _xlinkHandler xlinkHandler;
|
||||
typedef xlinkHandler *xlinkHandlerPtr;
|
||||
struct _xlinkHandler {
|
||||
xlinkSimpleLinkFunk simple;
|
||||
xlinkExtendedLinkFunk extended;
|
||||
xlinkExtendedLinkSetFunk set;
|
||||
};
|
||||
|
||||
/*
|
||||
* The default detection routine, can be overridden, they call the default
|
||||
* detection callbacks.
|
||||
*/
|
||||
|
||||
XMLPUBFUN xlinkNodeDetectFunc XMLCALL
|
||||
xlinkGetDefaultDetect (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
|
||||
|
||||
/*
|
||||
* Routines to set/get the default handlers.
|
||||
*/
|
||||
XMLPUBFUN xlinkHandlerPtr XMLCALL
|
||||
xlinkGetDefaultHandler (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xlinkSetDefaultHandler (xlinkHandlerPtr handler);
|
||||
|
||||
/*
|
||||
* Link detection module itself.
|
||||
*/
|
||||
XMLPUBFUN xlinkType XMLCALL
|
||||
xlinkIsLink (xmlDocPtr doc,
|
||||
xmlNodePtr node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_XPTR_ENABLED */
|
||||
|
||||
#endif /* __XML_XLINK_H__ */
|
||||
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* Summary: interface for the I/O interfaces used by the parser
|
||||
* Description: interface for the I/O interfaces used by the parser
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_IO_H__
|
||||
#define __XML_IO_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Those are the functions and datatypes for the parser input
|
||||
* I/O structures.
|
||||
*/
|
||||
|
||||
/**
|
||||
* xmlInputMatchCallback:
|
||||
* @filename: the filename or URI
|
||||
*
|
||||
* Callback used in the I/O Input API to detect if the current handler
|
||||
* can provide input functionality for this resource.
|
||||
*
|
||||
* Returns 1 if yes and 0 if another Input module should be used
|
||||
*/
|
||||
typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename);
|
||||
/**
|
||||
* xmlInputOpenCallback:
|
||||
* @filename: the filename or URI
|
||||
*
|
||||
* Callback used in the I/O Input API to open the resource
|
||||
*
|
||||
* Returns an Input context or NULL in case or error
|
||||
*/
|
||||
typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename);
|
||||
/**
|
||||
* xmlInputReadCallback:
|
||||
* @context: an Input context
|
||||
* @buffer: the buffer to store data read
|
||||
* @len: the length of the buffer in bytes
|
||||
*
|
||||
* Callback used in the I/O Input API to read the resource
|
||||
*
|
||||
* Returns the number of bytes read or -1 in case of error
|
||||
*/
|
||||
typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len);
|
||||
/**
|
||||
* xmlInputCloseCallback:
|
||||
* @context: an Input context
|
||||
*
|
||||
* Callback used in the I/O Input API to close the resource
|
||||
*
|
||||
* Returns 0 or -1 in case of error
|
||||
*/
|
||||
typedef int (XMLCALL *xmlInputCloseCallback) (void * context);
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
/*
|
||||
* Those are the functions and datatypes for the library output
|
||||
* I/O structures.
|
||||
*/
|
||||
|
||||
/**
|
||||
* xmlOutputMatchCallback:
|
||||
* @filename: the filename or URI
|
||||
*
|
||||
* Callback used in the I/O Output API to detect if the current handler
|
||||
* can provide output functionality for this resource.
|
||||
*
|
||||
* Returns 1 if yes and 0 if another Output module should be used
|
||||
*/
|
||||
typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename);
|
||||
/**
|
||||
* xmlOutputOpenCallback:
|
||||
* @filename: the filename or URI
|
||||
*
|
||||
* Callback used in the I/O Output API to open the resource
|
||||
*
|
||||
* Returns an Output context or NULL in case or error
|
||||
*/
|
||||
typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename);
|
||||
/**
|
||||
* xmlOutputWriteCallback:
|
||||
* @context: an Output context
|
||||
* @buffer: the buffer of data to write
|
||||
* @len: the length of the buffer in bytes
|
||||
*
|
||||
* Callback used in the I/O Output API to write to the resource
|
||||
*
|
||||
* Returns the number of bytes written or -1 in case of error
|
||||
*/
|
||||
typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer,
|
||||
int len);
|
||||
/**
|
||||
* xmlOutputCloseCallback:
|
||||
* @context: an Output context
|
||||
*
|
||||
* Callback used in the I/O Output API to close the resource
|
||||
*
|
||||
* Returns 0 or -1 in case of error
|
||||
*/
|
||||
typedef int (XMLCALL *xmlOutputCloseCallback) (void * context);
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/encoding.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
struct _xmlParserInputBuffer {
|
||||
void* context;
|
||||
xmlInputReadCallback readcallback;
|
||||
xmlInputCloseCallback closecallback;
|
||||
|
||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||
|
||||
xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */
|
||||
xmlBufPtr raw; /* if encoder != NULL buffer for raw input */
|
||||
int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
|
||||
int error;
|
||||
unsigned long rawconsumed;/* amount consumed from raw */
|
||||
};
|
||||
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
struct _xmlOutputBuffer {
|
||||
void* context;
|
||||
xmlOutputWriteCallback writecallback;
|
||||
xmlOutputCloseCallback closecallback;
|
||||
|
||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||
|
||||
xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
|
||||
xmlBufPtr conv; /* if encoder != NULL buffer for output */
|
||||
int written; /* total number of byte written */
|
||||
int error;
|
||||
};
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
/*
|
||||
* Interfaces for input
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCleanupInputCallbacks (void);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPopInputCallbacks (void);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRegisterDefaultInputCallbacks (void);
|
||||
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
|
||||
xmlAllocParserInputBuffer (xmlCharEncoding enc);
|
||||
|
||||
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
|
||||
xmlParserInputBufferCreateFilename (const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
|
||||
xmlParserInputBufferCreateFile (FILE *file,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
|
||||
xmlParserInputBufferCreateFd (int fd,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
|
||||
xmlParserInputBufferCreateMem (const char *mem, int size,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
|
||||
xmlParserInputBufferCreateStatic (const char *mem, int size,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
|
||||
xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParserInputBufferRead (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlParserInputBufferPush (xmlParserInputBufferPtr in,
|
||||
int len,
|
||||
const char *buf);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
|
||||
XMLPUBFUN char * XMLCALL
|
||||
xmlParserGetDirectory (const char *filename);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
|
||||
xmlInputOpenCallback openFunc,
|
||||
xmlInputReadCallback readFunc,
|
||||
xmlInputCloseCallback closeFunc);
|
||||
|
||||
xmlParserInputBufferPtr
|
||||
__xmlParserInputBufferCreateFilename(const char *URI,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
/*
|
||||
* Interfaces for output
|
||||
*/
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCleanupOutputCallbacks (void);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPopOutputCallbacks (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRegisterDefaultOutputCallbacks(void);
|
||||
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||
xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||
xmlOutputBufferCreateFilename (const char *URI,
|
||||
xmlCharEncodingHandlerPtr encoder,
|
||||
int compression);
|
||||
|
||||
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||
xmlOutputBufferCreateFile (FILE *file,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||
xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||
xmlOutputBufferCreateFd (int fd,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||
xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite,
|
||||
xmlOutputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
/* Couple of APIs to get the output without digging into the buffers */
|
||||
XMLPUBFUN const xmlChar * XMLCALL
|
||||
xmlOutputBufferGetContent (xmlOutputBufferPtr out);
|
||||
XMLPUBFUN size_t XMLCALL
|
||||
xmlOutputBufferGetSize (xmlOutputBufferPtr out);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
||||
int len,
|
||||
const char *buf);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlOutputBufferWriteString (xmlOutputBufferPtr out,
|
||||
const char *str);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlOutputBufferWriteEscape (xmlOutputBufferPtr out,
|
||||
const xmlChar *str,
|
||||
xmlCharEncodingOutputFunc escaping);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlOutputBufferFlush (xmlOutputBufferPtr out);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlOutputBufferClose (xmlOutputBufferPtr out);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
|
||||
xmlOutputOpenCallback openFunc,
|
||||
xmlOutputWriteCallback writeFunc,
|
||||
xmlOutputCloseCallback closeFunc);
|
||||
|
||||
xmlOutputBufferPtr
|
||||
__xmlOutputBufferCreateFilename(const char *URI,
|
||||
xmlCharEncodingHandlerPtr encoder,
|
||||
int compression);
|
||||
|
||||
#ifdef LIBXML_HTTP_ENABLED
|
||||
/* This function only exists if HTTP support built into the library */
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlRegisterHTTPPostCallbacks (void );
|
||||
#endif /* LIBXML_HTTP_ENABLED */
|
||||
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputPtr ret);
|
||||
|
||||
/*
|
||||
* A predefined entity loader disabling network accesses
|
||||
*/
|
||||
XMLPUBFUN xmlParserInputPtr XMLCALL
|
||||
xmlNoNetExternalEntityLoader (const char *URL,
|
||||
const char *ID,
|
||||
xmlParserCtxtPtr ctxt);
|
||||
|
||||
/*
|
||||
* xmlNormalizeWindowsPath is obsolete, don't use it.
|
||||
* Check xmlCanonicPath in uri.h for a better alternative.
|
||||
*/
|
||||
XMLPUBFUN xmlChar * XMLCALL
|
||||
xmlNormalizeWindowsPath (const xmlChar *path);
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCheckFilename (const char *path);
|
||||
/**
|
||||
* Default 'file://' protocol callbacks
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlFileMatch (const char *filename);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlFileOpen (const char *filename);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlFileRead (void * context,
|
||||
char * buffer,
|
||||
int len);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlFileClose (void * context);
|
||||
|
||||
/**
|
||||
* Default 'http://' protocol callbacks
|
||||
*/
|
||||
#ifdef LIBXML_HTTP_ENABLED
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIOHTTPMatch (const char *filename);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlIOHTTPOpen (const char *filename);
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlIOHTTPOpenW (const char * post_uri,
|
||||
int compression );
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIOHTTPRead (void * context,
|
||||
char * buffer,
|
||||
int len);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIOHTTPClose (void * context);
|
||||
#endif /* LIBXML_HTTP_ENABLED */
|
||||
|
||||
/**
|
||||
* Default 'ftp://' protocol callbacks
|
||||
*/
|
||||
#ifdef LIBXML_FTP_ENABLED
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIOFTPMatch (const char *filename);
|
||||
XMLPUBFUN void * XMLCALL
|
||||
xmlIOFTPOpen (const char *filename);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIOFTPRead (void * context,
|
||||
char * buffer,
|
||||
int len);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlIOFTPClose (void * context);
|
||||
#endif /* LIBXML_FTP_ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_IO_H__ */
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Summary: API to build regexp automata
|
||||
* Description: the API to build regexp automata
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_AUTOMATA_H__
|
||||
#define __XML_AUTOMATA_H__
|
||||
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#ifdef LIBXML_REGEXP_ENABLED
|
||||
#ifdef LIBXML_AUTOMATA_ENABLED
|
||||
#include <libxml/xmlregexp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlAutomataPtr:
|
||||
*
|
||||
* A libxml automata description, It can be compiled into a regexp
|
||||
*/
|
||||
typedef struct _xmlAutomata xmlAutomata;
|
||||
typedef xmlAutomata *xmlAutomataPtr;
|
||||
|
||||
/**
|
||||
* xmlAutomataStatePtr:
|
||||
*
|
||||
* A state int the automata description,
|
||||
*/
|
||||
typedef struct _xmlAutomataState xmlAutomataState;
|
||||
typedef xmlAutomataState *xmlAutomataStatePtr;
|
||||
|
||||
/*
|
||||
* Building API
|
||||
*/
|
||||
XMLPUBFUN xmlAutomataPtr XMLCALL
|
||||
xmlNewAutomata (void);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeAutomata (xmlAutomataPtr am);
|
||||
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataGetInitState (xmlAutomataPtr am);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlAutomataSetFinalState (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr state);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewState (xmlAutomataPtr am);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewTransition (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
const xmlChar *token,
|
||||
void *data);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewTransition2 (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
const xmlChar *token,
|
||||
const xmlChar *token2,
|
||||
void *data);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewNegTrans (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
const xmlChar *token,
|
||||
const xmlChar *token2,
|
||||
void *data);
|
||||
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewCountTrans (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
const xmlChar *token,
|
||||
int min,
|
||||
int max,
|
||||
void *data);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewCountTrans2 (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
const xmlChar *token,
|
||||
const xmlChar *token2,
|
||||
int min,
|
||||
int max,
|
||||
void *data);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewOnceTrans (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
const xmlChar *token,
|
||||
int min,
|
||||
int max,
|
||||
void *data);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewOnceTrans2 (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
const xmlChar *token,
|
||||
const xmlChar *token2,
|
||||
int min,
|
||||
int max,
|
||||
void *data);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewAllTrans (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
int lax);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewEpsilon (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewCountedTrans (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
int counter);
|
||||
XMLPUBFUN xmlAutomataStatePtr XMLCALL
|
||||
xmlAutomataNewCounterTrans (xmlAutomataPtr am,
|
||||
xmlAutomataStatePtr from,
|
||||
xmlAutomataStatePtr to,
|
||||
int counter);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlAutomataNewCounter (xmlAutomataPtr am,
|
||||
int min,
|
||||
int max);
|
||||
|
||||
XMLPUBFUN xmlRegexpPtr XMLCALL
|
||||
xmlAutomataCompile (xmlAutomataPtr am);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlAutomataIsDeterminist (xmlAutomataPtr am);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_AUTOMATA_ENABLED */
|
||||
#endif /* LIBXML_REGEXP_ENABLED */
|
||||
|
||||
#endif /* __XML_AUTOMATA_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user