Quantcast
Channel: Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 741

How to.. Import and use XSLT 2.0 mappings in SAP PI/PO

$
0
0

Back in March 2014 Stephan Schluchterblogged about the new features of SAP Process Orchestration 7.31 SP10 & 11 / 7.4 SP05&06, which you can read all about here


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.

There are essential 3 things you need to do:


  1. Create and import an XSLT 2.0 mapping
  2. Download an external XSLT parser
  3. Tell PI/PO to look for the external parser and use it.


1. Create and import an 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> 

Please note that I have set the stylesheetversion="2.0" which indicates that I want to utilize XSLT 2.0 functions.

I then saved the XSL and compressed it as a .zip file. Hereafter I imported the archive in ES Builder.

 

 

2. Download an external XSLT parser.


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:

 

  • /META-INF/services/javax.xml.transform.TransformerFactory
  • /META-INF/services/javax.xml.xpath.XPathFactory

 

The content of these resources defines the implementation of the transformer or XPATH evaluator.

 

 

3. Tell PI/PO to look for the external parser and use it.


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:

 

  1. Access SAP NetWeaver Administrator at:http://<host:port>/nwa
    The variables host and port are the hostname and connection port of your AEX.
  2. Choose -> Configuration -> Infrastructure -> Java System Properties and select the “Services” tab and search for Service XPI: AIIConfig Service
  3. Ensure the custom calculated value for property com.sap.aii.ibrun.server.mapping.externalTransfomer is set to “true”

 

That’s it, now the PO should be good and ready to utilize your next fantastic XSLT 2.0 Mapping


Viewing all articles
Browse latest Browse all 741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>