on 10-10-2008 3:03 PM
Hi Friends,
My requirement is like this.
for one employee id there are multiple check dates. what i need is i will get latest check date in the output. please tell me logic
i am using java XSLT.
plz help me out. ponts also rewarded.
Thanks
Anil M
Hi Anil,
take this as example:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<datum>20081231</datum>
<datum>20081201</datum>
<datum>20080101</datum>
</root>
And the stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<root>
<xsl:for-each select="//datum">
<xsl:sort order="descending" select="."/>
<xsl:if test="position()=1">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
will give you the result:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<datum>20081231</datum>
</root>
Regards,
Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can not expect one to give complete solution here. Udo has given proper example. It is up to you to change it according to your requirements. The way he mentioned the diffrent dates is considering they are in different records. Assume that they are in the same record and try to modify the code.
Or write an udf which take the entire context of the dates and returns you the max number (Convert date to yyyymmdd format) and then return this to the target.
VJ
Hi Anil,
the stylesheet picks the latest datum of my test xml, definitively.
Of course your xml might look a bit different, therefore you have to adapt the stylesheet for your challenge. If this is too much for you you could post your xml. In general it is not bad to provide the requirements by posting questions.
Regards,
Udo
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.