W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2002

DOM with XSL

From: NESTOR ZORZANO COZAR <nestorz@fedro.ugr.es>
Date: Thu, 25 Apr 2002 12:43:43 +0200 (MET DST)
To: www-dom@w3.org
Message-ID: <1019731423.3cc7dddf8189a@fedro.ugr.es>
Hello, we are students in University of Granada (Spain), we are doing the final
proyect of degree, and we need to use the DOM Interface. Specifically, we are
interested in create DOM Documents from scratch, which represent a stylesheet
(an archive .xsl). We are tried to do this, by this way:

             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
             DocumentBuilder db = dbf.newDocumentBuilder ();
             Document xslDoc = db.newDocument ();

             Element root = xslDoc.createElement ("xsl:stylesheet");
             Attr version=xslDoc.createAttribute("version");
             version.setValue("1.0");
             Attr xmlns=xslDoc.createAttribute("xmlns:xsl");
             xmlns.setValue("http://www.w3.org/1999/XSL/Transform");
             root.setAttributeNode(version);
             root.setAttributeNode(xmlns);

             xslDoc.appendChild (root);

             Element template=xslDoc.createElement ("xsl:template");
             Attr match=xslDoc.createAttribute("match");
             match.setValue("raiz");
             template.setAttributeNode(match);

             root.appendChild (template);

The Document is created, but when we try to transform a XML Document with it by 
XALAN,
we have problems. It cause a java.xml.transform.TransformerException : 
"stylesheet
requires attribute version". Why?. Are we creating the DOM right?.

Also, we are tried to load a XSL Stylesheet empty from archive with this 
content:

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

and full it with the content of our stylesheet, but it not transform neither. We 
put the
<xsl:template> tag as a child of <xsl:stylesheet> tag using the method 
appendchild
applied on the Node loaded by xslDoc.getDocumentName(). When it is transformed 
it says
"xsl:template is not allowed in this position in the stylesheet!". Why?

What can we do?. Please help us!.
Received on Thursday, 25 April 2002 10:02:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:56 GMT