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

RE: Adding namespace nodes question

Subject: RE: Adding namespace nodes question
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 17 Dec 2001 14:34:53 -0000
RE:  Adding namespace nodes question
> Suppose I have this XML:
>
> <elem name="myElem">
>  <ns type="own" prefix="">http://www.domain1.org/ns</ns>
>  <ns type="extra" prefix="pre2">http://www.domain2.org/ns</ns>
>  <ns type="extra" prefix="pre3">http://www.domain3.org/ns</ns>
> </elem>
>
> Which actually represents the this XML:
>
> <myElem xmlns="http://www.domain1.org/ns"
>  xmlns:pre2="http://www.domain2.org/ns"
>  xmlns:pre3="http://www.domain3.org/ns" />
>
> What is the most efficient method to add these namespaces to
> the element
> in the result tree?

AFAIK the only way to add a namespace node to the result tree, when the
namespace isn't present in either the source document or the stylesheet, is
to create an element on a temporary tree that uses that namespace, and then
use xsl:copy[-of] to copy the namespace node from the temporary tree to the
result tree. Even this relies on (a) the errata to XSLT 1.0, and (b) the
xx:node-set() extension.

<xsl:variable name="temp">
  <xsl:element name="{$prefix}.temp" namespace="{.}"/>
</xsl:variable>

<xsl:copy-of select="xx:node-set()/*/namespace::*"/>

Mike Kay


 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.