Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member190293
Active Contributor
In this blog I want to show you the way of getting user-defined parameters within XSL transformation without using any custom java classes and Dynamic Configuration.

But first, I would like to thank Nikolay Yasinskiy very much, whos valuable suggestion threw the light on how the Operation mapping input parameters can be accessed directly using java extensions mechanism.

Described approach is based on using poorly documented input parameter "TransformationInput", which is passed to XSL transformation among the other parameters.

So, in order to use this parameter we should add the line to our XSL stylesheet:
<xsl:param name="TransformationInput">

At next step we just get parameter value using java extensions mechanism and types casting possibilities.

Here is an example stylesheet demonstating the approach described above:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ti="java:com.sap.aii.mapping.api.TransformationInput"
xmlns:inpar="com.sap.aii.mapping.api.InputParameters"
xmlns:xsltc="http://xml.apache.org/xalan/xsltc"
exclude-result-prefixes="xs ti inpar xsltc"
version="1.0">

<xsl:param name="TransformationInput"/>

<xsl:template match="/">
<xsl:variable name="myparam" select="inpar:getValue(ti:getInputParameters(xsltc:cast('com.sap.aii.mapping.api.TransformationInput',$TransformationInput)),'MyParam')" />
<ExampleMessage>
<Param name="MyParam"><xsl:value-of select="$myparam"/></Param>
</ExampleMessage>
</xsl:template>

</xsl:stylesheet>

As you can see, neither custom java classes nor Dynamic Configuration as transport layer were involved.

Now we can define the needed parameters in Operation mapping editor and bind it to respective XSL mapping. That's all.

Update: During further investigation I could find another parameter called "inputParameter". Using it instead of "TransformationInput" parameter makes things even easier:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:inpar="com.sap.aii.mapping.api.InputParameters"
xmlns:xsltc="http://xml.apache.org/xalan/xsltc"
exclude-result-prefixes="xs inpar xsltc"
version="1.0">

<xsl:param name="inputParameter"/>

<xsl:template match="/">
<xsl:variable name="myparam" select="inpar:getValue(xsltc:cast('com.sap.aii.mapping.api.InputParameters',$inputParameter),'MyParam')" />

<ExampleMessage>
<Param name="MyParam"><xsl:value-of select="$myparam"/></Param>
</ExampleMessage>
</xsl:template>

</xsl:stylesheet>

Hope it helps!

Regards, Evgeniy.
16 Comments
Labels in this area