OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Adding nodes without modifing non-infoset of a document

[ Lists Home | Date Index | Thread Index ]

I want to add some elements to an existing XML document at well defined positions without modifing the concret representation of the XML document.
Especially I want to keep the overall 'formatting' of attributes and the indentation. Generally speaking, the so-called non-infoset
(see http://lists.xml.org/archives/xml-dev/200504/msg00340.html)
should remain unchanged.
My programming language is Java.

What is the best way?
- If I use DOM or SAX, the formatting of the attributes and others will be lost.
- Manually parsing the XML is a pain.

I'm thinking about a hybrid solution:
- parse the document with SAX,
- keep track of the location in the file with a Locator,
- generate new DOM nodes in the SAX ContentHandler at the defined position(s),
- stream out the original byte stream, mixed with the new nodes at the appropriate locations.
Seems to be less pain, but still looks rather complicated.

Do you have any better suggestions?
Is there something similar to SAX events that also regards the non-infoset? 


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS