SILENT KILLERPanel

Current Path: > > opt > hc_python > lib64 > python3.12 > site-packages > > lxml


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/hc_python/lib64/python3.12/site-packages//lxml

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
html Directory - -
includes Directory - -
isoschematron Directory - -
ElementInclude.py File 8560 bytes April 04 2025 08:02:25.
__init__.py File 574 bytes April 04 2025 08:02:25.
_elementpath.cpython-312-x86_64-linux-gnu.so File 204992 bytes April 04 2025 08:02:25.
_elementpath.py File 10888 bytes April 04 2025 08:02:25.
apihelpers.pxi File 63610 bytes April 04 2025 08:02:25.
builder.cpython-312-x86_64-linux-gnu.so File 116536 bytes April 04 2025 08:02:25.
builder.py File 8100 bytes April 04 2025 08:02:25.
classlookup.pxi File 22435 bytes April 04 2025 08:02:25.
cleanup.pxi File 8454 bytes April 04 2025 08:02:25.
cssselect.py File 3306 bytes April 04 2025 08:02:25.
debug.pxi File 3282 bytes April 04 2025 08:02:25.
docloader.pxi File 5772 bytes April 04 2025 08:02:25.
doctestcompare.py File 17731 bytes April 04 2025 08:02:25.
dtd.pxi File 15281 bytes April 04 2025 08:02:25.
etree.cpython-312-x86_64-linux-gnu.so File 5353704 bytes April 04 2025 08:02:25.
etree.h File 9912 bytes April 04 2025 08:02:25.
etree.pyx File 134517 bytes April 04 2025 08:02:25.
etree_api.h File 17063 bytes April 04 2025 08:02:25.
extensions.pxi File 32088 bytes April 04 2025 08:02:25.
iterparse.pxi File 16521 bytes April 04 2025 08:02:25.
lxml.etree.h File 9912 bytes April 04 2025 08:02:25.
lxml.etree_api.h File 17068 bytes April 04 2025 08:02:25.
nsclasses.pxi File 9129 bytes April 04 2025 08:02:25.
objectify.cpython-312-x86_64-linux-gnu.so File 3077608 bytes April 04 2025 08:02:25.
objectify.pyx File 75735 bytes April 04 2025 08:02:25.
objectpath.pxi File 11450 bytes April 04 2025 08:02:25.
parser.pxi File 82040 bytes April 04 2025 08:02:25.
parsertarget.pxi File 6326 bytes April 04 2025 08:02:25.
proxy.pxi File 23697 bytes April 04 2025 08:02:25.
public-api.pxi File 6666 bytes April 04 2025 08:02:25.
pyclasslookup.py File 92 bytes April 04 2025 08:02:25.
readonlytree.pxi File 18976 bytes April 04 2025 08:02:25.
relaxng.pxi File 6339 bytes April 04 2025 08:02:25.
sax.cpython-312-x86_64-linux-gnu.so File 186040 bytes April 04 2025 08:02:25.
sax.py File 9303 bytes April 04 2025 08:02:25.
saxparser.pxi File 33322 bytes April 04 2025 08:02:25.
schematron.pxi File 5908 bytes April 04 2025 08:02:25.
serializer.pxi File 65753 bytes April 04 2025 08:02:25.
usedoctest.py File 230 bytes April 04 2025 08:02:25.
xinclude.pxi File 2456 bytes April 04 2025 08:02:25.
xmlerror.pxi File 49854 bytes April 04 2025 08:02:25.
xmlid.pxi File 6073 bytes April 04 2025 08:02:25.
xmlschema.pxi File 8490 bytes April 04 2025 08:02:25.
xpath.pxi File 19132 bytes April 04 2025 08:02:25.
xslt.pxi File 36023 bytes April 04 2025 08:02:25.
xsltext.pxi File 11088 bytes April 04 2025 08:02:25.

Reading File: //opt/hc_python/lib64/python3.12/site-packages//lxml/schematron.pxi

# support for Schematron validation
from lxml.includes cimport schematron


cdef class SchematronError(LxmlError):
    """Base class of all Schematron errors.
    """

cdef class SchematronParseError(SchematronError):
    """Error while parsing an XML document as Schematron schema.
    """

cdef class SchematronValidateError(SchematronError):
    """Error while validating an XML document with a Schematron schema.
    """


################################################################################
# Schematron

cdef class Schematron(_Validator):
    """Schematron(self, etree=None, file=None)
    A Schematron validator.

    Pass a root Element or an ElementTree to turn it into a validator.
    Alternatively, pass a filename as keyword argument 'file' to parse from
    the file system.

    Schematron is a less well known, but very powerful schema language.  The main
    idea is to use the capabilities of XPath to put restrictions on the structure
    and the content of XML documents.  Here is a simple example::

      >>> schematron = Schematron(XML('''
      ... <schema xmlns="http://www.ascc.net/xml/schematron" >
      ...   <pattern name="id is the only permitted attribute name">
      ...     <rule context="*">
      ...       <report test="@*[not(name()='id')]">Attribute
      ...         <name path="@*[not(name()='id')]"/> is forbidden<name/>
      ...       </report>
      ...     </rule>
      ...   </pattern>
      ... </schema>
      ... '''))

      >>> xml = XML('''
      ... <AAA name="aaa">
      ...   <BBB id="bbb"/>
      ...   <CCC color="ccc"/>
      ... </AAA>
      ... ''')

      >>> schematron.validate(xml)
      0

      >>> xml = XML('''
      ... <AAA id="aaa">
      ...   <BBB id="bbb"/>
      ...   <CCC/>
      ... </AAA>
      ... ''')

      >>> schematron.validate(xml)
      1

    Schematron was added to libxml2 in version 2.6.21.  Before version 2.6.32,
    however, Schematron lacked support for error reporting other than to stderr.
    This version is therefore required to retrieve validation warnings and
    errors in lxml.
    """
    cdef schematron.xmlSchematron* _c_schema
    cdef xmlDoc* _c_schema_doc
    def __cinit__(self):
        self._c_schema = NULL
        self._c_schema_doc = NULL

    def __init__(self, etree=None, *, file=None):
        cdef _Document doc
        cdef _Element root_node
        cdef xmlNode* c_node
        cdef char* c_href
        cdef schematron.xmlSchematronParserCtxt* parser_ctxt = NULL
        _Validator.__init__(self)
        if not config.ENABLE_SCHEMATRON:
            raise SchematronError, \
                "lxml.etree was compiled without Schematron support."
        if etree is not None:
            doc = _documentOrRaise(etree)
            root_node = _rootNodeOrRaise(etree)
            self._c_schema_doc = _copyDocRoot(doc._c_doc, root_node._c_node)
            parser_ctxt = schematron.xmlSchematronNewDocParserCtxt(self._c_schema_doc)
        elif file is not None:
            filename = _getFilenameForFile(file)
            if filename is None:
                # XXX assume a string object
                filename = file
            filename = _encodeFilename(filename)
            with self._error_log:
                orig_loader = _register_document_loader()
                parser_ctxt = schematron.xmlSchematronNewParserCtxt(_cstr(filename))
                _reset_document_loader(orig_loader)
        else:
            raise SchematronParseError, "No tree or file given"

        if parser_ctxt is NULL:
            if self._c_schema_doc is not NULL:
                tree.xmlFreeDoc(self._c_schema_doc)
                self._c_schema_doc = NULL
            raise MemoryError()

        try:
            with self._error_log:
                orig_loader = _register_document_loader()
                self._c_schema = schematron.xmlSchematronParse(parser_ctxt)
                _reset_document_loader(orig_loader)
        finally:
            schematron.xmlSchematronFreeParserCtxt(parser_ctxt)

        if self._c_schema is NULL:
            raise SchematronParseError(
                "Document is not a valid Schematron schema",
                self._error_log)

    def __dealloc__(self):
        schematron.xmlSchematronFree(self._c_schema)
        if self._c_schema_doc is not NULL:
            tree.xmlFreeDoc(self._c_schema_doc)

    def __call__(self, etree):
        """__call__(self, etree)

        Validate doc using Schematron.

        Returns true if document is valid, false if not."""
        cdef _Document doc
        cdef _Element root_node
        cdef xmlDoc* c_doc
        cdef schematron.xmlSchematronValidCtxt* valid_ctxt
        cdef int ret

        assert self._c_schema is not NULL, "Schematron instance not initialised"
        doc = _documentOrRaise(etree)
        root_node = _rootNodeOrRaise(etree)

        valid_ctxt = schematron.xmlSchematronNewValidCtxt(
            self._c_schema, schematron.XML_SCHEMATRON_OUT_ERROR)
        if valid_ctxt is NULL:
            raise MemoryError()

        try:
            self._error_log.clear()
            # Need a cast here because older libxml2 releases do not use 'const' in the functype.
            schematron.xmlSchematronSetValidStructuredErrors(
                valid_ctxt, <xmlerror.xmlStructuredErrorFunc> _receiveError, <void*>self._error_log)
            c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
            with nogil:
                ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
            _destroyFakeDoc(doc._c_doc, c_doc)
        finally:
            schematron.xmlSchematronFreeValidCtxt(valid_ctxt)

        if ret == -1:
            raise SchematronValidateError(
                "Internal error in Schematron validation",
                self._error_log)
        if ret == 0:
            return True
        else:
            return False

SILENT KILLER Tool