Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4408859

TransformerFactory.newTransformer(DOMSource) method always throws Exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.1
    • 1.1
    • xml
    • 1.1fcs
    • sparc
    • solaris_2.6
    • Verified

      import javax.xml.parsers.*;
      import javax.xml.transform.*;
      import javax.xml.transform.dom.*;
      import java.io.*;
      import org.w3c.dom.*;

      public class T2 {

          public static void main(String str[]) throws Exception {
              TransformerFactory tf = TransformerFactory.newInstance();
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              DocumentBuilder db = dbf.newDocumentBuilder();
              Document document = db.parse(new File("cities.xsl"));
              DOMSource ds = new DOMSource((Node)document);
              Transformer t = tf.newTransformer(ds);
          }
      }
      The above program produces the problem. xsl file is attached.
      The error thrown is as mentioned below:
      javax.xml.transform.TransformerException: "xmlns:xsl" attribute is not allowed on the xsl:stylesheet element!
              at org.apache.xalan.processor.StylesheetHandler.error(StylesheetHandler.java:843)
              at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:342)
              at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:300)
              at org.apache.xalan.processor.ProcessorStylesheetElement.startElement(ProcessorStylesheetElement.java:137)
              at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:626)
              at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java:284)
              at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java:119)
              at org.apache.xalan.processor.TransformerFactoryImpl.processFromNode(TransformerFactoryImpl.java:207)
              at org.apache.xalan.processor.TransformerFactoryImpl.processFromNode(TransformerFactoryImpl.java:266)
              at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:734)
              at org.apache.xalan.processor.TransformerFactoryImpl.newXMLFilter(TransformerFactoryImpl.java:485)
              at SAXTFactoryTest011.main(SAXTFactoryTest011.java:44)

            duke J. Duke
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: