You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Sergey Petrunia <se...@rwwws.ru> on 2002/04/24 21:08:32 UTC

Is there any way to evaluate Xpath on a writeable document?

Hello,
 I am using Xalan in application that needs to 
   1. evaluate an XPath expression on document
   2. modify the source document 
   3. repeat steps 1-2 several times.
The problem is that parsing the source document the way it is done in
XPath API samples gives a readonly document, so in step 3 I have to
construct a new document and feed it back to Xalan, which makes code
slow and complicated. Is there any way to evaluate Xpath expressions on
a writeable document in Xalan?

BR
--Sergey Petrunia


Re: Is there any way to evaluate Xpath on a writeable document?

Posted by "Ushakov, Sergey N" <us...@int.com.ru>.
Why not consider doing without Xalan? At least on some stages?

Say,
1) load initial document into in-memory DOM;
2) manipulate and modify this DOM using XPath and whatsoever until final
satisfaction :)
3) use Xalan for serialization of the resulting document.

Regards,
Sergey Ushakov
P.S. Perhaps "xalan-j-users" might be a better playground for this
discussion...


----- Original Message -----
From: "Sergey Petrunia" <se...@rwwws.ru>
To: <xa...@xml.apache.org>
Sent: Wednesday, April 24, 2002 11:08 PM
Subject: Is there any way to evaluate Xpath on a writeable document?


> Hello,
>  I am using Xalan in application that needs to
>    1. evaluate an XPath expression on document
>    2. modify the source document
>    3. repeat steps 1-2 several times.
> The problem is that parsing the source document the way it is done in
> XPath API samples gives a readonly document, so in step 3 I have to
> construct a new document and feed it back to Xalan, which makes code
> slow and complicated. Is there any way to evaluate Xpath expressions on
> a writeable document in Xalan?
>
> BR
> --Sergey Petrunia
>
>


Re: Is there any way to evaluate Xpath on a writeable document?

Posted by Bogdan Pilch <bp...@artax.karlin.mff.cuni.cz>.
> Hello,
>  I am using Xalan in application that needs to
>    1. evaluate an XPath expression on document
>    2. modify the source document
>    3. repeat steps 1-2 several times.
> The problem is that parsing the source document the way it is done in
> XPath API samples gives a readonly document, so in step 3 I have to
> construct a new document and feed it back to Xalan, which makes code
> slow and complicated. Is there any way to evaluate Xpath expressions on
> a writeable document in Xalan?

I haven't found any other way than just use XSLT to add new tag or remove
the tag from XML file and then reread it in Xalan.
Or You can construct new tree right in the memory using Xalan methods.

One more way: Use Xercer (DOM) and implement Your own XPath.
If You don't need too complicated regex XPath expressions, it shouldn't be
too hard.

	Bogdan
--------------------------------------------------------------------
  "Those who would give up a little freedom for a little safety,
         deserve neither freedom nor safety." --Benjamin Franklin