xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Welch" <AWe...@piper-group.com>
Subject RE: Custom SAX Parser
Date Tue, 13 May 2003 13:15:48 GMT

> This code "generates" the XML that worked with the first example.
> However, when I try this, the output from Xalan doesn't have anything
> from my generated SAX/XML.
> Can anyone point me in the right direction ?

I was doing this only the other day...

The solution I arrived at was to implement an XMLFilter that generated the false events from
within the parse(String) method.  The content handler will receive the fake events as if it
had parsed a file, with the whole process kicked off by calling parse("dummy") on the Filter.
 A cut down looks like this:

public class Whatever implements XMLReader {
    private ContentHandler m_contentHandler = null;
    ...implement all of the interface methods here....

    public void parse(String s) {
       m_contentHandler.startElement("", "Foo", "Foo", new AttributesImpl());
       m_contentHandler.endElement("", "Foo", "Foo");

This will give you a 'fake' xml document of exactly 



Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.478 / Virus Database: 275 - Release Date: 06/05/2003

View raw message