Changeset 2922:0832d2a1840f in livinglogic.python.xist

Show
Ignore:
Timestamp:
09/12/07 15:37:46 (12 years ago)
Author:
Walter Doerwald <walter@…>
Children:
2923:f038a4fc8989, 2928:d5b0b3944e0b, 2932:288938cee0e0
Branch:
default
Message:

Use the XML codec for publishing. Remove ns.xml.XML10, but add constructor arguments to ns.xml.XML.

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • NEWS.rst

    r2911 r2922  
    3838*   The method :meth:`asBytes` has been renamed to :meth:`bytes` and :meth:`bytes` 
    3939    has been renamed to :meth:`iterbytes`. 
     40 
     41* :class:`ll.xist.ns.xml.XML10` is gone now. Use :class`ll.xist.ns.xml.XML` 
     42  instead. 
    4043 
    4144*   A class attribute :attr:`empty` inside element classes will now no longer get 
  • NEWS.xml

    r2911 r2922  
    4141<item>The method <method>asBytes</method> has been renamed to <method>bytes</method> 
    4242and <method>bytes</method> has been renamed to <method>iterbytes</method>.</item> 
     43 
     44<item><class>ll.xist.ns.xml.XML10</class> is gone now. Use 
     45<class>ll.xist.ns.xml.XML</class> instead.</item> 
    4346 
    4447<item>A class attribute <lit>empty</lit> inside element classes will now no 
  • src/ll/xist/ns/xml.py

    r2903 r2922  
    3535class XML(xsc.ProcInst): 
    3636    """ 
    37     &xml; declaration. The encoding will be automatically set when publishing. 
     37    &xml; declaration. The encoding will be automatically set when publishing 
     38    (by the &xml; codec). 
    3839    """ 
    3940    xmlname = "xml" 
    4041 
    41     def publish(self, publisher): 
    42         content = self.content 
    43         encodingfound = utils.findattr(content, u"encoding") 
    44         versionfound = utils.findattr(content, u"version") 
    45         standalonefound = utils.findattr(content, u"standalone") 
    46         if publisher.encoding != encodingfound: # if self has the wrong encoding specification (or none) we construct a new XML ProcInst and publish that (this doesn't lead to infinite recursion, because the next call will skip it) 
    47             node = XML(u"version='%s' encoding='%s'" % (versionfound, publisher.encoding)) 
    48             if standalonefound is not None: 
    49                 node += u" standalone='%s'" % standalonefound 
    50             return node.publish(publisher) # return a generator-iterator 
    51         return xsc.ProcInst.publish(self, publisher) # return a generator-iterator 
    52  
    53  
    54 class XML10(XML): 
    55     """ 
    56     &xml; declaration with <lit>version="1.0"</lit>. 
    57     """ 
    58     xmlns = xmlns 
    59     xmlname = "xml10" 
    60     register = False # don't register this ProcInst, because it will never be parsed from a file, this is just a convenience class 
    61  
    62     def __init__(self): 
    63         XML.__init__(self, u'version="1.0"') 
     42    def __init__(self, version="1.0", encoding="utf-8"): 
     43        xsc.ProcInst.__init__(self, u'version="%s" encoding="%s"' % (version, encoding)) 
    6444 
    6545 
  • src/ll/xist/publishers.py

    r2909 r2922  
    1818 
    1919from ll import misc, url 
     20from ll import xml_codec # registers the "xml" encoding 
    2021 
    2122import xsc, helpers 
     
    3839    """ 
    3940 
    40     def __init__(self, encoding="utf-8", xhtml=1, validate=True, prefixes={}, prefixdefault=False, hidexmlns=()): 
    41         """ 
    42         <par><arg>encoding</arg> specifies the encoding to be used for the byte sequence.</par> 
     41    def __init__(self, encoding=None, xhtml=1, validate=True, prefixes={}, prefixdefault=False, hidexmlns=()): 
     42        """ 
     43        <par><arg>encoding</arg> specifies the encoding to be used for the byte sequence. 
     44        If <lit>None</lit> is used the encoding in the &xml; declaration will be 
     45        used. If there is none, UTF-8 will be used.</par> 
    4346 
    4447        <par>With the parameter <arg>xhtml</arg> you can specify if you want &html; output:</par> 
     
    214217        self.node = node 
    215218 
    216         self.encoder = codecs.getincrementalencoder(self.encoding)() 
     219        self.encoder = codecs.getincrementalencoder("xml")(encoding=self.encoding) 
    217220 
    218221        for part in self.node.publish(self):