on 2017 Apr 18 12:46 PM
hello Experts,
I am doing XSLT mapping, below is my xml and xsl code:
xml code:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_sender xmlns:ns0="http://sortbykey_xslt.com">
<Root>
<ReportID>1</ReportID>
<ReportName>test1</ReportName>
<Amount>99</Amount>
<Referance>google</Referance>
</Root>
<Root>
<ReportID>3</ReportID>
<ReportName>test3</ReportName>
<Amount>90</Amount>
<Referance>yahoo</Referance>
</Root>
<Root>
<ReportID>2</ReportID>
<ReportName>test2</ReportName>
<Amount>92</Amount>
<Referance>bing</Referance>
</Root>
</ns0:MT_sender>
xsl code:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://sortbykey_xslt.com">
<xsl:output method="xml" indent="yes" />
<xsl:template match="Root">
<xsl:copy>
<xsl:apply-templates select="ReportID">
<xsl:sort select="ReportID" order="ascending"/>
</xsl:apply-templates>
<ReportID>
<xsl:apply-templates select="ReportID" />
</ReportID>
<ReportName>
<xsl:value-of select="ReportName" />
</ReportName>
<Amount>
<xsl:value-of select="Amount" />
</Amount>
<Referance>
<xsl:value-of select="Referance" />
</Referance>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
i want output in ascending order by ReportID, but I am not getting it by this xsl code.
please help me where am I wrong???
Thanks,
Ravi
Request clarification before answering.
Hi Ravi!
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<ns0:MT_sender xmlns:ns0="http://sortbykey_xslt.com">
<xsl:apply-templates select="//Root">
<xsl:sort select="ReportID"/>
</xsl:apply-templates>
</ns0:MT_sender>
</xsl:template>
<xsl:template match="Root">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
20 | |
10 | |
9 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.