On Tuesday 12 November 2002  3:34 pm, Benjamin Reitzammer wrote:
> Hello,
> I want to "transform" a XML document, but not in the sense of XSLT. I
> have a lot of documents, that contain primary keys of a database, like:
> <report id="123"> ... </report>
>
> Now the DBA must do something with the db (don't ask me what it is, I
> simply don't know it), that will change almost all of the primary keys,
> which means, that the references in my XML documents will be wrong.
> Therefore I will have to read/parse the XML documents, transform all of
> the "old" primary keys to the "new" primary keys, and write out the
> documents again.
>
> Because I used Digester quite often already, I wondered if it could be
> used for this problem.
>
> My question is (finally): Can Digester tell me, which tags he has parsed
> already, and is parsing at the moment? Then I could simply write this
> data, to a writer of my choice, and while parsing the primary keys, I
> could transform them and write them out.
>
> I haven't found anything, how this could be done, with the default
> functionality of digester.
> Any ideas, how I could extend digester to achieve this?
>
> thanks
>
> Benjamin
>

Digester will not be able to round-trip (with modifications) your XML 
document on it's own because it does not have XML serialisation functionality.

If you can create a network of JavaBeans then I believe you could serialise 
to XML using betwixt:

   http://jakarta.apache.org/commons/betwixt/

Alternatively you could build a DOM representation using this Digester rule:

http://cvs.apache.org/viewcvs/jakarta-commons/digester/src/java/org/apache/commons/digester/NodeCreateRule.java?rev=1.1&content-type=text/vnd.viewcvs-markup

and then serialise the DOM using Xerces.

If you have a very large document you could consider a SAX pipeline, i.e. 
don't build an object network in memory at all. In the middle of the pipeline 
apply the attribute transformation.

Just some ideas!
Janek

--
To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-user-help@;jakarta.apache.org>

Reply via email to