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

Re: Mapping Values.

Subject: Re: Mapping Values.
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Wed, 15 Mar 2006 15:09:23 +0530
mapping values
Hi Amal,
   Please try this stylesheet. It uses identity template along with
templates for other rules.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" indent="yes" />

<xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*" />
    </xsl:copy>
</xsl:template>

<xsl:template match="@*[. = 'abcd']">
    <xsl:attribute name="{name()}">1</xsl:attribute>
</xsl:template>

<xsl:template match="@*[(. = 'xxxx') or (. = 'yyyy')]">
    <xsl:attribute name="{name()}">2</xsl:attribute>
</xsl:template>

<xsl:template match="@*[. = 'aaaa']">
    <xsl:attribute name="{name()}">3</xsl:attribute>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

On 3/14/06, Amal <raj.amal@xxxxxxxxx> wrote:
> I have an xml of the form
>
> <root>
> <bldg loc=3D3D3D"abcd" subloc=3D3D3D"abcd" />
> <bldg loc=3D3D3D"xxxx" subloc=3D3D3D"yyyy" />
> <bldg loc=3D3D3D"aaaa" subloc=3D3D3D"aaaa" />
>
> <addr bldgloc=3D3D3D"aaaa" bldgsubloc=3D3D3D"aaaa" />
> <addr bldgloc=3D3D3D"xxxx" bldgsubloc=3D3D3D"yyyy" />
>
>  </root>
>
> I have to convert it to
> <root>
> <bldg loc=3D3D3D"1" subloc=3D3D3D"1" />
> <bldg loc=3D3D3D"2" subloc=3D3D3D"2" />
> <bldg loc=3D3D3D"3" subloc=3D3D3D"3" />
>
> <addr bldgloc=3D3D3D"3" bldgsubloc=3D3D3D"3" />
> <addr bldgloc=3D3D3D"2" bldgsubloc=3D3D3D"2" />
>
> </root>
>
> So for this purpose I want to map some strings to some values that can be
> used later. Like when I map bldg block in input to bldg block in output I
> want to map the attributes to a number and then use the same when mapping
> addr tags.
> How shud I go about doing it ?
>
>
> Amal.

Current Thread
  • Mapping Values.
    • Amal - 14 Mar 2006 11:03:37 -0000
      • Mukul Gandhi - 15 Mar 2006 09:39:44 -0000 <=
        • Amal - 15 Mar 2006 09:41:35 -0000
      • <Possible follow-ups>
      • Amal - 14 Mar 2006 12:33:25 -0000

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.