[xslt] exclude-result-prefixes question



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".
Is it because libxslt intelligent enough to eliminate unnecessary namespace 
prefix declaration automatically so that one does not need to use 
exclude-result-prefixes?  If not, under what circumstances would one 
have unneeded namespace declarations?

- Tak Sze





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