cancel
Showing results for 
Search instead for 
Did you mean: 

To filter records using XSLT mapping

Former Member
0 Kudos

Hi all,

I am using XSLT mapping in my scenario.

I have below structure.

<Node>

<emp_id>123<emp_id>

<begin_date>dd/mm/yyyy<begin_date/>

<end_date>dd/mm/yyyy<end_date/>

<check_date>dd/mm/yyyy<check_date/>

<Node/>

I want to filter out the records based on check_date. If checkdate is less than enddate, i want to filter out that particular records.

If anyone knows, Please suggest me in this issue.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Thank u all for ur valuable suggestions.

Former Member
0 Kudos

hi,

<xsl:variable name="checkdate">

<xsl:for-each select="Node/check_date">

<xsl:value-of select="substring(concat(substring(Node/checkdate,1,2),substring

(Node/checkdate,4,2),substring(Node/checkdate,7,4)),1,8)"/>

</xsl:for-each>

</xsl:variable>

Like wise create a variable for end date....

<xsl:for-each select="Node">

<xsl:if test="$checkdate > ''$enddate">

<emp_id>

<xsl:value-of select="Node/emp_id"/>

</emp_id>

like wise create map for other filed...

</xsl:if>

</xsl:for-each>

I think this will solve your requirement......

Regards,

Prakasu

Former Member
0 Kudos

Hi Radhika,

I hope u can achieve it.

First, your requirement is to display only those data which mets the condition (Check date<end date). For this, use <xsl:for-each> with <xsl:if test> followed by it.

And in the test condition compare the dates. Even though there are no funtions in XSL to compare the dates directly, you can first convert the dates into numeric values using the existing date functions. That means, get the year, month, and date from the given dates and then compare those numbers.

I think this will acieve your requirement.

Regards

Bhanu

Intelligroup.

Former Member
0 Kudos

Hi,

My issue is to filtering records.I can compare the dates.What my requirement is If condition fails i have to avoid those records while sending to the receiver.

Thanks for ur quick reply.Please suggest.

Former Member
0 Kudos

Hi Radhika

you may use some piece of java code to perform this comparison !

here is the link for code sample

XSL date manipulation

http://www.topxml.com/forum/m_302/mpage_1/key_/tm.htm#302

some more threads

http://www.w3.org/2001/08/date-util.xslt

http://www.ibm.com/developerworks/library/x-xdexslt.html

regards

sandeep

if helpful reward points

Former Member
0 Kudos

HI ,

You need to use XSLT(XPath) to reach the exact element in

and then you can compare the two dates.

Pls refer the following link for reaching the nodes and transformation.

http://www.w3schools.com/xsl/xsl_transformation.asp

Thanks,

Ramu

Former Member
0 Kudos

Hi,

I'm not sure XSLT provides native date manipulator (in your case, compare), so you may have to embed some piece of java code to perform this comparison !

I think I have a sample somewhere, I'll try to find it

Rgds

Chris

PS : there is another solution, change your dates format to YYYYMMDD and perform simple string comparison in your XSLT, it should work as explained here : http://www.stylusstudio.com/xsllist/200603/post60720.html

Edited by: Christophe PFERTZEL on Apr 24, 2008 12:58 PM