
    ,h3              
       ^   d Z ddlZddlZddlmZ 	 e 	 e
 g dZdZdZdZdZd	ez  Zd	ez  Zej$                  j'                  ej$                  j)                  e      d
      Z ej.                   ej0                  ej$                  j'                  edd                  Z ej.                   ej0                  ej$                  j'                  edd                  Z ej.                   ej0                  ej$                  j'                  eddd                  Z ej.                   ej0                  ej$                  j'                  eddd                  Z ej.                   ej0                  ej$                  j'                  eddd                  Z ej<                  ddei      ZdZ 	  ejB                  ej$                  j'                  edd            Z"dZ d Z$d Z% G d dejL                        Z'y# e$ r e	ZY w xY w# e$ r e	Z
Y w xY w# ejF                  $ r d Z"Y Lw xY w)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/schematronzhttp://purl.oclc.org/dsdl/svrlz
{%s}schema	resourcesxslzXSD2Schtrn.xslzRNG2Schtrn.xslziso-schematron-xslt1ziso_dsdl_include.xslziso_abstract_expand.xslziso_svrl_for_xslt1.xslz//svrl:failed-assertsvrl
namespacesFrngziso-schematron.rng)fileTc                     t        d      )Nz9Validating the ISO schematron requires iso-schematron.rng)NotImplementedError)args    ]/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/lxml/isoschematron/__init__.pyr
   r
   H   s    !"]^^    c                     i }| j                         D ]l  \  }}t        |t              r t        j                  j                  |      }n2|t        d      t        |t        j                        st        |      }|||<   n |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.
    z*None not allowed as a stylesheet parameter)	items
isinstance
basestring_etreeXSLTstrparam	TypeErrorXPathunicode)kwargsresultkeyvals       r   r   r   L   sx     FLLN Sc:&++&&s+C[HIIC.#,Cs Mr   c                 r    t        |       } |j                         D ]  \  }}|	|| |<    t        di | } | S )zReturn a copy of paramsDict, updated with kwargsDict entries, wrapped as
    stylesheet arguments.
    kwargsDict entries with a value of None are ignored.
     )dictr   r   )
paramsDict
kwargsDictkvs       r   _stylesheet_param_dictr.   h   sM     j!J  " 1=JqM #0Z0Jr   c                   F    e Zd ZdZej
                  j                  Zej                  j                  Z
ej                  j                  ZeZ ej                   ddei      Zd ZeZeZeZeZeZeZddddi i i ddddeef fd		Z d
 Z!e"d        Z#e"d        Z$e"d        Z% xZ&S )r   a  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.

    If ``validate_schema`` is set to False, the validation of the schema file
    itself is disabled.  Validation happens by default after building the full
    schema, unless the schema validation file cannot be found at import time,
    in which case the validation gets disabled.  Some lxml distributions exclude
    this file due to licensing issues.  ISO-Schematron validation can then still
    be used normally, but the schemas themselves cannot be validated.

    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   c                     d}|j                   t        k(  r| j                  |      }|S |j                  j	                  |j
                        t        k(  r| j                  |      }|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_xsdnsmapgetprefix
RELAXNG_NS_extract_rng)selfelement
schematrons      r   _extractzSchematron._extract   sa     
;;****73J  ]]w~~.*<**73Jr   NTFc                    t         |           |
| _        d | _        d | _        d | _        || j                  ur|| _        d }	 |)t        j                  |      r|}n6|j                         }n%|#t        j                  |      j                         }|t!        d      |j"                  t$        k(  r|}n| j'                  |      }|t        j                  d      |r | j(                  |fi |}|r | j*                  |fi |}|r1t-        |      s&t        j                  dt,        j.                  z        |r|| _        d|i}t1        ||      } | j2                  |fi |}|	r|| _        t        j4                  |      | _        y # t        $ r. t        j                  dt        j                         d   z        w xY w)NzNo tree or file given: %s   z
Empty treez=Document is not a schematron schema or schematron-extractablezinvalid schematron schema: %sphase)super__init___store_report_schematron_validator_xslt_validation_reportASSERTS_ONLY_validation_errorsr   	iselementgetrootparse	ExceptionSchematronParseErrorsysexc_info
ValueErrorr1   _schematron_rootr<   _include_expandr
   	error_logr.   _compiler   
_validator)r9   r   r   includeexpandinclude_paramsexpand_paramscompile_paramsstore_schematron
store_xsltstore_reportr?   error_findervalidate_schemarootr;   compile_kwargsvalidator_xslt	__class__s                     r   rA   zSchematron.__init__   s   
 	)#"&t000&2D# 
	A ##E* D ==?D!||D)113 <\**88''Jt,J--OQ Q &zD^DJ%jBMBJ#::#F--/'1123 3 )D!5)/O&zD^D#1D  ++n5=  	A--+cllnQ.??A A	As   AF 7Gc                    | j                          | j                  |      }| j                  r|| _        | j	                  |      }|rt        j                  |      r)|j                         j                  j                  xs d}n|j                  j                  xs d}|D ]L  }| j                  | j                  | j                  | j                  dt        j                  |d      |       N yy)zaValidate doc using Schematron.

        Returns true if document is valid, false if not.
        z<file>r   r"   )encoding)domaintypelevellinemessagefilenameFT)_clear_error_logrU   rB   rE   rG   r   rH   getroottreedocinfoURL_append_log_message_domain_error_type_leveltostring)r9   r   r$   errorsfnameerrors         r   __call__zSchematron.__call__0  s    
 	'&,D#((0&))+3377C8))5X $((<<d.>.>++A"OOEIF"	 ) $$ r   c                     | j                   S )zrISO-schematron schema document (None if object has been initialized
        with store_schematron=False).
        )rC   r9   s    r   r;   zSchematron.schematronI  s    
 r   c                     | j                   S )zISO-schematron skeleton implementation XSLT validator document (None
        if object has been initialized with store_xslt=False).
        )rD   rz   s    r   rb   zSchematron.validator_xsltP  s    
 ###r   c                     | j                   S )zfISO-schematron validation result report (None if result-storing has
        been turned off).
        )rE   rz   s    r   validation_reportzSchematron.validation_reportW  s    
 &&&r   )'__name__
__module____qualname____doc__r   ErrorDomainsSCHEMATRONVrq   ErrorLevelsERRORrs   
ErrorTypesSCHEMATRONV_ASSERTrr   r	   rF   r!   SVRL_NSASSERTS_AND_REPORTSr<   r   r3   r   r8   r   rQ   r   rR   r   rT   rG   !schematron_schema_valid_supportedrA   rx   propertyr;   rb   r}   __classcell__)rc   s   @r   r   r   v   s    Wt !!--G%%F##66K *L&&,,9G$&" LLH!G!H
 &!d4 ""R"'E,!B	76r2     $ $ ' 'r   r   )(r   rM   os.pathoslxmlr   r   r"   	NameErrorstrr   __all__XML_SCHEMA_NSr7   SCHEMATRON_NSr   rP   r2   pathjoindirname__file___resources_dirr   rJ   r   r   r   r   r   r!   r	   r   RelaxNGr
   RelaxNGParseErrorr   r.   
_Validatorr   r(   r   r   <module>r      sR      . 32
6
*  -/ -/ bggooh7E fkk,&,,GGLL(89; <fkk,&,,GGLL(89; <6;;|v||GGLL(>') * +  "fkk,&,,GGLL(>*,#- .  !V[[GGLL.0HJ"K L  &'8:  %* !_,fnnWW\\.%1EFH(,%8f'"" f'S  G
  Jh  ___s4   G; H	 /0H ;HH	HHH,+H,