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

is this really tough?

Subject: is this really tough?
From: Sundar Shanmugasundaram <SSHANMUGASUNDARAM@xxxxxxxxxxxxx>
Date: Wed, 30 Apr 2003 15:03:48 +0530
 is this really tough?
I would like to sort the following XML file based on the displayposition.
I am printing the value and displayname. 

Here is the XML File I have used:

<?xml version="1.0"?>
<o>
	<com>
		<hereyougo>
			<first displayposition="4"
displayname="raman4">4</first>
			<second displayposition="1"
displayname="raman1">1</second>
			<third displayposition="3"
displayname="raman3">3</third>		
			<fourth displayposition="2"
displayname="raman2">2</fourth>
		</hereyougo>
		<imaycome>
			<four displayposition="4"
displayname="raman4">22</four>
			<five displayposition="1"
displayname="raman1">33</five>
			<six displayposition="3"
displayname="raman3">44</six>			
			<firvi displayposition="2"
displayname="raman2">11</firvi>			
		</imaycome>
	</com>
</o>

This is the output I expect:

raman1 1 33
raman2 2 11
raman3 3 44
raman4 4 22

The o/p I am getting:

raman1 4 22 
raman2 1 33 
raman3 3 44 
raman4 2 11 

The XSL File I used  to process This :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes" /> 	
  <xsl:template match="/">
 <table>
 <xsl:variable name="y" select="o/com/*" />
     <xsl:for-each select="$y[1]/*">
     	<xsl:sort select="@displayposition"/>
      <xsl:variable name="x" select="position()" />
      <tr>
      <th>
      	<xsl:value-of select="@displayname"/>
      </th>
        <xsl:for-each select="$y/*[position() = $x]">
        	<xsl:sort select="@displayposition"/>
          <td>
            <xsl:value-of select="." />
          </td>
        </xsl:for-each>
      </tr>
    </xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

Possible Error:

<xsl:sort select="@displayposition"/> in the second <xsl:for-each > is not
working.

Pls help me out.

thanks and regards,
sundar

 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.