This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: problem generating dynamic namespace declarations



With saxon, I think that generating a namespace node in the result
based on a variable value you need to do something like


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0"
                xmlns:saxon="http://icl.com/saxon"
                   extension-element-prefixes="saxon"
                >

<xsl:output method="xml" indent="yes"/>

<xsl:param name="p" select="'foo'"/>
<xsl:param name="n" select="'http://x/y/z'"/>

<xsl:template match="/">
<xsl:variable name="x">
 <xsl:element name="{$p}:x" namespace="{$n}"/>
</xsl:variable>
<xxx path="{$p}:that">
  <xsl:for-each select="saxon:node-set($x)/*/namespace::*[name()=$p]">
  <xsl:copy/>
  </xsl:for-each>
<!--
  <xsl:copy-of select="saxon:node-set($x)/*/namespace::*"/>
-->
</xxx>
</xsl:template>

</xsl:stylesheet>


applying this to anything (eg itself) gives you

<?xml version="1.0" encoding="utf-8" ?>
<xxx xmlns:foo="http://x/y/z" path="foo:that"/>

But this relies on some grey areas in the spec about copying namespace
nodes, (which saxon, as Mike pointed out on this list some time back,
interprets slightly differently for copy and copy-of.)

David


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]