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

RE: Element name Change for a node

Subject: RE: Element name Change for a node
From: cknell@xxxxxxxxxx
Date: Wed, 13 Sep 2006 22:15:50 -0400
set node value
<xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>
<xsl:template match="address">
  <address>
    <xsl:apply-templates select="child::*[1]" />
  </address>
</xsl:template>

<xsl:template match="*[not(local-name() = 'address')][parent::*[local-name() = 'address']]">
  <xsl:variable name="elmnt-name">US_<xsl:value-of select="local-name()" /></xsl:variable>
  <xsl:element name="{$elmnt-name}">
    <xsl:value-of select="." />
  </xsl:element>
  <xsl:apply-templates select="following-sibling::*[1]" />
</xsl:template>
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Senthilkumaravelan Krishnanatham <senthil@xxxxxxxxx>
Sent:     Wed, 13 Sep 2006 18:00:01 -0700
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:   Element  name Change for a node


Hi All,

I have the following structure in my XML and I want to transform this  
all "address" node content to prefix with "US".
Please let me how to create the XSL template for the given input.

Input
   <address>
    <streetAddress>123 First Street</streetAddress>
      <city>Sometown</city>
      <state>CA</state>
      <zip>12345</zip>
      <province />
      <country>USA</country>
   </address>

output
   <address>
    <US_streetAddress>123 First Street</US_streetAddress>
      <US_city>Sometown</US_city>
      <US_state>CA<US_/state>
      <US_zip>12345</US_zip>
      <US_province />
      <US_country>USA</US_country>
   </address>

I do not know how to create the XSL for it to transform.

Thanks for your help.


Regards,
Senthil

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.