Back in March 2014 Stephan Schluchter blogged 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 stylesheet version=“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.


(*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.

External Transformer.JPG

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: AII Config 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 πŸ˜‰

To report this post you need to login first.

36 Comments

You must be Logged on to comment or reply to a post.

  1. nav mrid

    Hi Chris,

    Very Nice Blog….. Highly informative. But  I am having some doubts like whether following the same procedure can we use XSLT 2.0 in PI 7.11.

    (0) 
    1. Chris Christoffersen Post author

      Hi Nav,

      Thanks, glad you like it πŸ™‚

      According to Stephans blog mentioned in the beginning, the features is available for Process Orchestration 7.31 SP10&11 / 7.4 SP05&06, so I don’t think you will be able to make it work on PI 7.11.


      If you try it out, then please share the results.

      Best regards,

      Chris

      (0) 
  2. SiriManasa Nutalapati

    Hello Chris,

      Thanks for a very useful blog.

      We have implemented some map using XSLT 2.0. The mapping uses few of the functions 

      like for-each-group and replace. Saxon9he.jar has also been imported by making sure the

      required XSLT and XPath factory configuration files are available.

    In order to enable the use of the external processor imported, the “AII Config service 

    property “com.sap.aii.ibrun.server.mapping.externalTransfomer” is also been set to “true”.

    But still the runtime throwing error the used functions are not supported by the processor. 

    Upon deploying and checking the XPI traces, we encountered that the imported processor

    is not being referred by JDK. It is still referring to the internal Xalan processor.

    Can you please provide us any inputs to identify the root cause of the issue.

    By the way, PI version is: PI 7.4 dual stack SP9.

    Thanks in advance..

    Regards,

    Manasa.

    (0) 
  3. Sumit Patel

    Hi Chris,


    We are having requirement of Saxon Enterprise Edition in SAP Netweaver PI 7.4 system for which I need to import it JAR file but I am not aware how to import these jar files into SAP Netweaver PI 7.4 system and where to place it. Couldyou please help me with it asap..

    (0) 
    1. Chris Christoffersen Post author

      Hi Evgeniy

      I have actually only tried ot on PO single stack. But as long as it is at least 7.31 SP10 & 11 or 7.4 SP05&06 then I imagine that it should work.


      If you test it out, then please let us know your findings

      Cheers,

      Chris

      (0) 
      1. Evgeniy Kolmakov

        Hi Chris!

        I couldn’t make it work for now. I’ve tried with Saxon 9 HE and Saxon-B.  In both cases I have error on XSLT 2.0 syntax and in error trace I can see that it raised by java’s xalan processor, not Saxon.

        Regards, Evgeniy.

        (0) 
  4. Sumit Patel

    Hi Kolmakov,

    Thanks for your reply.

    Could you please provide me with step by step screenshots..

    Where can I find Imported Archive option in ESR?

    SCW?

    Regards,

    Sumit

    (0) 
    1. Chris Christoffersen Post author

      Hi Sumit

      In ESR goto the SWCV that you need the XSLT 2.0 mapping for. Here you will have a namespace where your actual mapping objects are. In this namespace, you should have “Imported Archives”. Find the Archive where your XSLT 2.0 mapping is located. Change object and click “Import Archive” Now add the saxon9he.jar file (or whatever XSLT parser you have downloaded)

      Hope this explains it. Otherwise please feel free to ask again

      Cheers,

      Chris

      (0) 
  5. Sumit Patel

    Hi Chris,

    Thanks for your quick reply.

    In ESR  SWCV  means Software Component version right?

    I am unable to find Imported Archive option

    COuld you please provide me your email id so that I can share more details .

    Regards,

    Sumit

    (0) 
    1. Chris Christoffersen Post author

      Hi Sumit

      How did you upload your XSLT then? Or didnt you upload it yet?

      The import archive is located here (The SAP BASIS Software Component Version is just an example):

      CaptureSWCV.JPG

      Cheers,

      Chris

      (0) 
      1. Chris Christoffersen Post author

        And by the way, if you dont see any “Imported Archives” then right click on the namespace and choose -> new -> Mapping objects -> Imported Archive and create a new one.

        /Chris

        (0) 
  6. Sumit Patel

    Hi Chris,

    Thanks for the above screenshot .

    I haven’t uploaded any XSLT till yet . I found the Imported archive option as per above screenshot.  X1.jpg

    I am not sure whether xslt mapping creation has been done or not .

    As Saxon EE is an alternative for XSLT 2.0 mapping tool hence I want to download Saxon EE   SaxonEE9-6-0-9J JAR  file and deploy it to SAP Netweaver PI 7.4  system

    Please let me know what next I need to do to import Saxon EE jar file SaxonEE9-6-0-9J  from below screenshot.SaxonEE.jpg

    (0) 
    1. Chris Christoffersen Post author

      Hi Summit

      Please be aware that the SWCV that I used was just an example (SAP BASIS 7.40) You probably want to use your own instead.

      When you have the “imported archive” you want to import your XSLT (Zipped) which contains the mapping, and then the saxon9ee.jar file.

      (Refer to Imported Archives (XSLT/Java) – SAP XI: Design and Configuration Time – SAP Library for procedure if you are in doubt)

      When done, you should change the parameter as described in section 3 of the blog.

      Chris

      (0) 
  7. Sumit Patel

    Hi Chris,

    Even after importing saxon9ee.jar file into imported archive of xslt mapping and set the parameter com.sap.aii.ibrun.server.mapping.externalTransfomer  value to True in exchange profile , it is still throwing error..Pls find below screenshots..

    Please suggest how to proceed further

    Xslt1.jpg

    Xslt2.jpg

    Xslt3.jpg

    (0) 
    1. Evgeniy Kolmakov

      Hi Sumit!

      Blog comments is not the right place to post questions about your technical problems.

      Please start new discussion, thus much more experienced forum members will be able to help you with decision for your problem.

      Regards, Evgeniy.

      (0) 
  8. Artem Osukhovskyi

    Hello Chris and guys/girls.

    First of all – thanks for great blog. Everything explained nicely and without many words.

    I’ve configured parameters as described and tried with several versions of Saxon parser (latest version 9.7 and also older 9.2 – just imported saxon9he.jar in each case), but still no success for me. πŸ™

    During mapping test (operation mapping) ES builder throws such error:

    Transformer Configuration Exception occurred when loading XSLT <my xslt name goes here>; details: com.sap.aii.ib.server.mapping.execution.MappingClassNotFoundException: com/sap/aii/mapping/xslt/saxon/JavaExtensions$JavaFunctionLibrary.class

    Any ideas what can be causing that?

    I’m afraid this problem can be related to some issue in latest patch we applied on DEV system (we are on NW PI 7.4 single-stack with latest components SP13).

    BR, Artem.

    (0) 
    1. Evgeniy Kolmakov

      Hi Artem!

      It’s worth mention that Saxon HE processor doesn’t support java extensions:

      Not included in the Home Edition are: schema processing and schema aware XSLT and XQuery; support for higher-order functions; numerous Saxon extensions; calling out to Java methods;

      If you use java extensions in your XSL transformations try Saxon-B, which also supports XSLT 2.0.

      Regards, Evgeniy.

      (0) 
      1. Artem Osukhovskyi

        Hello Evgeniy.

        That’s what is most confusing – I don’t have any calls to Java methods in my mapping.

        I’ve tried with simplest XSLT-mapping which is based on XSLT 1.0 (without any additional namespaces prefix except for xmlns:xsl)and executed successfully as such. After copying this mapping into SWCV where Saxon parser is imported – it starts to throw error shown above. Thank you for suggestion – I’ll try with Saxon-B as well, but I’m afraid this is just another issue among others which we got along with newest SP. πŸ™

        BR, Artem.

        (0) 
  9. Antony FERMINUS

    Hi Artem,

    According to the instruction i got it done recently. It is really simple. I am using pi 7.5.

    Download the JAR saxon9he.jar extract it and upload  to the PI external archives.

    After the export make sure that you see

    javax.sml.transform.transformerFactory  with path  META-INF/Services/xslt2_0.PNG

    If you do not see this means you have to search the correct jar file where you can find this line and download it.

    Go to NWA java system property, then service tab and search

    Service XPI: AII Config Service

    and change the

    com.sap.aii.ibrun.server.mapping.externalTransfomer is set to “true”.

    That is it. It should work.

    Regards,

    Antony.

    (0) 
    1. Artem Osukhovskyi

      Hello Antony.

      I did everything exactly like you described, but unfortunately with no success.

      At the moment I have just two suggestions:

      1. Latest SP broken external transformer functionality.

      2. Maybe I need much older version of parser which was built using Java version corresponding to the one used in NW 7.4 (version 1.6). So far I have tried only with Saxon 9.2 (built on Java 1.7) and latest 9.7 (built on Java 1.8).

      BR, Artem.

      (0) 
      1. Antony FERMINUS

        Hi Artem,

        Can you post the recent error description or still it is the same as before?

        It is not a bad idea to restart your java stack if you can.

        First of all which NWDS you are using?

        Did you install the XSLT2.0 processer in your NWDS?.

        Is the xslt2.0 transfomation working on your NWDS?

        https://www.youtube.com/watch?v=i5ygzJVkG1w

        You can find the instruction on the youtube (4.55 min time).

        Regards,

        Antony.

        (0) 
        1. Artem Osukhovskyi

          Hi Antony.

          Thanks for your interest, but as I mentioned in my comment below – this is a problem of latest patch. I was able to run the same parser and XSLTs successfully on another system with lower patch level.

          Also patched system was restarted – it didn’t help.

          Thanks for your link above – I hadn’t used XSLT in eclipse before. Now gonna use it on such occasion.

          BR, Artem.

          (0) 
  10. Artem Osukhovskyi

    Update: the error I mentioned above is really related to newest SP applied on our system (NW 7.4 SP13 with latest PLs which indeed is part of SPS15).

    I have checked on another system (based on SP12 components) and it worked fine with latest Saxon version (even though XSLT mapping is running slowly when testing it in ES Builder).

    So be extremely careful with patches !

    BR, Artem.

    (0) 
  11. Artem Osukhovskyi

    Another update:

    it seems that following note should fix the problem I’ve mentioned above:

    2221350 – Support for Java Extensions in the SaxonHE XSLT Transformer

    it refers to exactly the same class/package which is reported in the above exception and must be created according to the note as Function Library.

    Unfortunately proposed solution doesn’t work out of the box with latest version of Saxon HE parser (9.7) because of changed class hierarchy there (so attached code is not consistent anymore).

    Still this is a valid solution for previous version(s) of Saxon parser. I was able to run XSLT 2.0 mappings using it with Saxon parser 9.5 (some older versions like 9.1/9.2 do not compile with it same way as it does not work with version 9.7).

    Going to ask SAP for updating above note to make it searchable by exception text and also adding more code versions for different parser version (at least for the latest version 9.7, if possible – or otherwise it should be possible to disable use of Java extensions with external parsers which don’t support them).

    BR, Artem.

    (0) 
    1. Sebastian Duelfer

      Hello Artem,

      did you get any response about the update of the note for Saxon HE parser 9.6 or higher?
      We had the same problem and had installed Saxon 9.6 which was working fine, then patched the system to latest SP and it was not working anymore.
      So I downgraded the saxon to 9.5 and appliedΒ 2221350 – Support for Java Extensions in the SaxonHE XSLT TransformerΒ and then it was working.

      But would be interesting if SAP will deliver a solution for Saxon 9.6 or higher.

      Best Regards

      Sebastian

      (0) 

Leave a Reply