This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: a very unusual namespace question
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] a very unusual namespace question
- From: "David Jeschke" <david dot jeschke at pobox dot com>
- Date: Fri, 18 May 2001 00:51:50 -0700
- Reply-To: xsl-list at lists dot mulberrytech dot com
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@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Steve Tinney
Sent: Thursday, May 17, 2001 6:07 PM
To: xsl-list@lists.mulberrytech.com
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">
<!DOCTYPE axsl:stylesheet [
<!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>"
</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