ó ²¬5=c@s™dZddlZddlZddlZddlZddlZddlZddlTddlTddl Tddd„ƒYZ de fd„ƒYZ dS( sðThis is the parts of xmlproc that are specific to validation. They are an application class that receive data from the parser and a subclass of the parser object that sets this up. $Id: xmlval.py,v 1.16 2002/07/17 17:43:14 mikeolson Exp $ iÿÿÿÿN(t*t XMLValidatorcBs.eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zdd„Zd„Zd"d„Zd„Zd„Zd„Zd„Z d „Z!d!„Z"RS(#sšXML parser that validates a document and does some of what is required of a validating parser, like adding fixed and default attribute values etc.cCsPtƒ|_tƒ|_t|jƒ|_t|j|jƒ|_|jƒdS(N( t XMLProcessortparsert Applicationtappt CompleteDTDtdtdt ValidatingApptvaltreset(tself((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyt__init__s   cCs|jj|ƒdS(N(Rtparse_resource(R tsysid((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR scCsl|jjƒ|jjƒ|jjƒ|jj|jƒ|j|j_|j|j_|jjdƒdS(Ni(RR R Rtset_applicationtenttset_read_external_subset(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR !s   cCs|jj|ƒdS(N(Rtfeed(R tdata((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR+scCs|jjƒdS(N(Rtclose(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR.scCs|jjƒdS(N(Rtderef(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR1scCs0||_|jj|jƒ|j|jƒdS(N(RR t set_real_appt set_locatorR(R R((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR4s cCs|jj|ƒdS(N(Rtset_error_language(R tlanguage((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR9scCs|jj|ƒdS(N(Rtset_error_handler(R terr((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR<scCs|jj|ƒdS(N(Rtset_dtd_listener(R t dtd_listener((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR?scCs|jj|ƒdS(N(Rtset_inputsource_factory(R tisf((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyRBscCs$|jj|ƒ|jj|ƒdS(N(R tset_pubid_resolverR(R tpubres((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR EsicCs|jj|ƒdS(N(Rtset_data_after_wf_error(R t stop_on_wf((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR"IscCs|jj|ƒdS(N(Rt set_sysid(R R((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR$LscCsdS(N((R tread_it((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyROscCs|jS(N(R(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pytget_dtdRscCs |jjƒS(N(Rtget_current_sysid(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR'UscCs |jjƒS(N(Rt get_offset(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR(XscCs |jjƒS(N(Rtget_line(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR)[scCs |jjƒS(N(Rt get_column(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR*^scCs|jjƒdS(N(Rt parseStart(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR+ascCs|jjƒdS(N(RtparseEnd(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR,dsi@cCs|jj||ƒdS(N(Rt read_from(R tfiletbufsize((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR-gscCs|jjƒdS(N(Rtflush(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR0jscCs|jj||ƒdS(N(Rt report_error(R terrnotargs((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR1mscCs |jjS(s>Returns the internal element stack. Note: this is a live list!(Rtstack(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pytget_elem_stackrscCs |jjS(s Returns the current data buffer.(RR(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pytget_data_buffervscCs |jjS(sPReturns the start position of the current construct (tag, comment, etc).(Rtprepos(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pytget_construct_startzscCs |jjS(sNReturns the end position of the current construct (tag, comment, etc).(Rtpos(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pytget_construct_endscCs|jj|jj|jj!S(s.Returns the raw form of the current construct.(RRR7R9(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pytget_raw_construct„scCstd„|jjƒS(ssReturns a snapshot of the entity stack. A list of the system identifier of the entity and its name, if any.cSs|d|dfS(Nii ((R((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyt‹s(tmapRt ent_stack(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pytget_current_ent_stackˆsN(#t__name__t __module__t__doc__R R R RRRRRRRRR R"R$RR&R'R(R)R*R+R,R-R0tNoneR1R5R6R8R:R;R?(((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyRs@                             RcBs§eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„ZRS(s@The object that uses the DTD to actually validate XML documents.cCs8||_||_tƒ|_tƒ|_|jƒdS(N(RRRtrealappt PubIdResolverR!R (R RR((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR ”s     cCs:d|_d|_g|_i|_g|_d|_dS(Ni(RCtcur_elemt cur_stateR4tidstidrefst _seen_root(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR ›s      cCs ||_dS(N(RD(R R((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR£scCs ||_dS(N(R!(R R!((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR ¦scCs$tj||ƒ|jj|ƒdS(N(RRRD(R tlocator((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR©scCs¬|jjƒ}|jdkrÝ|jdkr¾|jj|j|ƒ}|dkr²|jj|j|ƒ}|rœ|jjd|d|fƒ|d|_q»|jjd|ƒq¾||_n|j j |j|jfƒn8|j r|dkr||kr|jjd|ƒnd|_ yG|jj |ƒ|_|jj ƒ|_|j|jj |ƒ|ƒWn-tk r”|jjd|ƒd|_nX|jj||ƒdS(NiÿÿÿÿiiéiiÑiÒiÓ(Rt get_root_elemRFRCRGt next_statetnext_state_skipRR1R4tappendRJtget_elemtget_start_statetvalidate_attributestKeyErrorRDthandle_start_tag(R tnametattrst decl_roottnexttskip((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyRT­s.  "    cCs«|jdkrb|jj|jƒ rb|jj|jƒ}|jjd|tj|dƒfƒn|j j |ƒ|j gkr§|j d\|_|_|j d=ndS(s>Notifies the application of end tags (and empty element tags).iÔs, iÿÿÿÿN( RFRCt final_stateRGtget_valid_elementsRR1tstringtjoinRDthandle_end_tagR4(R RUtvalid((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR^Ðs(cCsº|jdkr |jdkr |jj|jdƒ}|dkr”|jj|||ƒx5|||!D]&}|dkrf|jjdƒPqfqfWdS||_n|jj|||ƒdS(s+Notifies the application of character data.iÿÿÿÿs#PCDATAis iÕN( RFRCRGRMRDthandle_ignorable_dataRR1t handle_data(R RtstarttendRXtch((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyRaàs   cCsKxé|jƒD]Û}y|j|ƒ}Wn'tk rO|jjd|ƒq nX|jdkr‚tjtj||ƒƒ|| #  cCs¤yy|jj|ƒ}|jdkr7|jjdƒnAy|jj|jƒWn'tk rw|jjd|jƒnXWn$tk rŸ|jjd|ƒnXdS(NRgiØiÙiÍ (Rt resolve_getnotationRR1t get_notationRS(R RUR((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyt__validate_attr_entrefs  cCsVxB|jD]7\}}}|jj|ƒs |jjd|ƒq q W|jjƒdS(NiÛ(RIRHRqRR1RDtdoc_end(R tlinetcoltid((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR})scCs&|jj|||ƒ||j_dS(N(RDthandle_doctypeRt root_elem(R trootnametpub_idtsys_id((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR0scCs|jjƒdS(N(RDt doc_start(R ((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR†7scCs|jj|ƒdS(N(RDthandle_comment(R R((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR‡:scCs|jj|||ƒdS(N(RDR`(R RRbRc((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR`=scCs|jj||ƒdS(N(RDt handle_pi(R ttargetR((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyRˆ@scCs|jj|||ƒdS(N(RDtset_entity_info(R txmlvertenctsddecl((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyRŠCs(R@RARBR R RR RRTR^RaRRRrR}RR†R‡R`RˆRŠ(((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyR‘s$      #   *      (( RBturlparsetostanydbmR\tcPicklettimetxmlproctxmldtdtxmlappRRR(((sL/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlval.pyts H