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


> Hello,
>
> thanks for your reply.
> I just tried setting name space awareness on the DocumentFactoryBuilder (i'm
> using JAXP)
> so now,
>
> myBuilder.isNamespaceAware() returns true.
>
> ........... but I am still getting the same error !
>
> etienne
>
> Gary L Peskin wrote:
>
> > I'm not sure how you're building myDomDocument but it sounds like you
> > may not have namespace support turned on in your DOM builder.  If that
> > is the case, please let me know so that I can include this as a FAQ
> > since it does come up from time to time.
> >
> > Gary
> >
> > Etienne Deleflie wrote:
> > >
> > > Hello,
> > >
> > > I am writing an XSL stylesheet on the fly, as a DOM document.
> > >
> > > Printed out, it looks like this ...........
> > >
> > > <?xml version="1.0" encoding="UTF-8" ?>
> > > <xsl:stylesheet version="1.0"
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> > >      <xsl:template match="/">
> > >           <xsl:call-template name="bob" />
> > >      </xsl:template>
> > >      <xsl:include href="gaga-html.xsl" />
> > > </xsl:stylesheet>
> > >
> > > Strange thing is, when I use Xalan thus .....
> > >
> > > transformer = factory.newTransformer( new DOMSource(   myDomDocument )
> > > );
> > >
> > > I get a Transform error: "stylesheet requires attribute: version" and
> > > stdout tells me
> > > file:////opt/Centauri/bin/javax.xml.transform.dom.DOMSource; Line 0;
> > > Column 0;
> > >
> > > So I have tried writing that stylesheet to disk and then passing it as a
> > > StreamSource instead ...
> > >
> > > transformer = factory.newTransformer( new
> > > StreamSource(myXslFileURLtoString()) );
> > >
> > > and this works!!! so my document seems to be correct.
> > > smells like a bug.
> > >
> > > am I missing something? does any one know either a workaround, or have a
> > > suggestion or ....
> > >
> > > etienne

Reply via email to