ó ÄqPc @sRdZddlZddlZddlmZyeWnek rOe ZnXye Wnek rqe Z nXye Wnek r“e Z nXdddddd d d d g Z d Z dZdZdZdeZde ZejjejjeƒdƒZejejejjeddƒƒƒZejejejjeddƒƒƒZejejejjedddƒƒƒZejejejjedddƒƒƒZejejejjedddƒƒƒZejddied6ƒZ ej!ejejjeddƒƒƒZ"d„Z#d „Z$d ej%fd!„ƒYZ&dS("sxThe ``lxml.isoschematron`` package implements ISO Schematron support on top of the pure-xslt 'skeleton' implementation. iÿÿÿÿN(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.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/lib64/python2.7/site-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_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__.pyR0Ú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_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\            !