Re: exclude-result-prefixes Editors please note:

Subject: Re: exclude-result-prefixes Editors please note:
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 8 Mar 2000 13:38:20 GMT
> ? What do you mean 'use'? please.
>As in 
>  <xsl:copy>
>    something with a ns prefix
>   </xsl:copy>

>I.e. If I add something to the output tree that uses namespaces,
>then it should put xmlns:xxx declarations on the output?
>Concerned that the spec is clear here.

When an element (or attribute) node is copied from the stylesheet to the
output either using copy-of or copy or a literal result element
then all the namespace nodes associated with that element go with it.

That is all xmlns and xmlns: declarations from any ancestor of the
current element in the stylesheet.

So if I have a stylesheet transforming say xhtml to some other DTD

I need to have something like 

<xsl:stylesheet xmlns:xsl="";

I need the xmlns:h so that I can have

<xsl:template match="h:a[@name]">

etc to match on namespaced elements in the source.

But that means that namespace declaration is in scope for the entire
stylesheet and so in particular it is in scope on every literal result
<xsl:template match="h:a[@name]">
  <anchor id="{@name}"/>

would produce

<anchor id="xxx" xmlns:h=""/>

in the output or maybe not but xmlns:h="
would appear on _some_ ancestor of this anchor element in the output,
becaue it is on some ancestor of anchor in the stylesheet.

This probably is not what you want so you can tell the system that some
namespaces are just for use within the stylesheet, or for querying the
input document. the XSL namespace automaticaly has that status, to add
others you use exclude-result-prefixes="h"

then since the anchor element isn't in the xhtml namespace, and neither
are any of its attributes or children, the
does not appear in the output, which is a good thing if you want to
validate the output against (in this case) the docbook dtd.


 XSL-List info and archive:

Current Thread