DOM with XSL

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 UTC