You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by "Helzer, Mark" <Ma...@adp.com> on 2010/05/19 02:28:39 UTC

Appropriate use of XPath & xerces

Hi all,

Documentation and the list archive say that you can use a Xerces DOM document if you wish to update your document while using XPath. Or at least something similar, perhaps I'm misconstruing the intent.

Here is what I would like to do:

I have an existing app using Xerces DOM where I create/update an XML document.  Looping through a cvs file, extracting the data and updating or adding elements in the XML as needed.  This was working fine until the data and the # of elements were smaller.  After adding new types of data performance has gone in the hopper.

I would like to be able to use XPath to locate nodes for update,  if the node is not found I would add the new element and refresh the document tree.

Perhaps this is not how XPath is intended to be used?

Mark Helzer



This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.

Re: Appropriate use of XPath & xerces

Posted by David Bertoni <db...@apache.org>.
On 5/18/2010 5:28 PM, Helzer, Mark wrote:
> Hi all,
>
> Documentation and the list archive say that you can use a Xerces DOM document if you wish to update your document while using XPath. Or at least something similar, perhaps I'm misconstruing the intent.
>
> Here is what I would like to do:
>
> I have an existing app using Xerces DOM where I create/update an XML document.  Looping through a cvs file, extracting the data and updating or adding elements in the XML as needed.  This was working fine until the data and the # of elements were smaller.  After adding new types of data performance has gone in the hopper.
>
> I would like to be able to use XPath to locate nodes for update,  if the node is not found I would add the new element and refresh the document tree.
>
> Perhaps this is not how XPath is intended to be used?
Unfortunately, you haven't provide nearly enough specific information to 
answer your question.

In general, Xalan-C's wrapper around the Xerces-C DOM is not that 
efficient for modifying a document. In particular, it's a requirement 
you rebuild the wrapper when you make modifications, so it would be 
better if you evaluated all of the XPath expressions at once, then made 
all of the modifications.

If you could post some code snippets, and be more specific about exactly 
what changes are causing the performance problem, that would be helpful.

Also, this is exactly the kind of manipulation that XSLT was designed to 
do, so you might consider writing a stylesheet to do this transformation.

Dave