Hi and thanks, I have a filter setup. But, I was not specific, but I was hoping to do this without using the DOM. I was hoping to run a XNI parse and then at some point insert something in the source.
Is there anyway to do this? Or can you add only with the DOM? Thanks, -Rob > -----Original Message----- > From: Elena Litani [mailto:[EMAIL PROTECTED] > Sent: Monday, August 18, 2003 2:36 PM > To: [EMAIL PROTECTED] > > Hi Robert, > > You need to add a new filter component to your parser pipeline. Your > filter must implement xni.parser.XMLDocumentFilter interface, and should > be responsible for adding a new element by calling an extra startElement > method. > > You need also create your own configuration that will include this new > filter component. Just extend one of the existing configurations, i.e. > org.apache.xerces.parsers.DTDConfiguration or > IntegratedParserConfiguration (if you are worried about XML Schema > validation) and overwrite configurePipeline() method. For example, if > you want your filter to be the last component in the pipeline your code > for configurePipeline() should look as follows: > > super.configurePipeline(); > fLastComponent.setDocumentHandler(fMyFilter); > if (fDocumentHandler != null) { > fDocumentHandler.setDocumentSource(fMyFilter); > } > fLastComponent = fMyFilter; > > Then, create a parser, i.e. org.apache.xerces.parsers.DOMParser, passing > in the constructor this new configuration you want to use. > > Read more about XNI pipelines here: > http://xml.apache.org/xerces2-j/xni-config.html > > Also you can look at existing filter components and their > implementation: org.apache.xerces.impl.XMLNamespaceBinder, > org.apache.xerces.impl.dtd.XMLDTDValidator, etc. > > Hope it helps, > -- > Elena Litani / IBM Toronto > > Robert Koberg wrote: > > > > Hi, > > > > I have XML that looks like: > > > > <list> > > <item/> > > <item/> > > </list> > > > > I want to use XNI to insert an 'item element' when the 'endElement' > event is > > triggered for the closing 'list element.' > > > > So far, I have tried extending the XNIPassThroughFilter. I would think > that > > I could call a super.startElement passing it the appropriate objects. > But > > since it is not readily available, I was wondering if there was a > different > > way. Should I just an insert a character buffer (or something similar) > into > > the XmlInputSource? If so, how? > > > > Is there a simple way to add an element during a XNI parse/filter? > > > > Thanks for any hints or pointers, > > -Rob > -- > Elena Litani / IBM Toronto > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]