Re: [xsl] Partial Implementation of XInclude include element

Subject: Re: [xsl] Partial Implementation of XInclude include element
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 25 Sep 2002 23:27:59 +0100
Hi Eliot,

> Here's what I'm observing: when using Stylus Studio 4.5 beta (which
> enables Saxon as a debugging XSLT engine), if I use Saxon to do the
> transform, then Saxon copies all the namespace declarations from the
> xsl:stylesheet element to the root element of the output doucment.
> If I use the built-in XSLT engine, no copying.
>
> So: which behavior is more correct? Or have I inadvertantly turned
> on a convenience feature of Saxon?

It's hard to tell without seeing your stylesheet, but I would guess
that Saxon is doing the right thing (it usually does) and that you
have something like:

<xsl:template match="/*">
  <fo:root>
    ...
  </fo:root>
</xsl:template>

When you create an element using a literal result element (as above),
then the element you create has to have the same namespaces in scope
as the element in the stylesheet. The <fo:root> literal result element
has in scope all the namespaces that are declared on the
<xsl:stylesheet> element (as well as those on its parent
<xsl:template> element and itself), so the element in the result has
these namespaces as well.

If, on the other hand, you're doing:

<xsl:template match="/*">
  <xsl:copy>
    ...
  </xsl:copy>
</xsl:template>

(which is what I assumed, since you seemed to be doing an XInclude
pre-process) then you shouldn't get any namespaces from the
<xsl:stylesheet> element coming through into the result document.
That's because <xsl:copy> takes the element node from the *source*
document and copies it.

Also, if you're doing:

<xsl:template match="/*">
  <xsl:element name="fo:root">
    ...
  </xsl:element>
</xsl:template>

then you shouldn't get any namespace nodes from the <xsl:stylesheet>
element being copied through.

Oh, I should point out that no matter how you create the <fo:root>
element, it should have the correct XSL-FO namespace declaration for
the 'fo' prefix on it. Any processor that generates a result document
that isn't namespace-valid is definitely in error.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread