Lists Home |
Date Index |
David Megginson wrote:
>Miguel A. Robles writes:
> > Many thanks for your help. Now, I know I can manage large XML files
> > with SAX and it works fine. The problem now exists when I need to
> > update the content of an element or any of its attributes. I'm not
> > sure, but I think that SAX cannot be used for that purpose.
>SAX per se is just a common interface, and cannot do anything.
>However, there are SAX clients (like my own XML-Writer and probably
>many better ones) that take SAX events and generate XML markup from
>them. So if you take a SAX parser and register a SAX writer as its
>client, you have an XML identity transformation with only a few lines
>Now, create your own filter to sit between the parser and the writer.
>All your filter has to do is intercept the events it wants to change
>and generate new ones to replace them. That may be an easy or
>difficult task, depending on the scope of the changes (i.e. renaming
>or splitting a few elements is easy, restructuring a large subtree
You can avoid programming of callbacks by using STX, a SAX-based
transformation language. The rules to update your data can be then
given in a form of XSLT-like templates. There are implementations in
Java and Perl available [http://stx.sourceforge.net/].