C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Sort the Xml file using Xslt by passing argument


Posted Date: 30 Sep 2008      Total Responses: 1

Posted By: Tamilarasan       Member Level: Silver     Points: 1


Hi,

I want to sort the XML file using XSLT by passing argument.

XML file:

<NewDataSet>
<Table>
<Title>Supervisor </Title>
<CompanyName>Chennai Leather Cluster</CompanyName>
<CityName>Chennai</CityName>
</Table>
<Table>
<Title>Manager for Chennai Main Branch</Title>
<CompanyName>Chennai Leather Cluster</CompanyName>
<CityName>Chennai</CityName>
</Table>
<Table>
<Title>Senior Manager for Adyar Branch</Title>
<CompanyName>Chennai Leather Cluster</CompanyName>
<CityName>Chennai</CityName>
</Table>
</NewDataSet>

XSLT file:
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="*">
<xsl:sort order="ascending" data-type="text" select="Title" />
</xsl:apply-templates>

</xsl:copy>

</xsl:template>

I want to sort by using Title field. but it's not working...pls. help..

Regards,
tamil




Responses

Author: Kiran Kumar Raju    23 Oct 2008Member Level: SilverRating:     Points: 6
Hi Tamil,

Please execute the below XSLT file. It will give you sorted xml data in a table with respect to Title.

XSLT file:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<!--<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>-->
<html>
<head>
<title>Sorting XML Data</title>
</head>
<body>
<table width="100%" border="1">
<thead>
<tr>
<td width="35%">
<B>Title</B>
</td>
<td width="35%">
<B>Company Name</B>
</td>
<td width="30%">
<B>City</B>
</td>
</tr>
</thead>
<tbody>
<xsl:for-each select="NewDataSet/*">
<xsl:sort select="title" order="ascending"></xsl:sort>
<tr>
<td>
<xsl:value-of select="Title"/>
</td>
<td>
<xsl:value-of select="CompanyName"/>
</td>
<td>
<xsl:value-of select="CityName"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>



Thanks
Kiran Kumar Raju



Post Reply
You must Sign In to post a response.
Next : Problem in HTML and XML file while opening in Firefox and Chrome browsers
Previous : xml
Return to Discussion Forum
Post New Message
Category: XML

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use