[XML-SIG] losing cdata tag

Paul Tremblay phthenry@earthlink.net
Wed, 29 May 2002 00:28:07 -0400


On Mon, May 27, 2002 at 08:43:37AM +0200, Martin v. Loewis wrote:

> 
> Paul Tremblay <phthenry@earthlink.net> writes:
> 

> Not really. It first tries pirxx (which is not part of PyXML, but
> could be installed on your system); it then tries xmlproc, then
> expat. With PyXML installed and pirxx not, it will always use xmlproc.
> 

I can't figure out what xml processor python is using:

which: no xmlproc in (/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/home/paul/bin)
which: no expat in (/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/home/paul/bin)
which: no pirxx in (/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/home/paul/bin)

In fact, expat is part of my Mandrake distribution, so I could
install this. How exactly do you find out which processor is
being used, and how can you control this? 

> 
> I cannot reproduce this problem. Given the document
> 
> <?xml version="1.0"?>
> <foo>
> <![CDATA[<some text>]]>
> </foo>

I re-tried my code with  your example above, and got this result:

<foo > 
<some text>
</foo>

The code I'm using is below. 

Thanks!

Paul


***************************

#!/usr/bin/python

from xml.sax import saxutils


from xml.sax import make_parser
from xml.sax.handler import feature_namespaces


class CopyTree(saxutils.DefaultHandler):
	def __init__(self):
		self.character = ""
 

	def startElement(self, name, attrs):
		
		print "<" + name,
		for theKey in attrs.keys():
				print " " + theKey + "=\"" + attrs[theKey] + "\"",
		print  ">",

	def characters(self, ch):
		self.character = self.character + ch
		

	def endElement(self, name):
		print self.character + "</" + name + ">",
		self.character=""

parser = make_parser()

#Tell the parser we are not interested in XML namespaces
parser.setFeature(feature_namespaces, 0)

# Create the handler
dhObj = CopyTree()

# Tell the parser to use our handler
parser.setContentHandler(dhObj)

# Parse the input
file = "/home/paul/paultemp/test.xml"

parser.parse(file)




-- 

************************
*Paul Tremblay         *
*phthenry@earthlink.net*
************************