Re: [xsl] a very unusual namespace question

Subject: Re: [xsl] a very unusual namespace question
From: Steve Tinney <stinney@xxxxxxxxxxxxx>
Date: Thu, 17 May 2001 21:06:45 -0400
Something like this, maybe?

A.xsl:
====

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

<xsl:param name="ns" select="'anyns'"/>
<xsl:param name="ns-uri" select="'http://www.whatever.uri'"/>

<xsl:output method="xml"/>

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

<xsl:template match="/">
  <xsl:text disable-output-escaping="yes">
&lt;!DOCTYPE axsl:stylesheet [
&lt;!ATTLIST axsl:stylesheet xmlns:</xsl:text>
<xsl:value-of select="$ns"/>
<xsl:text> CDATA #FIXED "</xsl:text>
<xsl:value-of select="$ns-uri"/>
<xsl:text>"&#xa;</xsl:text>
<xsl:text>xmlns</xsl:text>
<xsl:text> CDATA #FIXED "</xsl:text>
<xsl:value-of select="$ns-uri"/>
<xsl:text>"</xsl:text>
<xsl:text disable-output-escaping="yes">
>]>
</xsl:text>
<axsl:stylesheet version="1.0">
  <axsl:template match="{$ns}:*">
    <axsl:element name="{$ns}:node"/>
  </axsl:template>
</axsl:stylesheet>
</xsl:template>

</xsl:stylesheet>

===============================================

With Saxon 6.3 (YMMV with other processors in terms of escaping
and line-breaking) this generates (reformatted for aesthetic purposes
only):

B.xsl:
====

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE axsl:stylesheet [
<!ATTLIST axsl:stylesheet
   xmlns:anyns CDATA #FIXED "http://www.whatever.uri";
   xmlns CDATA #FIXED "http://www.whatever.uri";
>]>
<axsl:stylesheet 
  xmlns:axsl="http://www.w3.org/1999/XSL/Transform"; 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
  version="1.0">
<axsl:template match="anyns:*">
  <axsl:element name="anyns:node"/>
</axsl:template>
</axsl:stylesheet>

================================================

If you feed B.xsl this 

test.xml:
======

<anyns:rootNode xmlns:anyns="http://www.whatever.uri"/>

You get back

out.xml:
======

<?xml version="1.0" encoding="utf-8"?>
<anyns:node xmlns:anyns="http://www.whatever.uri"/>

=======

 Steve

On Thursday 17 May 2001 07:56 pm, you wrote:
> I have a stylesheet A that is outputting stylesheet B (using
> xsl:namespace-alias'ing).  Stylesheet B will be matching elements from
> namespace N so it must have a namespace declaration for N.  But the problem
> is that namespace N is not known at the time I construct A and does not
> appear in the input to A.  I would like to pass the prefix and URI for N to
> stylesheet A as top-level parameters.  How can I get stylesheet A to
> generate a namespace declaration in B from the parameters?  Thanks!
>
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

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


Current Thread