Etienne --

The DOM is explained in the W3C DOM Recommendation.  Xerces, used by
Xalan, implements most or all of Level 2, the Core of which you can find
here:  http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html

Your attributes don't need to be in a namespace, just the element.  The
terms that you've asked about are all defined in the DOM Spec.

I think you'll want something like:

   Element xslRoot = (Element)
stylesheet.createElementNS("http://www.w3.org/1999/XSL/Transform";,
"xsl:stylesheet");
  xslRoot.setAttributeNS(null, "version", "1.0");
  stylesheet.appendChild( xslRoot );

If you're not familiar with namespaces, namespace URIs and namespace
prefixes, you might want to read up on this.

Gary  

Etienne Deleflie wrote:
> 
> Gary,
> 
> There is something about namespaces I have missunderstood,  and the documentation
> for doing this stuff (in java) is practically non-existent (or very well hidden).
> Forgive me for my ignorance, but, syntactically, what is the :
> 
> namespaceURI
> qualifiedName
> value
> 
> required for setAttributeNS ?
> 
> This code produces the right XML file (when printed out)..........
> 
>   Element xslRoot = (Element) stylesheet.createElementNS("test", "xsl:stylesheet");
>   xslRoot.setAttributeNS( "test", "version", "1.0");
>   xslRoot.setAttributeNS( "test", "xmlns:xsl",
> "http://www.w3.org/1999/XSL/Transform"; );
>   stylesheet.appendChild( xslRoot );
> 
> but still gives me an "attibute: version" is missing error.
> 
> etienne.
> 
> > Etienne --
> >
> > This is not correct because you are not putting these elements into a
> > namespace.  You need to use createElementNS to create an element in the
> > namespace.
> >
> > Gary
> >
> > Etienne Deleflie wrote:
> > >
> > > Hi,
> > >
> > > more on this dynamic XSL DOM document creation. Perhaps I am not creating the
> > > DOM document correctly (even though it prints out correctly)
> > >
> > > ........... I am setting both the attributes of the root node (version and
> > > xmlns:xsl)
> > >
> > > <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> > >
> > > by doing the following
> > >
> > >   // make a root node for the xml Document
> > >   Element root = (Element) document.createElement("page");
> > >   document.appendChild(root);
> > >
> > >  // namespace and version
> > >   Element xslRoot = (Element) stylesheet.createElement("xsl:stylesheet");
> > >   xslRoot.setAttribute("version", "1.0");
> > >   xslRoot.setAttribute("xmlns:xsl", "http://www.w3.org/1999/XSL/Transform";);
> > >
> > > does this seem correct ?
> > >
> > > etienne

Reply via email to