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

7.1.5 Creating namespace declarations with xsl:namespace-dec

Subject: 7.1.5 Creating namespace declarations with xsl:namespace-declaration
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 21 Dec 1999 16:21:29 GMT
xsl namespace declaration
section 7.1.3 says that I can add an attribute to the current element in
the result tree like so 

<foo>
<xsl:attribute name="x">this</xsl:attribute>

or if I want to copy all the attributes from the current node

<foo>
<xsl:copy-of select="@*"/>

But there is nothing equivalent for namespace declarations.

I want to produce an element foo in the result tree that has (at least) 
the namespace declarations of the current node.

In the special case that the node in the result tree has the same qname
as the current node, I can use xsl:copy, but if not then I would like to
do

<foo>
<xsl:copy-of select="namespace::*"/>

The spec is distinctly unclear what is supposed to happen if you copy a
namespace node. xt doesn't support the namespace axis, and saxon does
as a query, but doesn't seem to copy namespace nodes to the output (and
It's not clear to me that it should, although that would be useful)


I finally managed to acheive what I want by

wrapping the body of my template in <xsl:copy> ...</xsl:copy>
which put all the result tree nodes in scope of the necessary namespace
declaration, and then had a second stylesheet that was an identity
transform except that it removed the unwanted copied elements (leaving
their contents) (XSLT then automatically shifts the namespace
declarations on to the remaining elements)

Is there a better way in xslt 1.0?

The context of this is an xpath aware input language with an input
node looking like

 <rule context="om:OMS">

with om: prefix being declared somewhere above.

I am transforming this to an xsl stylesheet so it ends up looking like


<axsl:template match="om:OMS">

so, I need to generate a namespace declaration in the result tree for
om: prefix even though there is no attribute or element in the openmath
namespace.

David


 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.