[XML-SIG] Re: Could somebody help me?
Uche.Ogbuji at fourthought.com
Fri Jan 28 16:13:02 CET 2005
On Fri, 2005-01-28 at 15:48 +0530, Prasad PS wrote:
> Sure, here is the code
> In the code below, what I am doing is - I am opening an xml file and
> appending a node to the root document. Then I add this root document to
> the xml file
> fp = open (string.strip(self.cnfDtls.GetLogFilePath()), 'w')
> xml.dom.ext.PrettyPrint(doc, self.xmlFile)
So you tried the first choice (PyXML) rather than the second (Amara).
OK. You were not clear on that.
Your first problem is that you're using xml.dom.ext.reader.FromXmlStream
from xml.dom import minidom
doc = minidom.parse(string.strip(self.cnfDtls.GetLogFilePath()))
doc.toprettyxml() (rather than xml.dom.ext.PrettyPrint)
That's the fault of the PyXML docs, which should really be updated.
Side question: you mean you're appending a node to the document element,
right? Not the root document. The latter would result in an invalid
XML document entity.
In the code you posted, it looks as if you only append to subsidiary
nodes, so that should be OK.
Even using 4DOM, your general approach should work, and I've used it
oftentimes before (in the far-off past), with no problem, so I wonder:
Are you sure self.xmlFile is "empty" at the point of the
If so, I suggest you whittle down a test case that reveals the apparent
bug, and post data and complete, runnable code (preferably after
switching to minidom). If it seems a clear bug, you can use the PyXML
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
Use CSS to display XML - http://www.ibm.com/developerworks/edu/x-dw-x-xmlcss-i.html
Introducing the Amara XML Toolkit - http://www.xml.com/pub/a/2005/01/19/amara.html
Be humble, not imperial (in design) - http://www.adtmag.com/article.asp?id=10286
UBL 1.0 - http://www-106.ibm.com/developerworks/xml/library/x-think28.html
Manage XML collections with XAPI - http://www-106.ibm.com/developerworks/xml/library/x-xapi.html
Default and error handling in XSLT lookup tables - http://www.ibm.com/developerworks/xml/library/x-tiplook.html
Packaging XSLT lookup tables as EXSLT functions - http://www.ibm.com/developerworks/xml/library/x-tiplook2.html
More information about the XML-SIG