[XML-SIG] Multiple top nodes
Wed, 1 Nov 2000 09:39:14 +1300 (NZDT)
On 31 Oct 2000, Lars Marius Garshol wrote:
> * firstname.lastname@example.org
> | [...] which worked great. I'm having exactly 0 luck getting the same
> | sort of thing to work with 0.6.1. The key in this case was using a
> | DocumentHandler that stuffed the DOM into a DocumentFragment, not a
> | Document (which must be well formed).
> Could you provide us with the exact error message you get?
> I have a suspicion that your problem might be related to your trying
> to parse a non-wellformed XML document. :-)
Thanks for the reply. A quick example -
With a file called some.xml with contents -
and using FromXmlFile to parse some.xml into a DOM -
Python 2.0 (#1, Oct 16 2000, 18:10:03)
[GCC 2.95.2 19991024 (release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from xml.dom.ext.reader.Sax2 import FromXmlFile
Traceback (most recent call last):
File "<stdin>", line 1, in ?
line 276, in FromXmlFile
rv = FromXmlStream(fp, ownerDocument, validate, keepAllWs, catName,
line 256, in FromXmlStream
line 68, in parseFile
if self.parser.Parse(buf, 0) != 1:
xml.parsers.expat.error: junk after document element: line 6, column 0
Which I would have expected, if it was trying to parse into a Document. My
reading of -
suggests that if I was to parse into a DocumentFragment (which is what I
did with SaxBuilder in my original example), the document should be able
to have more than one top-level node.
A little more detail might help -- I'm looking to have a number of
different programs writing 'snippets' of XML into different files, which
then get read by a different program, parsed into DocumentFragment, and
then written back out to a file which will be Well Formed.
I could just read the files in blindly, manually put root tags around the
lot, and write them out again, but I may want to manipulate the DOM before
I write it out, and I'd like to check that the fragments are individually
well formed (well, as well formed as a document could be with multiple top
iOpen Technologies Ltd.