qPc @sRdZddlZddlZddlmZyeWnek rOe ZnXye Wnek rqe Z nXye Wnek re Z nXdddddd d d d g Z d Z dZdZdZdeZde ZejjejjedZejejejjeddZejejejjeddZejejejjedddZejejejjedddZejejejjedddZejddied6Z ej!ejejjeddZ"dZ#d Z$d ej%fd!YZ&dS("sxThe ``lxml.isoschematron`` package implements ISO Schematron support on top of the pure-xslt 'skeleton' implementation. iN(tetreet extract_xsdt extract_rngtiso_dsdl_includetiso_abstract_expandtiso_svrl_for_xslt1tsvrl_validation_errorstschematron_schema_validtstylesheet_paramst Schematrons http://www.w3.org/2001/XMLSchemas#http://relaxng.org/ns/structure/1.0s$http://purl.oclc.org/dsdl/schematronshttp://purl.oclc.org/dsdl/svrls {%s}schemat resourcestxslsXSD2Schtrn.xslsRNG2Schtrn.xslsiso-schematron-xslt1siso_dsdl_include.xslsiso_abstract_expand.xslsiso_svrl_for_xslt1.xsls//svrl:failed-assertt namespacestsvrltrngsiso-schematron.rngcKsi}x|jD]v\}}t|trCtjj|}n<|dkr^tdn!t|tjst |}n|||>> from lxml import isoschematron >>> schematron = isoschematron.Schematron(etree.XML(''' ... ... ... id is the only permitted attribute name ... ... Attribute ... is forbidden ... ... ... ... ... ''')) >>> xml = etree.XML(''' ... ... ... ... ... ''') >>> schematron.validate(xml) 0 >>> xml = etree.XML(''' ... ... ... ... ... ''') >>> schematron.validate(xml) 1 cCsSd}|jtkr'|j|}n(|j|jtkrO|j|}n|S(s 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(Rttagt_xml_schema_roott _extract_xsdtnsmaptprefixt RELAXNG_NSt _extract_rng(tselftelementt schematron((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pyt_extracts c Cstt|j| |_d|_d|_d|_y^|dk rpt|t j ra|} q|j } n$|dk rt j |j } nWn.t k rt jdtjdnX| dkrtdn| jtkr| } n|j| } | dkr&t jdn|rA|j| |} n|r\|j| |} nt| st jdtjn|r| |_ni| d6}t||}|j| |}| r||_nt j||_dS(NsNo tree or file given: %sis Empty trees=Document is not a schematron schema or schematron-extractablesinvalid schematron schema: %stphase(tsuperR t__init__t _store_reportRt _schematront_validator_xsltt_validation_reportRRt_Elementtgetroottparset ExceptiontSchematronParseErrortsystexc_infot ValueErrorR#t_schematron_rootR-t_includet_expandRt error_logR"t_compileRt _validator(R*Rtfiletincludetexpandtinclude_paramst expand_paramstcompile_paramststore_schematront store_xsltt store_reportR.trootR,tcompile_kwargstvalidator_xslt((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pyR0sN                cCs|j|j|}|jr.||_n|j|}|rt|tjrp|jj j pjd}n|j j pd}xN|D]F}|j d|j d|j d|jdddtj|d|qWtStS( saValidate doc using Schematron. Returns true if document is valid, false if not. stdomainttypetleveltlineitmessagetfilename(t_clear_error_logRBR1R4t_validation_errorsRRR5t getroottreetdocinfotURLt_append_log_messaget_domaint _error_typet_levelt tounicodetFalsetTrue(R*RRterrorstfnameterror((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pyt__call__s       cCs|jS(srISO-schematron schema document (None if object has been initialized with store_schematron=False). (R2(R*((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pyR,'stdoccCs|jS(sISO-schematron skeleton implementation XSLT validator document (None if object has been initialized with store_xslt=False). (R3(R*((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pyRN.scCs|jS(sfISO-schematron validation result report (None if result-storing has been turned off). (R4(R*((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pytvalidation_report5sN(#t__name__t __module__t__doc__Rt ErrorDomainst SCHEMATRONVR[t ErrorLevelstERRORR]t ErrorTypestSCHEMATRONV_ASSERTR\R-RR%RR)RR>RR?RRARRVRR`R_R0RdR,tpropertyRNRf(((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pyR ss,E        2    ('RiR:tos.pathtostlxmlRRtbytest NameErrortstrRRt__all__t XML_SCHEMA_NSR(t SCHEMATRON_NStSVRL_NSR=R$tpathtjointdirnamet__file__t_resources_dirRR7RRRRRRRtRelaxNGRRR"t _ValidatorR (((sA/usr/lib64/python2.7/site-packages/lxml/isoschematron/__init__.pyts\            !