Using WmPublic functions inside xslt stylesheet

Hi,

I’m pretty new at this so…

However, I searched the forums for “xslt” and didn’t find anything specific as to what I’m looking for.

Let’s say I wanted to call the addInts service from the WmPublic package from my xslt stylesheet, how would I go about it? I know there’s other ways to make simple additions, but bear with me for the sake of knowing how to do it.

I tried the example from page 29 of the XSLTServiceDevGuide, using this namespace:

[FONT=Courier][SIZE=1]xmlns:IntDate=“java://com.wm.pkg.xslt.samples.date.IntDate”

It worked. Great. After finding where math.class was in the WmPublic package, I used this namespace:

xmlns:addInts=“java://pub.math”

and this snippet:

<xsl:value-of select=“math:addInts(‘5’, ‘5’)”

This didn’t work. I got the “JAXP: Error instantiating transformer” message.

First obvious question: Is it possible to do what I want to do? On Developper 6.5 by the way.

Any tips appreciated. Here’s the test xslt stylesheet I’m using:

[/SIZE][/FONT]

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL]http://www.w3.org/1999/XSL/Transform[/URL]"
xmlns:IntDate="java://com.wm.pkg.xslt.samples.date.IntDate"
xmlns:addInts="java://pub.math">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:param name="MyParam1"></xsl:param> 
 <xsl:template match="/">
  <xsl:element name="EDITRANSACTIONSET">
   <xsl:element name="EDIDOCUMENTTYPE"><xsl:value-of select="//EDIDOCUMENTTYPE"/></xsl:element>
   <xsl:element name="EDIDOCUMENTNUMBER"><xsl:value-of select="//EDIDOCUMENTNUMBER"/></xsl:element>
   <xsl:element name="NOCOMMANDE"><xsl:value-of select="//NOCOMMANDE"/></xsl:element>
   <xsl:element name="DATECOMMANDE"><xsl:value-of select="math:addInts('5', '5')"/></xsl:element>
   <xsl:element name="DATELIVRAISON"><xsl:value-of select="IntDate:getDate('2010','07','20','12','12','12')"/></xsl:element>
   <xsl:element name="MESSAGE"><xsl:value-of select="$MyParam1"/></xsl:element>
   <xsl:element name="ADDRESSNUMBERSHIPTO"><xsl:value-of select="//ADDRESSNUMBERSHIPTO"/></xsl:element>
   <xsl:element name="LISTECOMMANDESDA">
   <xsl:for-each select="//COMMANDESDA">
    <xsl:sort select="QTECOMMANDE"/>
    <xsl:element name="COMMANDESDA">
     <xsl:element name="QTECOMMMANDE"><xsl:value-of select="QTECOMMANDE"/></xsl:element>
     <xsl:choose>
      <xsl:when test="UNITE = 'BT' ">
       <xsl:element name="UNITE"><xsl:text>BOUTEILLE</xsl:text></xsl:element>
      </xsl:when>
      <xsl:otherwise>
       <xsl:element name="UNITE"><xsl:text>CAISSE</xsl:text></xsl:element>
      </xsl:otherwise>
     </xsl:choose>
     <xsl:element name="CODEUPC"><xsl:value-of select="CODEUPC"/></xsl:element>
    </xsl:element>
   </xsl:for-each>
   </xsl:element>
  </xsl:element>
 </xsl:template>
</xsl:stylesheet>

did you try to use:
<xsl:value-of select=“$var1 + $var2” />
to directly do the math?

Hi,

I know there are other ways to do the additions. I picked the addInts from WmPublic because it’s a simple example to use. I could have chosen any other service from the WmPublic package as an example. The goal on my post is really to know how I could call whatever service coming from WmPublic (or another WmXX package) from my xslt stylesheet.

Actually, what would help tremendously is if anobody could give me a hint as to what would be the correct namespace for the math class under WmPublic. For the IntDate example I posted above, the namespace is java://com.wm.pkg.xslt.samples.date.IntDate. It happens that the IntDate.class is in the following directory in our environment:

/opt/webMethods7/IntegrationServer/packages/WmXSLT/code/classes/com/wm/pkg/xslt/samples/date

I tried the example from the documentation and it works. In our environment, math.class is there:

/opt/webMethods7/IntegrationServer/packages/WmPublic/code/classes/pub

That’s why I thought that my namespace would be “java://pub.math” but it doesn’t work, probably because it’s not the right namespace. I’ve been searching like crazy for the right namespace but I can’t find it.

No you can’t, because public Built-in services uses Idata as input/output parameters for the methods, and XSLT will use The IOutputMap
interface (com.wm.pkg.xslt.extension.IOutputMap) , and will put values as IOutputMap.put(Object name, Object value) to add name/value pairs to an output object of type IOutputMap.

When you add in the XSLT:
IntDate:getDate(‘2010’,‘07’,‘20’,‘12’,‘12’,‘12’)

That will excute methods getDate passing 6 String arguments, and the method will return a Date object which will be placed in the interface IOutputMap.put(Object name, Object value)

You can build your own Java classes, but not possible using built-in ones.

Well, thanks for clearing that up. I was looking left and right like crazy in trying to make this work. I believe the built-in services like what you can find in the WmPublic are written in Java (which I’m not that familiar with, Java that is) and I figured it could be done. Damn… would have been nice.