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: 
MortenWittrock
Active Contributor
Updated June 26th, 2019: The entire blog post has been revised to reflect the major upgrade CPI’s XSLT support received in April of 2019.

When it comes to transforming XML, I’m a huge fan of XSLT. There is a fairly steep learning curve to climb, but once you’ve done so, the power and expressiveness of the language is unmatched. Luckily, XSLT is one of the three mapping options offered by SAP Cloud Integration.

In this blog post, I will take a peek under the hood of CPI’s XSLT processor, to see what we can learn about it.

Peeking under the hood


So CPI supports XSLT, which is great, because XSLT - like bow ties - is cool. But which processor is performing the XML transformations behind the scenes? To answer this, we can utilise XSLT’s built-in system-property function to learn more about the underlying processor (it is safe to use the XSLT 3.0 version of the function, since CPI now supports XSLT 3.0).

The function takes a property name as its only input, and returns the value of that property. Per the W3C specification, XSLT 3.0 implementations must support a number of different properties. However, for this blog post I’m going to focus on the following ones:

  • xsl:version (the supported XSLT version)

  • xsl:vendor (the processor’s implementer)

  • xsl:vendor-url (the URL of the implementer’s web site)

  • xsl:product-name (the processor’s product name)

  • xsl:product-version (the version string of the product)


Right, let’s put all of these in an XSLT 3.0 stylesheet and run it through CPI’s processor. First, the stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:variable name="properties" select="(
'xsl:version',
'xsl:vendor',
'xsl:vendor-url',
'xsl:product-name',
'xsl:product-version')"/>

<xsl:template match="/">
<system-properties>
<xsl:for-each select="$properties">
<xsl:variable name="prop" select="."/>
<xsl:element name="{substring-after($prop, ':')}">
<xsl:value-of select="system-property($prop)"/>
</xsl:element>
</xsl:for-each>
</system-properties>
</xsl:template>

</xsl:stylesheet>

Executing this stylesheet in CPI, I get the following output:
<?xml version="1.0" encoding="UTF-8"?>
<system-properties>
<version>3.0</version>
<vendor>Saxonica</vendor>
<vendor-url>http://www.saxonica.com/</vendor-url>
<product-name>SAXON</product-name>
<product-version>EE 9.8.0.12</product-version>
</system-properties>

This tells us that the XSLT 3.0 processor in CPI is Saxon-EE by Saxonica, the commercial version of the open source Saxon processor. Specifically, CPI runs version 9.8.0.12 at the time of writing.

Java extensions


Prior to the XSLT processor upgrade in April, CPI used Saxon-HE, the open source version of Saxon. One important area, in which the two products differ, is Java extensions, i.e. your ability to execute Java code from within your XSLT stylesheet.

Here’s an example of the so-called reflexive extension functions, where the static pow method of the java.lang.Math class is called:
<xsl:value-of select="math:pow(2,8)" xmlns:math="java:java.lang.Math"/>

Reflexive extension functions are not supported in Saxon-HE, however, and that explains why they weren’t available in CPI, until the XSLT processor received an upgrade.

However, please be aware that calling your own classes from XSLT is not supported and will not work.
12 Comments
Labels in this area