You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Marcus Kalthoff <ma...@web.de> on 2002/06/28 16:55:12 UTC

transformation xsl problems, TransformerException: stylesheet requires attribute: version

I'm trying to do a transformation with a DOMSouce that is manually build 
and always get an exception. What am I doing wrong?
I use this code:
//creating the xsl-document
org.w3c.dom.Document doc = null;
javax.xml.parsers.DocumentBuilderFactory dbf =
    javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder dBuilder =
    dbf.newDocumentBuilder();
doc = dBuilder.newDocument();
org.w3c.dom.Element root = d.createElementNS("xsl", "stylesheet");
doc.appendChild(root);
root.setAttributeNS("xmlns", "xsl",
                          "http://www.w3.org/1999/XSL/Transform");
root.setAttribute("version", "1.0");

...generating the rest of the doc...

javax.xml.transform.Source style = new 
javax.xml.transform.dom.DOMSource(doc) ;

javax.xml.transform.TransformerFactory tFactory =
            javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = 
tFactory.newTransformer(style); // here the exception is thrown







 >List:     xalan-j-users
 >Subject:  RE: transformation xsl probelms
 >From:     "Gary L Peskin" <ga...@firstech.com>
 >Date:     2001-12-15 4:16:52
 >[Download message RAW]

 >When building the Nodes xmlSourceDoc and xslSourceDoc, be sure that
 >you've turned on namespace awareness in the parser.  If you're building
 >these Nodes manually, be sure you use the namespace-aware DOM L2 calls.

 >Gary