cancel
Showing results for 
Search instead for 
Did you mean: 

CPI XSLT - Using of header variable in XSLT

0 Kudos

hi everyone,

I am trying to use an CPI header named termdate in my XSLT mapping (in xsl file)as a parameter.

According to this blog it should be possible to do so by simply defining a parameter since XSLT parameters are automatically bound to Camel headers.

https://blogs.sap.com/2018/03/27/sap-cpi-accessing-header-and-property/

My XSLT is as below:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:hci="http://sap.com/it/" exclude-result-prefixes="hci">
 <xsl:param name= "termdate"/>
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>
 <xsl:template match="node()|@*">
  <xsl:copy>
   <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
 </xsl:template>

 <xsl:template match="/queryCompoundEmployeeResponse/CompoundEmployee[(person/employment_information/payrollEndDate <= '$termdate')]"/>
</xsl:stylesheet>

I am not facing any errors while running this mapping step. But the filter condition does not seem to work. (FilterCondition: PayrollEndDate lessthanorEqual to $termdate)

Please help me to use it in the right way. I am using the right syntax and right declarations ?

Best Regards, Sravan

View Entire Topic
Muniyappan
Active Contributor
0 Kudos

1.you are only declaring termdate variable and not providing any value.

<xsl:param name="termdate" slect="give your date here"/>

https://www.oreilly.com/library/view/xslt/0596000537/ch04s04.html

2. I am not sure if your second template match expression is right or wrong. once you provide value to your temdate variable and you get desired output, then ignore this step. else you could also change expression like below and try.

/queryCompoundEmployeeResponse/CompoundEmployee/person/employment_information[payrollEndDate <= '$termdate']
0 Kudos

Hi Muniyappan,

termdate is a header which I have declared in CPI iflow before my XSLT mapping.

I would like to use the same in my mapping.

I have referred to https://blogs.sap.com/2018/03/27/sap-cpi-accessing-header-and-property/

But still its not working.