Java XSLT Tranformer: DOMSource vs. StreamSource problem

Discussion in 'XML' started by Dominique Bejean, Dec 22, 2003.

  1. Hello,

    I am having a problem doing an XSLT transformation using Java.

    I have a XML document as a DOM Document object, wrap the Document
    object with a DOMSource object, and do the transformation. However,
    the transformation does not work. None of the templates in the XSLT
    source are Matched, except for the root template.
    The code is as follows:

    TransformerFactory tFactory =
    TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(new
    StreamSource(XslFileName));

    transformer.setOutputProperty(OutputKeys.ENCODING,
    "UTF-8");
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.METHOD, "html");

    transformer.transform(new DOMSource(m_Root), new
    StreamResult(out));


    I discovered that if I transform the DOM Document object back into
    text and wrap the text in a StreamSource, then the transformation
    works fine. It does not make sense that the StreamSource approach
    works and the DOMSource approach does not.

    I use JDK 1.4.2, Xerces 2.5.0 and Xalan 2.5.2

    Can anybody explain what the problem may be?

    Thank you for your help.

    Dominique Bejean
     
    Dominique Bejean, Dec 22, 2003
    #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. Dominique Bejean
    Replies:
    0
    Views:
    831
    Dominique Bejean
    Dec 22, 2003
  2. Stylus Studio
    Replies:
    0
    Views:
    765
    Stylus Studio
    Aug 3, 2004
  3. ted
    Replies:
    1
    Views:
    651
    Laurens
    Jan 26, 2004
  4. Simon Brooke
    Replies:
    2
    Views:
    614
    Simon Brooke
    Mar 15, 2007
  5. jwasp
    Replies:
    0
    Views:
    1,148
    jwasp
    May 8, 2009
Loading...

Share This Page