Re: [xslt] exclude-result-prefixes question



On Fri, Jun 01, 2001 at 05:06:42PM -0700, Sze, Tak F wrote:
> I am trying to figure out when one needs to use exclude-result-prefixes.
> According to the example in Michael Kay's XSLT Programmer's Reference,
> the following stylesheet should create unneeded namespace declaration,
> and thus require the use of exclude-result-prefixes to remove the 
> unneeded namespace declaration.
> 
>    <xsl:stylesheet version="1.0"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>         xmlns:var="http://another.org/xslt"
>    />
>    <xsl:variable name="var:x" select="17"/>
>    <xsl:template match="/">
>       <acme:document xmlns:acme="http://acme.com/xslt">
>         <acme:chapter>
>            Once upon a time ...
>         </acme:chapter>
>       </acme:document>
>    </xsl:template>
>    </xsl:stylesheet>
> 
> This should create the following output document:
> 
>    <acme:document xmlns:acme="http://acme.com/xslt"
>                   xmlns:var="http://another.org/xslt">
>      <acme:chapter>
>          Once Upon a time ...
>      </acme:chapter>
>    </acme:document>
> 
> 
> It seems that libxslt does not output the namespace declaration for "var".

   Right,

> Is it because libxslt intelligent enough to eliminate unnecessary namespace 
> prefix declaration automatically so that one does not need to use 
> exclude-result-prefixes? 

   Basically, yes. When adding a node or an attibute in the output tree,
libxslt adds the namespace declaration if there isn't one already in scope.

> If not, under what circumstances would one 
> have unneeded namespace declarations?

   Seems some copy operations actually generate uneeded namespaces declarations
depending on the XSLT construct used. Maybe I should chase them, or
alternatively implement "exclude-result-prefixes" since it's not currently :-)

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]