GRAYBYTE WORDPRESS FILE MANAGER7508

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.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
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/imunify360/venv/lib/python3.11/site-packages/lxml/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/imunify360/venv/lib/python3.11/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):
    u"""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, \
                u"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, u"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(
                u"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):
        u"""__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()
            schematron.xmlSchematronSetValidStructuredErrors(
                valid_ctxt, _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(
                u"Internal error in Schematron validation",
                self._error_log)
        if ret == 0:
            return True
        else:
            return False

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 11 2025 07:53:06
root / root
0755
__pycache__
--
July 02 2025 08:36:55
root / root
0755
html
--
July 02 2025 08:36:55
root / root
0755
includes
--
July 02 2025 08:36:55
root / root
0755
isoschematron
--
July 02 2025 08:36:55
root / root
0755
ElementInclude.py
8.359 KB
June 09 2025 11:12:39
root / root
0644
__init__.py
0.562 KB
June 09 2025 11:12:39
root / root
0644
_elementpath.cpython-311-x86_64-linux-gnu.so
225.273 KB
June 09 2025 11:13:05
root / root
0755
_elementpath.py
10.49 KB
June 09 2025 11:12:39
root / root
0644
apihelpers.pxi
62.941 KB
June 09 2025 11:12:39
root / root
0644
builder.cpython-311-x86_64-linux-gnu.so
120.727 KB
June 09 2025 11:13:05
root / root
0755
builder.py
7.956 KB
June 09 2025 11:12:39
root / root
0644
classlookup.pxi
21.936 KB
June 09 2025 11:12:39
root / root
0644
cleanup.pxi
8.26 KB
June 09 2025 11:12:39
root / root
0644
cssselect.py
3.287 KB
June 09 2025 11:12:39
root / root
0644
debug.pxi
3.206 KB
June 09 2025 11:12:39
root / root
0644
docloader.pxi
5.647 KB
June 09 2025 11:12:39
root / root
0644
doctestcompare.py
17.909 KB
June 09 2025 11:12:39
root / root
0644
dtd.pxi
14.862 KB
June 09 2025 11:12:39
root / root
0644
etree.cpython-311-x86_64-linux-gnu.so
5.53 MB
June 09 2025 11:13:05
root / root
0755
etree.h
8.374 KB
June 09 2025 11:12:39
root / root
0644
etree.pyx
129.312 KB
June 09 2025 11:12:39
root / root
0644
etree_api.h
17.058 KB
June 09 2025 11:12:39
root / root
0644
extensions.pxi
32.462 KB
June 09 2025 11:12:39
root / root
0644
iterparse.pxi
16.218 KB
June 09 2025 11:12:39
root / root
0644
lxml.etree.h
8.374 KB
June 09 2025 11:12:39
root / root
0644
lxml.etree_api.h
17.063 KB
June 09 2025 11:12:39
root / root
0644
nsclasses.pxi
8.931 KB
June 09 2025 11:12:39
root / root
0644
objectify.cpython-311-x86_64-linux-gnu.so
3.2 MB
June 09 2025 11:13:05
root / root
0755
objectify.pyx
75.293 KB
June 09 2025 11:12:39
root / root
0644
objectpath.pxi
11.21 KB
June 09 2025 11:12:39
root / root
0644
parser.pxi
76.413 KB
June 09 2025 11:12:39
root / root
0644
parsertarget.pxi
6.698 KB
June 09 2025 11:12:39
root / root
0644
proxy.pxi
23.01 KB
June 09 2025 11:12:39
root / root
0644
public-api.pxi
6.504 KB
June 09 2025 11:12:39
root / root
0644
pyclasslookup.py
0.09 KB
June 09 2025 11:12:39
root / root
0644
readonlytree.pxi
18.602 KB
June 09 2025 11:12:39
root / root
0644
relaxng.pxi
5.942 KB
June 09 2025 11:12:39
root / root
0644
sax.cpython-311-x86_64-linux-gnu.so
196.953 KB
June 09 2025 11:13:05
root / root
0755
sax.py
9.176 KB
June 09 2025 11:12:39
root / root
0644
saxparser.pxi
31.779 KB
June 09 2025 11:12:39
root / root
0644
schematron.pxi
5.646 KB
June 09 2025 11:12:39
root / root
0644
serializer.pxi
66.405 KB
June 09 2025 11:12:39
root / root
0644
usedoctest.py
0.225 KB
June 09 2025 11:12:39
root / root
0644
xinclude.pxi
2.402 KB
June 09 2025 11:12:39
root / root
0644
xmlerror.pxi
48.37 KB
June 09 2025 11:12:39
root / root
0644
xmlid.pxi
5.922 KB
June 09 2025 11:12:39
root / root
0644
xmlschema.pxi
7.89 KB
June 09 2025 11:12:39
root / root
0644
xpath.pxi
19.112 KB
June 09 2025 11:12:39
root / root
0644
xslt.pxi
35.834 KB
June 09 2025 11:12:39
root / root
0644
xsltext.pxi
10.825 KB
June 09 2025 11:12:39
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF