ó œ]Nc @svdZddlZddlZddlmZyedZWne e fk r[e ZnXyedZ Wne e fk r‰e Z nXyedZ Wne e fk r·e Z nXddd d d d d ddg ZdZdZdZdZdeZdeZejjejjeƒdƒZejejejjeddƒƒƒZejejejjeddƒƒƒZejejejjedddƒƒƒZejejejjedddƒƒƒZejejejjedddƒƒƒZ ej!ddied6ƒZ"ej#ejejjed d!ƒƒƒZ$d"„Z%d#„Z&dej'fd$„ƒYZ(dS(%sxThe ``lxml.isoschematron`` package implements ISO Schematron support on top of the pure-xslt 'skeleton' implementation. iÿÿÿÿN(tetreetbytestunicodet basestringt 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.rngcKs‘i}x„|jƒD]v\}}t|tƒrCtjj|ƒ}n<|dkr^tdƒ‚n!t|tjƒst |ƒ}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/lib/python2.7/vendor-packages/lxml/isoschematron/__init__.pyt_extract¿s c Csétt|ƒjƒ| |_d|_d|_d|_y^|dk rpt|t j ƒra|} q”|j ƒ} n$|dk r”t j |ƒj ƒ} nWn.t k rÅt jdtjƒdƒ‚nX| dkrátdƒ‚n| jtkrù| } n|j| ƒ} | dkr&t jdƒ‚n|rA|j| |} n|r\|j| |} nt| ƒst jdtjƒ‚n|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_expandR t error_logR#t_compileRt _validator(R+Rtfiletincludetexpandtinclude_paramst expand_paramstcompile_paramststore_schematront store_xsltt store_reportR/trootR-tcompile_kwargstvalidator_xslt((sA/usr/lib/python2.7/vendor-packages/lxml/isoschematron/__init__.pyR1ÚsN                cCsÛ|jƒ|j|ƒ}|jr.||_n|j|ƒ}|r×t|tjƒrp|jƒj j pjd}n|j j pd}xN|D]F}|j d|j d|j d|jdddtj|ƒd|ƒq‰WtStS( saValidate doc using Schematron. Returns true if document is valid, false if not. stdomainttypetleveltlineitmessagetfilename(t_clear_error_logRCR2R5t_validation_errorsRRR6t getroottreetdocinfotURLt_append_log_messaget_domaint _error_typet_levelt tounicodetFalsetTrue(R+RRterrorstfnameterror((sA/usr/lib/python2.7/vendor-packages/lxml/isoschematron/__init__.pyt__call__s       cCs|jS(srISO-schematron schema document (None if object has been initialized with store_schematron=False). (R3(R+((sA/usr/lib/python2.7/vendor-packages/lxml/isoschematron/__init__.pyR-'stdoccCs|jS(sISO-schematron skeleton implementation XSLT validator document (None if object has been initialized with store_xslt=False). (R4(R+((sA/usr/lib/python2.7/vendor-packages/lxml/isoschematron/__init__.pyRO.scCs|jS(sfISO-schematron validation result report (None if result-storing has been turned off). (R5(R+((sA/usr/lib/python2.7/vendor-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@RRBR RWRRaR`R1ReR-tpropertyRORg(((sA/usr/lib/python2.7/vendor-packages/lxml/isoschematron/__init__.pyR ss,E        2    ()RjR;tos.pathtostlxmlRRt __builtins__RtKeyErrort NameErrortstrRRt__all__t XML_SCHEMA_NSR)t SCHEMATRON_NStSVRL_NSR>R%tpathtjointdirnamet__file__t_resources_dirRR8RRRRRRR tRelaxNGR R R#t _ValidatorR (((sA/usr/lib/python2.7/vendor-packages/lxml/isoschematron/__init__.pyts\         !