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

Re: separating elements/attributes

Subject: Re: separating elements/attributes
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 22 Aug 2001 09:54:51 +0100
separating elements
Hi Samina,

> Now for all the "unused" elements/attributes, I want
> to do something like this in my stylesheet:
>
> <moreover:tagline><xsl:value-of
>       select="tagline"/></moreover:tagline>
> <moreover:access_reg><xsl:value-of 
>       select="access_reg"/></moreover:access_reg>
> <moreover:access_status><xsl:value-of
>       select="access_status"/></moreover:access_status>

Sure. Make a template that matches all these elements:

<xsl:template match="*">
  ...
</xsl:template>

You want to decide the name of the new element on the fly, so you have
to use xsl:element to create it. The value of the new element is the
same as the value of the element you're matching, so you just want the
value to be the value of the current node:

<xsl:template match="*">
  <xsl:element name="...">
    <xsl:value-of select="." />
  </xsl:element>
</xsl:template>

The (local) name of the new element is the same as the (local) name of
the element. But you want it to be in the moreover namespace. You can
use an attribute value template in the name attribute of the
xsl:element instruction to determine the name of the element
dynamically. Assuming that you've declared the moreover namespace with
the prefix 'moreover' in the stylesheet, you can use:

<xsl:template match="*">
  <xsl:element name="moreover:{local-name()}">
    <xsl:value-of select="." />
  </xsl:element>
</xsl:template>

Otherwise (or as well, if you like), you can declare the namespace
explicitly in the namespace attribute of xsl:element:

<xsl:template match="*">
  <xsl:element name="moreover:{local-name()}"
               namespace="http://www.moreover.com/">
    <xsl:value-of select="." />
  </xsl:element>
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.