on 11-30-2007 6:52 AM
Hi All,
I am trying to sort the records on specific field using XSLT mapping.But I'm unable get the proper output for the following code.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://xxxxxxxx">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<a:T1>
<Row>
<xsl:for-each select="a:S1/Record">
<xsl:sort select="EmpID" />
<EMPID>
<xsl:value-of select="EmpID"/>
</EMPID>
<ENAME>
<xsl:value-of select="EmpName"/>
</ENAME>
</xsl:for-each>
</Row>
</a:T1>
</xsl:template>
</xsl:stylesheet>>
Currently getting following output :
http://www.flickr.com/photos/21390012@N04/2074799747/
Expected output should be like below :
http://www.flickr.com/photos/21390012@N04/2074807393/
Kindly send me suggestion to achieve this.
Regards
Pullarao
Hi ,
I donno much about srting in XSLT but i can give you one example on that.
Example :
This is how to sort numbers in xslt.
Try this :
<xsl:for-each select="learn[@kind='done']">
<xsl:sort select="number(@rank)" data-type="number"/>
<table border="00" cellpadding="3" width="100%">
<tr>
<td width="100" valign="top" align="right"><input type="checkbox" checked="checked" readonly="readonly"/></td>
<td width="10" valign="top" align="right"><xsl:value-of select="position()"/>. </td>
<td valign="top">
[<xsl:value-of select="@rank"/>] <xsl:value-of select="@title"/>
</td>
</tr>
</table>
<table border="00" cellpadding="3" width="100%">
<tr>
<td width="100"> </td>
<td valign="top">
<xsl:apply-templates/>
</td>
</tr>
</table>
</xsl:for-each>
Regards
Aashish Sinha
PS : reward points if helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please go through the blog
/people/tobias.trapp/blog/2007/08/12/smartform-generation-using-advanced-abap-xslt-techniques
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can u paste ur desired output and what u r getting here on SDN.I am not able to see it thru those links.
Regards,
Anoop
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If I give input like as below I'm getting same in output.
<Record>
<EmpID>3<EmpID>
</Record>
<Record>
<EmpID>1<EmpID>
</Record>
<Record>
<EmpID>2<EmpID>
</Record>
But Expected output should be like below
<Record>
<EmpID>1<EmpID>
</Record>
<Record>
<EmpID>2<EmpID>
</Record>
<Record>
<EmpID>3<EmpID>
</Record>
Regards
Pullarao
you input structure doesn't have a root element ROW
try this
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match ="/">
<ROW>
<xsl:apply-templates select="//Record">
<xsl:sort data-type="number"></xsl:sort>
</xsl:apply-templates>
</ROW>
</xsl:template>
<xsl:template match="Record">
<Record>
<xsl:value-of select="EmpID"></xsl:value-of>
</Record>
</xsl:template>
</xsl:stylesheet>
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.