Multiple executions of transformation having DOM Document as parameter is not 
working
-------------------------------------------------------------------------------------

         Key: XALANJ-2067
         URL: http://issues.apache.org/jira/browse/XALANJ-2067
     Project: XalanJ2
        Type: Bug
  Components: Xalan  
    Versions: 2.6    
 Environment: Windows XP - jdk 1.4.1
    Reporter: Alain Grandjean


Create a Transformer, set a DOM Document as parameter to the Transformer and 
apply 2 times the Transformer. The second time, the parameter is no longer 
containing the DOM Document.

Sample class Test.java:

package testxalan;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.StringReader;

import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.Source;

import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Test {

  static Transformer newTransormer(String name) throws Exception
  {
    TransformerFactory  factory = TransformerFactory.newInstance();
    return factory.newTransformer(new StreamSource(new FileInputStream(name)));
  }

  static Document newDocument() throws Exception
  {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(false);

    Document doc = factory.newDocumentBuilder().newDocument();
    return doc;
  }

  public static void main(String[] args) {

    try {
      Transformer transformer = newTransormer("hello.xsl");

      Document doc = newDocument();
      Element root = doc.createElement("root");
      root.appendChild(doc.createTextNode("Hello World"));
      doc.appendChild(root);

      transformer.setParameter("data", doc);

      transformer.transform(new StreamSource(new StringReader("<node/>")), new 
StreamResult(new FileOutputStream("sample1.txt")));
      transformer.transform(new StreamSource(new StringReader("<node/>")), new 
StreamResult(new FileOutputStream("sample2.txt")));

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}


with Sample hello.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:param name="data" select="/.."/>

<xsl:template match="node">
  <xsl:value-of select="$data/root"/>
</xsl:template>

</xsl:stylesheet>






-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to