SAP CPI complex filtering using XSLT

For complexes filters, XSL scripts can really help. In this case I need to dynamically set a filter with the date of today and another date that happen 1 week ago.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:src="http://fer.common/worker"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
	exclude-result-prefixes="#all"
	version="3.0">
  <xsl:mode on-no-match="shallow-copy"/>
  <xsl:output method="html" indent="yes"/>
  <xsl:strip-space elements="*"/>
  <!-- Getting two dates : today and inactive date which is today minus 1 week-->
  <xsl:variable name="today" select="format-date(current-date(), '[Y0001]-[M01]-[D01] 00:00:00')" />
  <xsl:variable name="inactiveDate" select="format-date((current-date() - 7*xs:dayTimeDuration('P1D')), '[Y0001]-[M01]-[D01] 00:00:00')" />
  <!-- This will filter out all records NOT matching the conditions below -->
  <!-- 1. field1 greater than Today-->
  <!-- 2. field2 is false and field3 greater than a week -->
  <xsl:template match="Employee[(node1/field1/text() gt $today) or (node2/field2/text() eq 'false' and node3/field4 gt $inactiveDate ) ]"/>
</xsl:stylesheet>