[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: a very unusual namespace question

Subject: RE: a very unusual namespace question
From: "David Jeschke" <david.jeschke@xxxxxxxxx>
Date: Fri, 18 May 2001 00:51:50 -0700
david jeschke
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:  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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.