Back in March 2014 stephan.schluchter
One of the new features, is the XSLT 2.0 support for XSLT mappings, which provides new functions that could save a lot of XSLT 1.0 code or minimize the need for java mapping to achieve same functionality. Unfortunately I couldn't find much documentation about how to actually start using this new feature. Therefore I decided to write this step by step blog about how I implemented my first XSLT 2.0 mapping.
In my example I have a requirement of replacing the pound sign with the ISO code on all elements in an XML document, so I created the following XSL:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
<xsl:strip-space elements="*"/>
<xsl:param name="search" select="'£'"/>
<xsl:param name="replace" select="'GBP'"/>
<xsl:template match="@*|*|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:analyze-string select="." regex="{$search}">
<xsl:matching-substring><xsl:value-of select="$replace"/></xsl:matching-substring>
<xsl:non-matching-substring><xsl:value-of select="."/></xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
</xsl:stylesheet>
I then saved the XSL and compressed it as a .zip file. Hereafter I imported the archive in ES Builder.
In my test I used the Saxon 9 parser, which can be downloaded as a home edition from Sourceforge.
If you need further extensibility, the Professional and Enterprise edition can be optained directly from Saxonica homepage (Please note that these editions have license cost).
All other parsers should also work as long as they follow the JAXP specification.
In order for the mapping to use the parser, it needs to be imported to the software component that needs to utilize it. The procedure is the same as with importing the XSL document. In my case, I just imported the saxon9he.jar file.
Note:
When importing an external transformer, the following resources must be available in the archive(s), according to the JAXP specification:
The content of these resources defines the implementation of the transformer or XPATH evaluator.
(*Note: If you have a Dual Stack System, then please refer to evgeniy.kolmakov's excellent extension of this blog here: How to use external XSLT processor for PI Dual stack installations.)
To do this we must set the new global parameter: “com.sap.aii.ibrun.server.mapping.externalTransfomer” to true
(Note that the missing “r” in Transfomer is not a misspelling)
If this property is set to true, the mapping runtime will search for imported transformers, and will use one if found.
To maintain the parameters, perform the following steps:
That’s it, now the PO should be good and ready to utilize your next fantastic XSLT 2.0 Mapping :wink:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
7 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |