The best thing to do is make all changes through the Xerces DOM interfaces. Then, when you're ready to do an XPath query, create a wrapper and do the query. That way, you avoid building the wrapper only to rebuild it later. If you do build a wrapper, then you change the underlying DOM, you must rebuild the wrapper.
This usage pattern shows how the build the wrapper: http://xml.apache.org/xalan-c/usagepatterns.html#dom Here are the relevant lines: DOMParser theParser; // You MUST instruct the Xerces DOMParser NOT to create a DOM_XMLDecNode // in the DOM to represent the XML declaration. See "Limitations" below. DOMParser::setToCreateXMLDeclTypeNode(false); theParser.parse("foo.xml"); const DOM_Document theDOM = theParser.getDocument(); // Put any code here which modifies the DOM instance. // Set up a XercesParserLiaison and use it to wrap the DOM_Document // in a XalanDocument. XercesDOMSupport theDOMSupport; XercesParserLiaison theParserLiaison(theDOMSupport); XalanDocument* theDoc = theParserLiaison.createDocument(theDOM); // Put the XPathAPI query code here. Remember -- using the Xerces DOM is _much_ slower than using Xalan's source tree, so only do this if you really need to modify the DOM between the time you parse it and the time you query it. If you have any other questions, please post them. There are also some examples of this sort of thing in the archives of the Xalan developer and Xalan-C user lists. Dave sk ask <[EMAIL PROTECTED] To: Xalan Xalan <[email protected]> oo.com> cc: (bcc: David N Bertoni/Cambridge/IBM) Subject: Updating XalanDocument as elements are added to Xerces Doc 05/30/2002 12:33 PM > Hi, > In some rare cases I have to add some elements to > the > xerces document, and then use xpath later. > > What would be a good way to do this? Thanks in advance for any info. ===== __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
