Altova Mailing List Archives


RE: [xsl] a very unusual namespace question

From: "David Jeschke" <david.jeschke@--------->
To:
Date: 5/17/2001 11:50:00 PM
Very clever!  You are textually outputting a DTD which declares the dynamic
namespaces as #FIXED attributes on the root stylesheet element.  The XML
spec states that XML parsers must assume #FIXED attributes are present even
if they are omitted.  Since there doesn't appear to be a way within XSLT to
get them into the tree model you just do an end-run around it with a DTD
hack.  Thanks.

So, can someone tell me definitively that this is impossible to do through
the 'tree model'?  My intention was to generate stylesheet B from A using
MSXML TransformNodeToObject so that B is never actually serialized to text
and reparsed but just exists as an XML DOMDocument object.  My experience
with TransformNodeToObject is it fails if the stylesheet output is not a
well-formed XML document, which your solution isn't because the 'DTD' text
is output before the root element.

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Steve Tinney
Sent: Thursday, May 17, 2001 6:07 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] a very unusual namespace question


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


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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.