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

RE: Namespaces II

Subject: RE: [xsl] Namespaces II
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Wed, 2 Jul 2003 13:37:55 +0100
RE:  Namespaces II
> that stops _other_ namespace nodes being copied but as I said in my
> forst reply, you don't want a copy at all as you need to change the name
> of the element from p in urn:DTD930 to p in no namespace.
> 
> So you need to have a template that matches the former and generates the
> latter.

Yes, it's good to be aware that node and namespace are not two separate things, they are forever joined and merely reference two different bits of a node's qName.

For example, if you have:

<my:test>

The real name (qName) of the node is the fully expanded name.  So if you have stated the 'my' prefix to be 'http://www.mydomain.com' the actual name of the node is:

<http://www.mydomain.com:test/>

*not* something like:

<test namespace="http://www.mydomain.com"/> 

You can use the namespace prefix to save your fingers, and to make the code readable, but ultimately it doesn’t separate the namespace from the node.  The namespace should unique, so its common to use url's, although you can use whatever you want.

So the thing to remember is: when you copy a node the namespace is an intrinsic part the node, and comes too.

If you want a node with the same name but in a different namespace, you have to create a new node using the local-name() of the original, give it a new namespace (if any), then copy through the contents of the original.  Something like:

  <xsl:element name="foo" namespace="someurl">
      <xsl:copy-of select="child::node()"/>
  </xsl:element>


cheers
andrew

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003
 

 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.