HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib64/python3.9/site-packages/lxml/isoschematron/__pycache__/__init__.cpython-39.pyc
a

��ao0�
@s�dZddlZddlZddlmZzeWney>e	ZYn0ze
Wney^e	Z
Yn0gd�ZdZdZ
dZdZd	eZd	eZej�ej�e�d
�Ze�e�ej�edd���Ze�e�ej�edd
���Ze�e�ej�eddd���Ze�e�ej�eddd���Ze�e�ej�eddd���Zejddeid�Zej ej�edd�d�Z!dd�Z"dd�Z#Gdd�dej$�Z%dS)zxThe ``lxml.isoschematron`` package implements ISO Schematron support on top
of the pure-xslt 'skeleton' implementation.
�N)�etree)	�extract_xsd�extract_rng�iso_dsdl_include�iso_abstract_expand�iso_svrl_for_xslt1�svrl_validation_errors�schematron_schema_valid�stylesheet_params�
Schematronz http://www.w3.org/2001/XMLSchemaz#http://relaxng.org/ns/structure/1.0z$http://purl.oclc.org/dsdl/schematronzhttp://purl.oclc.org/dsdl/svrlz
{%s}schemaZ	resourcesZxslzXSD2Schtrn.xslzRNG2Schtrn.xslziso-schematron-xslt1ziso_dsdl_include.xslziso_abstract_expand.xslziso_svrl_for_xslt1.xslz//svrl:failed-assert�svrl�Z
namespaces�rngziso-schematron.rng)�filecKs`i}|��D]N\}}t|t�r,tj�|�}n&|dur>td��nt|tj�sRt|�}|||<q|S)a(Convert keyword args to a dictionary of stylesheet parameters.
    XSL stylesheet parameters must be XPath expressions, i.e.:

    * string expressions, like "'5'"
    * simple (number) expressions, like "5"
    * valid XPath expressions, like "/a/b/text()"

    This function converts native Python keyword arguments to stylesheet
    parameters following these rules:
    If an arg is a string wrap it with XSLT.strparam().
    If an arg is an XPath object use its path string.
    If arg is None raise TypeError.
    Else convert arg to string.
    Nz*None not allowed as a stylesheet parameter)	�items�
isinstance�
basestring�_etree�XSLTZstrparam�	TypeError�XPath�unicode)�kwargs�result�key�val�r�A/usr/lib64/python3.9/site-packages/lxml/isoschematron/__init__.pyr
Fs


r
cCs<t|�}|��D]\}}|dur|||<qtfi|��}|S)z�Return a copy of paramsDict, updated with kwargsDict entries, wrapped as
    stylesheet arguments.
    kwargsDict entries with a value of None are ignored.
    N)�dictrr
)Z
paramsDictZ
kwargsDict�k�vrrr�_stylesheet_param_dictbs
r!cs�eZdZdZejjZejj	Z
ejjZ
eZejddeid�Zdd�ZeZeZeZeZeZeZddddiiid	d	d	def�fd
d�	Zdd
�Z e!dd��Z"e!dd��Z#e!dd��Z$�Z%S)ra
An ISO 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.

    The standard behaviour is to fail on ``failed-assert`` findings only
    (``ASSERTS_ONLY``).  To change this, you can either pass a report filter
    function to the ``error_finder`` parameter (e.g. ``ASSERTS_AND_REPORTS``
    or a custom ``XPath`` object), or subclass isoschematron.Schematron for
    complete control of the validation process.

    Built on the Schematron language 'reference' skeleton pure-xslt
    implementation, the validator is created as an XSLT 1.0 stylesheet using
    these steps:

     0) (Extract from XML Schema or RelaxNG schema)
     1) Process inclusions
     2) Process abstract patterns
     3) Compile the schematron schema to XSLT

    The ``include`` and ``expand`` keyword arguments can be used to switch off
    steps 1) and 2).
    To set parameters for steps 1), 2) and 3) hand parameter dictionaries to the
    keyword arguments ``include_params``, ``expand_params`` or
    ``compile_params``.
    For convenience, the compile-step parameter ``phase`` is also exposed as a
    keyword argument ``phase``. This takes precedence if the parameter is also
    given in the parameter dictionary.

    If ``store_schematron`` is set to True, the (included-and-expanded)
    schematron document tree is stored and available through the ``schematron``
    property.
    If ``store_xslt`` is set to True, the validation XSLT document tree will be
    stored and can be retrieved through the ``validator_xslt`` property.
    With ``store_report`` set to True (default: False), the resulting validation
    report document gets stored and can be accessed as the ``validation_report``
    property.

    Here is a usage example::

      >>> from lxml import etree
      >>> from lxml.isoschematron import Schematron

      >>> schematron = Schematron(etree.XML('''
      ... <schema xmlns="http://purl.oclc.org/dsdl/schematron" >
      ...   <pattern id="id_only_attribute">
      ...     <title>id is the only permitted attribute name</title>
      ...     <rule context="*">
      ...       <report test="@*[not(name()='id')]">Attribute
      ...         <name path="@*[not(name()='id')]"/> is forbidden<name/>
      ...       </report>
      ...     </rule>
      ...   </pattern>
      ... </schema>'''),
      ... error_finder=Schematron.ASSERTS_AND_REPORTS)

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

      >>> schematron.validate(xml)
      False

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

      >>> schematron.validate(xml)
      True
    z///svrl:failed-assert | //svrl:successful-reportrr
cCs8d}|jtkr|�|�}n|j|jtkr4|�|�}|S)a
Extract embedded schematron schema from non-schematron host schema.
        This method will only be called by __init__ if the given schema document
        is not a schematron schema by itself.
        Must return a schematron schema document tree or None.
        N)�tag�_xml_schema_root�_extract_xsdZnsmap�prefix�
RELAXNG_NS�_extract_rng)�self�element�
schematronrrr�_extract�s

zSchematron._extractNTFc
sptt|���|
|_d|_d|_d|_||jur6||_d}
z<|dur^t	�
|�rT|}
qt|��}
n|durtt	�|���}
Wn(t
y�t	�dt��d��Yn0|
dur�td��|
jtkr�|
}n
|�|
�}|dur�t	�d��|r�|j|fi|��}|�r
|j|fi|��}t|��s$t	�dtj��|�r0||_d|i}t||�}|j|fi|��}|	�r`||_t	�|�|_dS)NzNo tree or file given: %s�z
Empty treez=Document is not a schematron schema or schematron-extractablezinvalid schematron schema: %s�phase)�superr�__init__�
_store_report�_schematron�_validator_xslt�_validation_report�ASSERTS_ONLY�_validation_errorsr�	iselementZgetroot�parse�	ExceptionZSchematronParseError�sys�exc_info�
ValueErrorr"�_schematron_rootr+�_include�_expandr	Z	error_logr!�_compiler�
_validator)r(rrZinclude�expandZinclude_paramsZ
expand_paramsZcompile_paramsZstore_schematronZ
store_xsltZstore_reportr-Zerror_finder�rootr*Zcompile_kwargs�validator_xslt��	__class__rrr/�s\


�


�
��
zSchematron.__init__c
Cs�|��|�|�}|jr||_|�|�}|r�t�|�rH|��jj	pDd}n|jj	pRd}|D]*}|j
|j|j|j
dtj|dd�|d�qXdSdS)zaValidate doc using Schematron.

        Returns true if document is valid, false if not.
        z<file>rr)�encoding)�domain�type�level�line�message�filenameFT)Z_clear_error_logr@r0r3r5rr6ZgetroottreeZdocinfoZURLZ_append_log_message�_domain�_error_type�_levelZtostring)r(rr�errors�fname�errorrrr�__call__"s$


�zSchematron.__call__cCs|jS)zrISO-schematron schema document (None if object has been initialized
        with store_schematron=False).
        )r1�r(rrrr*;szSchematron.schematroncCs|jS)z�ISO-schematron skeleton implementation XSLT validator document (None
        if object has been initialized with store_xslt=False).
        )r2rTrrrrCBszSchematron.validator_xsltcCs|jS)zfISO-schematron validation result report (None if result-storing has
        been turned off).
        )r3rTrrr�validation_reportIszSchematron.validation_report)&�__name__�
__module__�__qualname__�__doc__rZErrorDomainsZSCHEMATRONVrMZErrorLevelsZERRORrOZ
ErrorTypesZSCHEMATRONV_ASSERTrNrr4r�SVRL_NSZASSERTS_AND_REPORTSr+rr$rr'rr=rr>rr?r5r/rS�propertyr*rCrU�
__classcell__rrrDrrps8S��8

r)&rYr9Zos.path�osZlxmlrrr�	NameError�strr�__all__Z
XML_SCHEMA_NSr&Z
SCHEMATRON_NSrZr<r#�path�join�dirname�__file__Z_resources_dirrr7rrrrrrrZRelaxNGr	r
r!Z
_Validatorrrrrr�<module>sb

	����������