xsl-list
[Top] [All Lists]

Re: Re: Can one _generate_ namespace nodes?

2003-02-24 13:18:32

"Joseph Kesselman" <keshlam(_at_)us(_dot_)ibm(_dot_)com> wrote in message
news:OF61D39BC9(_dot_)77924166-ON85256CD7(_dot_)00611483-85256CD7(_dot_)0062E761(_at_)us(_dot_)ibm(_dot_)com(_dot_)(_dot_)(_dot_)
Yes, generating the <xsl:stylesheet> explicitly as <newxsl:stylesheet>
rather than using <xsl:copy> would result in newxsl: being declared at the
root.

But then any elements -- or XPaths -- copied from the source stylesheet
would have the reverse problem; they'd still be using the xsl: prefix and
would need to declare *that* prefix.

What about the following:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:newxsl="http://dymmy/Transform";


  <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <xsl:namespace-alias stylesheet-prefix="newxsl"
                       result-prefix="xsl"/>

  <xsl:template match="/">

    <newxsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
      <newxsl:text>foo</newxsl:text>
    </newxsl:stylesheet>

  </xsl:template>
</xsl:stylesheet>

The "newxsl" prefix will be bound to the XSLT namespace and the serializer
will generate the necessary namespace definition. In addition to this, a
definition of the XSLT namespace bound to the prefix "xsl" is also present
in the newxsl:stylesheet.

The result will be:

<newxsl:stylesheet xmlns:newxsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
   <newxsl:text>foo</newxsl:text>
</newxsl:stylesheet>

Therefore, any XPath expressions containing the "xsl" prefix will be
evaluated correctly. In the same way, any other necessary prefixes can be
specified on the newxsl:stylesheet element.

Is there an example, which is still problematic?




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL






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