No, that's not at all what I'm saying.  I said:

   "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."

   1. Create an instance of the Xerces DOM through whatever means Xerces
   provides.
   2. Modify it as desired.
   3. Create a wrapper and do an XPath query.
   4. Recover the information from the XPath query.
   5. Destroy the wrapper.
   6. Repeat 2-5 as necessary.

You may want to rethink this process.  You're essentially using a document
as a database, which is not an optimal use of the DOM.  Depending on the
size of the document, and the number of queries, you're going to be doing a
lot of work.

Xerces provides no way to serialize a document.  To do that, you must wrap
it and serialize through Xalan.  You can do that through an identity
transformation stylesheet, or by serializing the document with Xalan's
FormatterToXML.  There is some sample code in TestXSLT/process.cpp that
does this, or there is a sample called SerializeNodeSet that shows how you
can serialize a fragment.

Dave



                                                                                
                                               
                      sk ask                                                    
                                               
                      <[EMAIL PROTECTED]         To:      
[email protected]                                           
                      oo.com>                  cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                                   
                                               Subject: Re: Updating 
XalanDocument as elements are added to Xerces Doc         
                      05/31/2002 04:22                                          
                                               
                      AM                                                        
                                               
                                                                                
                                               
                                                                                
                                               




Hi,
 If I read an existing file and don't have to make
changes - xalan usage is straight forward.

 In the current case I am creating a xml file from
scratch, but need to do xpath queries often to see
if something is already been added. If I understand
your method correctly, I should just create an
xalan document from an empty xerces doc and just use
the xalan document for the all my stuff and finally
(if needed) export it as xerces(is this possible?)
or just save the xalan document to disk.

 Thanks for all the comments thus far.

--- David N Bertoni/Cambridge/IBM
<[EMAIL PROTECTED]> wrote:
>
> 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
>
>
>
>
>


=====


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com





Reply via email to