ó \STc@s‚dZddlZddlTddlTdefd„ƒYZdefd„ƒYZdd(d „ƒYZd efd „ƒYZd d)d „ƒYZ dd*d„ƒYZ dd+d„ƒYZ dd,d„ƒYZ dd-d„ƒYZ de fd„ƒYZde fd„ƒYZd„Zd„Zd„Zd„Zd„Zdd „Zd!„Zd"„Zd#„Zd$„Zd%„Zd&„Zd'„ZdS(.s These are the DTD-aware classes of xmlproc. They provide both the DTD event consumers for the DTD parser as well as the objects that store DTD information for retrieval by clients (including the validating parser). $Id: xmldtd.py,v 1.18 2002/04/13 19:13:16 larsga Exp $ iÿÿÿÿN(t*tWFCDTDcBsøeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s*DTD-representing class for the WFC parser.cCs-tj||ƒt|ƒ|_|jƒdS(N(t DTDConsumert__init__t dtd_listenertreset(tselftparser((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRscCs\i|_i|_i|_i|_i|_x(tjƒD]}|j|t|ƒq:WdS(sClears all DTD information.N(tgen_entst param_entstelemstattrinfotused_notationst predef_entstkeystnew_general_entity(Rtname((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRs     cCs ||_dS(s6Registers an object that listens for DTD parse events.N(R(Rtlistener((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytset_dtd_listener'scCs |j|S(s}Returns the entitiy object associated with this parameter entity name. Throws KeyError if the entity is not declared.(R (RR((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt resolve_pe+scCs |j|S(s{Returns the entitiy object associated with this general entity name. Throws KeyError if the entity is not declared.(R(RR((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt resolve_ge0scCs |jjƒS(s3Returns the names of all declared general entities.(RR(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytget_general_entities5scCs |jjƒS(s5Returns the names of all declared parameter entities.(R R(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytget_parameter_entities9scCs |j|S(s_Returns the declaration of this element. Throws KeyError if the element does not exist.(R (RR((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytget_elem=scCs |jjƒS(s-Returns a list of all declared element names.(R R(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt get_elementsBscCst|ƒ‚dS(s`Returns the declaration of the notation. Throws KeyError if the notation does not exist.N(tKeyError(RR((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt get_notationFscCsgS(s,Returns the names of all declared notations.((R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt get_notationsKscCsdS(sUReturns the name of the declared root element, or None if none were declared.N(tNone(RR((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt get_root_elemOscCsYi|_x<|jjƒD]+}|jƒ|jƒf|j|jƒeZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs(||_||_||_||_dS(N(RR<R=RP(RRR<R=RP((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRîs   cCs |jdkS(s True if this is a parsed entity.R?(RP(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt is_parsedôscCsdS(Ni((R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyR“øscCs|jS(s,Returns the public identifier of the entity.(R<(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt get_pubidûscCs|jS(s,Returns the system identifier of the entity.(R=(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt get_sysidÿscCs|jS(s=Returns the notation of the entity, or None if there is none.(RP(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRs(RHRIRR•R“R–R—R(((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyR9ìs      t FNDABuildercBszeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „ZRS( s,Builds a finite non-deterministic automaton.cCs"d|_gg|_g|_dS(Ni(t_FNDABuilder__currentt_FNDABuilder__transitionst_FNDABuilder__mem(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRs  cCs|jj|jƒdS(s-Makes the builder remember the current state.N(R›RWR™(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytremember_statescCs|jd|_dS(sbMakes the current state the last remembered one. The last remembered one is not forgotten.iÿÿÿÿN(R›R™(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytset_current_to_rememberedscCs|jd=dS(s6Makes the builder forget the current remembered state.iÿÿÿÿN(R›(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt forget_statescCs*|jjgƒt|jƒd|_dS(s6Creates a new last state and makes it the current one.iN(RšRWR‚R™(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt new_state"scCs|jS(s.Returns the automaton produced by the builder.(Rš(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt get_automaton'scCs|jS(sReturns the current state.(R™(R((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytget_current_state+scCs|j|j||fƒdS(s4Creates a new transition from frm to to, over label.N(RšRW(Rtlabeltfrmtto((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytnew_transition/scCsF|jƒ|jƒ|j|jdj|j|fƒ|jƒdS(slCreates a new transition from the current state to a new state, which becomes the new current state.iÿÿÿÿN(RœRŸRšR›RWR™Rž(RR¢((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytnew_transition_to_new3s  $cCs(|j|jj|jd|fƒdS(sRAdds a new transition from the current state to the last remembered state.iÿÿÿÿN(RšR™RWR›(RR¢((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytnew_transition_cur2rem;scCs(|j|jdj|j|fƒdS(sSCreates a new transition from the current state to the last remembered one.iÿÿÿÿN(RšR›RWR™(RR¢((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytnew_transition_rem2cur@scCs!|j|j|j|fƒdS(s?Creates a new transition from frm to current state, with label.N(RšRWR™(RR£R¢((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pytnew_transition_2curEs(RHRIRJRRœRRžRŸR R¡R¥R¦R§R¨R©(((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyR˜ s           t ContentModelcBs,eZdZd„Zd„Zdd„ZRS(s1Represents a singleton content model. (Internal.)cCs||_||_dS(N(R/tmodifier(RR/R«((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRNs cCsî|jdkr@|jƒ|j|ƒ|jdƒ|jƒnª|jdkr|j|ƒ|jƒ|j|dƒ|jƒ|jƒn]|jdkrÝ|jƒ|jdƒ|j|dƒ|jdƒ|jƒn |j|ƒdS(sBBuilds the part of the automaton corresponding to this model part.t?R?t+iRN(R«Rœt add_contentsR¨RžRR¦(Rtbuilder((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyt add_statesRs$            icCsÂt|jdƒtjkr{|rd|jƒ|jdj|ƒ|jdƒ|jƒ|jƒq¾|jdj|ƒnC|rª|j |jd|j ƒ|j ƒƒn|j |jdƒdS(s‹Adds the states and transitions belonging to the self.contents parts. If loop is true the states will loop back to the first state.iR?N( RbR/Rct InstanceTypeRœR°R§RRžR¥R¡R¦(RR¯tloop((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyR®hs     (RHRIRJRR°R®(((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRªKs  tSeqContentModelcBseZdZdd„ZRS(s2Represents a sequential content model. (Internal.)icCsX|r|jƒnx|jD]}|j|ƒqW|rT|jdƒ|jƒndS(NR?(RœR/R°R§Rž(RR¯R²tcp((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyR®s  (RHRIRJR®(((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyR³~stChoiceContentModelcBseZdZdd„ZRS(s.Represents a choice content model. (Internal.)icCsª|jƒg}xH|jD]=}|jƒ|jdƒ|j|ƒ|j|jƒƒqW|jƒx|D]}|j|dƒqlW|rœ|jdƒn|j ƒdS(NR?( RœR/RŸR¨R°RWR¡R©R§Rž(RR¯R²t end_statesR´Rm((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyR®‘s      (RHRIRJR®(((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pyRµŽscCs>d}d}x+|D]#}|r,||}n|d}qW|S(s.Creates a hash number from the included array.ill((tincludedtnotexpRm((sN/opt/freeware/lib64/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmldtd.pythash¨s  c CsÊ|jgƒi}i}dgt|ƒ}td||ƒt|ƒ}||ds6   ŸXtL !>3 & 2