4)$?c@s?dZdZddlZddlZddlZddlmZdZdfdYZ de fd YZ d e fd YZ d e fd YZ dfdYZ dejjjjfdYZde fdYZdefdYZde fdYZdfdYZdefdYZdS(sSAX document handlers that support output generation of XML, SGML, and XHTML. This module provides three different groups of objects: the actual SAX document handlers that drive the output, DTD information containers, and syntax descriptors (of limited public use in most cases). Output Drivers -------------- The output drivers conform to the SAX C protocol. They can be used anywhere a C is used. Two drivers are provided: a `basic' driver which creates a fairly minimal output without much intelligence, and a `pretty-printing' driver that performs pretty-printing with nice indentation and the like. Both can optionally make use of DTD information and syntax objects. DTD Information Containers -------------------------- Each DTD information object provides an attribute C which describes the expected output syntax; an alternate can be provided to the output drivers if desired. Syntax Descriptors ------------------ Syntax descriptor objects provide several attributes which describe the various lexical components of XML & SGML markup. The attributes have names that reflect the shorthand notation from the SGML world, but the values are strings which give the appropriate characters for the markup language being described. The one addition is the C attribute which should be used to end the start tag of elements which have no content. This is needed to properly support XML and XHTML. s$Revision: 1.9 $iN(tescapeiJtSyntaxcBsweZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZd ZdZdZRS(s--s&#t;t[t]t&t"s"t'ss]]ss?>N(RRR$R%tNoneR&(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyR'Vst XHTMLSyntaxcBseZdZRS(s />(RRR$(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyR)\st DoctypeInfocBseZeZd Zd ZdZdZdZ dZ dZ dZ dZ dZdZd Zd ZRS( cCsi|_i|_i|_dS(N(t_DoctypeInfo__emptiest_DoctypeInfo__elements_onlyt_DoctypeInfo__attribs(R ((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRgs  cCs|jj|S(N(R+thas_key(R tgi((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytis_emptylscCs |jjS(N(R+tkeys(R ((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytget_empties_listoscCs|jj|S(N(R,R.(R R/((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pythas_element_contentrscCs |jjS(N(R,R1(R ((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytget_element_containers_listuscCs|jj|ijS(N(R-tgetR1(R R/((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytget_attributes_listxscCs|j||S(N(R-(R R/tattr((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytget_attribute_info{scCsd|j| attribute %s already defined(R-tKeyErrorR.(R R/R7ttypetdecltdefaulttd((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytadd_attribute_defns cCs tddS(Ns'sublasses must implement load_pubtext()(tNotImplementedError(R tpubtext((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt load_pubtextsN(RRR'tsyntaxR(tfpitsysidRR0R2R3R4R6R8R9R:R@RC(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyR*as           t _XMLDTDLoadercBseZdZdZRS(cCs5||_tjjjjj|||j|_dS(N( tinfotxmltparserstxmlproctxmlappt DTDConsumerRR@t new_attribute(R RHtparser((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRs cCsc|ddkr'|dddkr'n8|dgdfkrO|jj|n|jj|dS(Nit|is#PCDATAt(s#PCDATARQ(RHR9R:(R R/tmodel((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytnew_element_types $(RRRRS(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRGs tXMLDoctypeInfocBseZdZRS(cCsBtjjjj}t||}|j||j|dS(N(RIRJRKt dtdparsert DTDParserRGtset_dtd_consumertparse_resource(R RFROtloader((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRCs (RRRC(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRTstXHTMLDoctypeInfocBseZeZRS((RRR)RD(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRZstSGMLDoctypeInfocBsMeZeZddlZejdejjZe dZ [dZ RS(iNs s&%sxml version=%s1.0%s encoding%s%s%s%ss%s standalone%s%s%s%ss%s%s (RzR%RRR!RsRxRp(R Rts((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt startDocuments  "cCs|jrtdndS(Ns+open element stack cannot be empty on close(RtR (R ((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt endDocuments c Csh|jr|j|n|j|j||j|||jdrf|d|_|d=n|jrxd}n#|jr|j |j }nd}d||j j |f}d|t |df}|j j}|j j}|j j}d}|j|jddkr\|jdk r6|j|jkr6q\d||d d g|j|f}n|j|jdd krd ||||j|f}n||} |jt | |_d}xV|jD]H\} } | dkrqnt| } tj| |dkr2d | ||tt| |f}nutj| |dkrrd | ||tt| |f}n5d | ||tt| i|j j|6|f}|jt ||jkr|j| d||} t | |_q| |} |jt ||_qW|j| d |_|jrd|jj |pT|jj!| rdd |_ndS(Nsxml:langRQs%s%s%ss%s %st iis xml:space%s%s%s%sR>tpreserveis%s xml:lang%s%s%s%ss %s%s%s%s%ss ("Rwthandle_doctypet_check_pending_contentt_XmlWriter__pushtagt_XmlWriter__check_flowingR.RuRmRnRrR{RzRRiRRR!RtRqR(tlangRltitemststrR`tfindRRR~RpRvRyR3R0( R ttagtattrstprefixtstagRRR!tatlinetktv((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt startElementsj           #   ((       cCsx|jr|jrf|j|jj|jrM|jt|jj|_q|jdd|_n/|j|jj|jt|jj|_d|_|j|dSt|j }|dks|js|j rd}n|j |j d|j }|j||jd||jj ||jjf|jr^|jt|d|_n|jdd|_dS(Ns iiRQRs%s%s%s%si(RvRnRpRzR$RmRlRit_XmlWriter__poptagRtRrR{R|RR (R RtdepthR((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt endElement9s2             cCs||||!}|r|jt|}d|kretj|d}t||d|_n|jt||_|j|j|ndS(Ns i(RRR`RRiRlRp(R tdatatstarttlengthtp((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt charactersXs    cCs||||!}|jd|jj|jj||jj|jjf}tj|d}|jr|dkrt||d|_ q|j t||_ n#|j d|j |fd|_ dS(Ns %s%s%s%s%ss iis%s%s ( RRzRRRR`trfindRmRiRlRpRr(R RRRRR((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytcommentes   cCsdS(N((R RRR((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytignorableWhitespacetscCs|jd|jj|||jjf}|j|j d|j}d|krtj|d}|j r|j r|j ||dd|_ q|j |t ||d|_ nW|j r|j r|j ||dd|_ n#|j ||j t ||_ dS(Ns %s%s %s%sRs ii(RRzRR%RrR{R|R`RRnRmRpRlRi(R ttargetRRRR((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pytprocessingInstructionws  "     cCsed|_|jr-|jj}|jj}n d}}|jj}|jjdk}|r|rd|jj|f}|r|d|||f}|d|||f}n|d|||f}|j |d|_ n|sad|jj|f}|rd||||f}n|r8d ||||f}n|j d ||jj fd|_ ndS( Nis?>s %sDOCTYPE %s s PUBLIC %s%s%s s %s%s%s> s SYSTEM %s%s%s> s %sDOCTYPE %ss%s PUBLIC %s%s%ss%s SYSTEM %s%s%ss%s%s ( RwRyRERFR(RzRR%RRpRlR(R trootRERFRtisxmlR((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRs.        cCs|j|jjd}|jj|jj}d|t||f}|jrd|krtj|d}t ||dt ||_ n$|j t |t |||_ |j |nd|_ |j |ddS(Ns[CDATA[s%s%s%ss ii( RRzRRRRRmR`RRiRlRp(R RRR_Rtrpos((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt handle_cdatas   $$ cCsj|jj}|\|_|_}|_|_||krRtd||fn|j|j |_dS(Nsexpected , got ( RttpopRnRuRmRqR RrR{(R Rtstatet expected_tag((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt__poptags ! cCsF|jj|j|j||j|jf|jd|j|_dS(NR(RttappendRnRuRmRqRrR{(R R((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt __pushtagscCsd}}|jrwy|jj|d}Wntk rEd}nX|dk rw|ddk|_|j|_qwn|jdr|ddk|_|d=ndS(snCheck the contents of attrs and the DTD information to determine whether the following content should be flowed. tag -- general identifier of the element being opened attrs -- attributes dictionary as reported by the parser or application This sets up both the _flowing and _dtdflowing (object) attributes. s xml:spaceiRN(R(RyR8R;RnRqR.(R RRtdocspectdtdspecRH((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt__check_flowings     cCsq|jrm|jj}|jr>|j r>|d}d|_n|jt||_|j|d|_ndS(Ns i(RvRzR RnRmRlRiRp(R R((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRs     N(RRt__doc__R(RRRRRRRRRRRRRRRR(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRks$   ;        t PrettyPrintercBs2eZdZdddddddZdZRS(s#Pretty-printing XML output handler.ic CsVtj||d|d|d|d|||_|dk rI||_n ||_dS(NRRRDR(RkRR{R(R|(R RRRRDRR{tendtagindentation((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRs     cCs||||!}|sdS|jt|}|jsK|j|dStj|}|dtjk}|o|dtjk}|j}t|dkrd}n|j }g} | j } |r| d|d}nd} d} x|r|d} |d=|| t| |j krY| d| || | t|t| }q| | d \} } | | |dt| }qW|r| d|d}n||_ |jtj | ddS( Niii(s RiRQs (Ri( RRRnRpR`RcRaRrRiRlRR~tjoin(R RRRtwordstbegspacetendspaceRtoffsettLRtwstws_lentw((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRsN                     N(RRRR(RR(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyRs  (Rt __version__R`txml.parsers.xmlproc.dtdparserRItxml.parsers.xmlproc.xmlapptxml.sax.saxutilsRR}RR"R'R)R*RJRKRLRMRGRTRZR[RkR(((s@/opt/freeware/lib/python2.7/site-packages/_xmlplus/sax/writer.pyt*s$   1"#