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

Extracting element name and value as separate

Subject: Extracting element name and value as separate
From: "Thangavelu Srinivasan" <vasantry@xxxxxxxxx>
Date: Fri, 16 Feb 2007 17:49:57 +0530
 Extracting element name and value as separate
Hi Folks

I am using xslt 1.0. I am facing the problem in extracting the element
name and value separately. Any suggestions are welcome

Sample XML:

<state_results state_name="Atlantic Canada" state_id="AC">
- <game_results game_name="Lotto 6/49" game_id="201">
- <date>
 <abbr_date>02/03/07</abbr_date>
 <full_date>02/03/2007</full_date>
 </date>
 <number_str>10-13-24-27-37-39, Bonus: 14</number_str>
- <numbers>
 <number>10</number>
 <number>13</number>
 </numbers>
- <bonus>
 <bonus_name>Bonus</bonus_name>
 <bonus_number>14</bonus_number>
 </bonus>
- <next_date>
 <next_abbr_date>02/07/07</next_abbr_date>
 <next_full_date>02/07/2007</next_full_date>
 </next_date>
 </game_results>
 <requested_action>ADD</requested_action>
 </state_results>

My XSL:
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="state_results">
<xsl:for-each select="@*">
<Name><xsl:value-of select="name()"/></Name>
<Value><xsl:value-of select="."/></Value>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Required Output :

<Name>state_name</Name>
<Value>Atlantic Canada</Value>
<Name>state_id</Name>
<Value>AC</Value>
<Name>game_name</Name>
<Value>Lotto 6/49</Value>
<Name>game_id</Name>
<Value>201</Value>
<Name>abbr_date</Name>
<Value>02/03/07</Value>
<Name>full_date</Name>
<Value>02/03/2007</Value>
<Name>number_str</Name>
<Value>10-13-24-27-37-39, Bonus: 14</Value>
<Name>next_abbr_date</Name>
<Value>02/07/07</Value>

I am not able to get desired output.

Regards
Srinivas

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.