xsl-list
[Top] [All Lists]

RE: Applying XSLT to SAX Reader

2002-10-07 17:18:10

I am having a problem trying to transform output from a SAX 
reader.  Looking at the XALAN FAQ, I believe the way I am
supposed to do this is to use a "pipe", or "chain" method.

It depends on your approach.  Personally, I don't like the JAXP method for 
obtaining an XMLFilter because it precludes the setting of parameters on the 
Transformer.  (The right way to do that, btw, IMHO, would be to map SAX 
properties of the form http://java.sun.com/jaxp-1.1/[qname] to the Transformer 
properties, but I digress...)

Another way to hand an XMLReader (or XMLFilter) to an XSLT processor using TrAX 
is to wrap it up in a SAXSource:

        // Foo implements XMLReader
        XMLReader xr = new Foo();
        InputSource is = new InputSource(blahblah);
        SAXSource sxs = new SAXSource(xr,is);

(Get a new Transformer here...)

Since it appears that you want serialized output, I'd suggest just using a 
StreamResult instead of a serializer:

        StreamResult str = new StreamResult(System.out);
        t.transform(sxs,str);

As for your specific code, I don't see anything obviously wrong.  (Maybe I'm 
missing the obvious...)  Does your XMLFilter implementation pass-on namespace 
and other SAX property settings to the driving XMLReader?  (Xalan can be a 
little picky about which way it receives namespace events.)

        -- Paul

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>