[XML-SIG] producing large XML files

Jürgen Schmidt scjuonline@web.de
Thu, 19 Sep 2002 15:23:25 +0200


Ok. 
Here is what I've tried:

#!/usr/local/bin/python

import sys
from xml.sax.writer import XmlWriter

class layoutwriter(XmlWriter):
    def __init__(self):
        XmlWriter.__init__(self,sys.stdout)

lw = layoutwriter()
lw.startDocument()
lw.startElement("doc")
lw.characters("Hallo",0,len("Hallo"))

# lw.handle_cdata("<b>das ist html<b>")
# if you uncomment this, one will get:
# <?xml version="1.0" encoding="iso-8859-1"?>
# <doc>Hallo<![CDATA[&lt;b&gt;das ist html&lt;b&gt;]]></doc>
#
# but shouldn't the data appear without escaping?

#
# lw.comment("great",0,len("great"))
# if you uncomment this, the comment won't show up (in the xml ;-)

# lw.processingInstruction("target",'data="wert\n"')
# if you uncomment this, one will get:
#<?xml version="1.0" encoding="iso-8859-1"?>
#<doc>Hallo<?target data="wert"?>
#Traceback (most recent call last):
#  File "/home/scju/tmp/xmlwriter/write.py", line 16, in ?
#    lw.processingInstruction("target",'data="wert"')
#  File "/usr/local/lib/python2.2/site-packages/_xmlplus/sax/writer.py", line
#392, in processingInstruction
#    self._offset = len(s) - (p + 1)
#NameError: global name 'p' is not defined
# Is my function call wrong?

lw.endElement("doc")
lw.endDocument()

thx
Juergen