On Tue, 12 Nov 2002, Benjamin Reitzammer wrote: > Date: Tue, 12 Nov 2002 16:34:10 +0100 > From: Benjamin Reitzammer <[EMAIL PROTECTED]> > Reply-To: Jakarta Commons Users List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: [digester] > > 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?
This sounds like something you could deal with in a custom Rule implementation (i.e. "implements org.apache.commons.digester.Rule"). When your Rule (like any Rule) is matched, the begin() method is called -- and the set of attributes for the currently matched element are passed. If you already have JavaBeans corresponding to your elements, one strategy would be to base your custom implementation on the code in the standard SetPropertiesRule, and simply add the code to modify the id values before populating the bean properties. > > thanks > > Benjamin > Craig -- To unsubscribe, e-mail: <mailto:commons-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-user-help@;jakarta.apache.org>
