Help with lexical events and a TransformerHandler

C

Collin VanDyck

Hello!

I have set up a pluggable SAX transformation pipeline which is made up
of individual nodes that transform the source XML, and for the most part
it works well. Each node in the pipeline is assigned a ContentHandler
and a LexicalHandler by the transformation framework.

Each node in the pipeline may either be:

* a class that implements ContentHandler and LexicalHandler
* a wrapper class that creates a TransformerHandler from an XSL
stylesheet and handles the SAX events.

The first case works perfectly. Both normal and lexical SAX events are
processed and then reported to the following nodes in the pipeline.

I'm having trouble with the second case; specifically lexical events
such as comments are not being passed to the next node.

Each node defines a setOutputHandlers() (below) that sets the handlers
for events generated by that node. For the xslt wrapper, I simply
create a SAXResult using both the ContentHandler and the LexicalHandler
and then proceed to create the TransformerHandler member that will
receive SAX events from the previous node.

Is there something I am doing wrong here that would prevent my xsl
stylesheet from passing the lexical events to the next node? I have
already verified that the transformation correctly passes through
comments in XMLSpy and that my framework is correctly invoking
transformerHandler.comment() when a comment event fires on a previous node.

Thanks for any help, thoughts, or suggestions.

Collin

--------------------------



public void setOutputHandlers(ContentHandler content, LexicalHandler
lexical) throws SAXException
{
super.setOutputHandlers(content, lexical);
this.result = new SAXResult();
this.result.setHandler(content);
this.result.setLexicalHandler(lexical);

try
{
final String xslt = fetchXSLTAsString();
final SAXSource xsltSource = new SAXSource(new
InputSource(new BufferedReader(new StringReader(xslt))));
final SAXTransformerFactory factory =
(SAXTransformerFactory) TransformerFactory.newInstance();
this.transformerHandler =
factory.newTransformerHandler(xsltSource);
this.transformerHandler.setResult(this.result);
}
catch (Exception e)
{
throw new SAXException(e);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top