Problem with TransformerHandler and Lexical events

Discussion in 'XML' started by Collin VanDyck, Nov 30, 2004.

  1. 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

    p.s. I forgot to crosspost this from comp.lang.java.programmer -- Sorry
    for the duplicates :(

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



    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);
    }
    }
     
    Collin VanDyck, Nov 30, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Collin VanDyck
    Replies:
    0
    Views:
    326
    Collin VanDyck
    Nov 30, 2004
  2. Replies:
    18
    Views:
    496
    Bengt Richter
    Dec 17, 2005
  3. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    374
    Chris
    Aug 30, 2005
  4. PerlFAQ Server
    Replies:
    0
    Views:
    361
    PerlFAQ Server
    Jan 6, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    266
    PerlFAQ Server
    Apr 15, 2011
Loading...

Share This Page