• Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry

Comments (9)

1 HermannSW commented Permalink

Have a look at stylesheet martin.xsl making use of XSLT 2.0 feature xs:decimal() available on DataPower.

 
If you just run it with coproc2 you will get NaN since the XML Manager of coproc2 service has XSLT 1.0 mode selected:
 
$ java coproc2 martin.xsl some.xml http://dp5-l3.boeblingen.de.ibm.com:2223
78.53999999999999
NaN
$
 
You may want to install two differnt coproc2 services to deal with this -- the second service having XSLT 2.0 selected in Compile Options policy of its XML Manager.
As you can see this works as intended:
$ java coproc2 martin.xsl some.xml http://dp3-l3.boeblingen.de.ibm.com:2223
78.53999999999999
78.54
$
 
Sample stylesheet making use of xs:decimal() :
$ cat martin.xsl
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xsl:output method="text"/>
 
 
<xsl:template match="/">
<xsl:variable name="netValue" select="'69.50'"/>
<xsl:variable name="tax" select="'9.04'"/>
 
 
<xsl:value-of select="number($netValue) + number($tax)"/>
<xsl:text>
</xsl:text>
 
<xsl:value-of select="xs:decimal($netValue) + xs:decimal($tax)"/>
 
<xsl:text>
</xsl:text>
</xsl:template>
 
</xsl:stylesheet>
$

2 HermannSW commented Permalink

Long time I did dot have Eclipse installed -- today I installed it and tried coproc2.


This is the Main tab:

 


This is the Arguments tab:

 


This shows execution of 2hex.xsl with hexadecimal output of "test":

 
 


Need to find out how to setup a XML/XSLT project -- Java view does not highlight XML/XSLT files.
And need to figure out how to pass the stylesheet and xmlfile "Eclipse-like" to coproc2.java, and how to configure the coproc2endpoint ...

 
Hermann.

3 HermannSW commented Permalink

It is even possible to use dp:variable() and dp:http-request-header() with coproc2, see screenshot below:

 
 

4 HermannSW commented Permalink

"coproc2 again -- integration in Eclipse"
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/coproc2_again_integration_in_eclipse44
 
(you can get the screenshots in big by clicking on the small ones)
 
Hermann.

5 RJain commented Permalink

Great post! I tried it and it does work, but I was wondering how does the imports work. I have a structured XSL file arrangement. Something like this

 
Operation (folder)
|___ RequestXSL (folder)
|____ Req.xsl (File importing helper.xsl in common folder)
|___ Common (folder)
|____ Helper.xsl
 
How do I do transformation using a java code and the new co-processor service. I have a variance of number of files in each folder across operations and the file imports are done like import from same folder or import from a different folder.
 
I am not able to find a way to do this kind of an import from coproc2 service. Any pointer is greatly appeciated!

6 SureshSingh commented Permalink

Hi did HTTP Loop back solution supports the import statements present in XSL?

7 HermannSW commented Permalink

Sorry for answering late.

/
There is no solution for passing more than one stylesheet yet, but I am working on a solution.


Workaround for now is to send the file you change most frequently and reference the other filese either on an external HTTP server
or store those files locally on the box, sorry.
 
See these two slide on how you can do at least "Transform Binary" stylesheets without the need to pass any file besides the stylesheet to the box:
http://www-01.ibm.com/support/docview.wss?uid=swg27022977&aid=3#page=13
 
 
http://www-01.ibm.com/support/docview.wss?uid=swg27022979&aid=3#page=3
 

8 Kumar_Y commented Permalink

Hi Hermann,
Finally I am able to see your blog for some reason I kept getting developer works site under maintenance. I tried to implement the coproc2 in my dev appliance and I am using cywgin. I have copied coproc2, coproc2.java in bin folder for cygwin. ($ which coproc2 /usr/local/bin/coproc2).
I am getting this error $ java coproc2
Error: Could not find or load main class coproc2
Can you please help? I am using this link as reference https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014590913

9 HermannSW commented Permalink

Hi, see postings following this one:
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014590913#8c080464-24a8-4181-af5a-167b1d25b7fa

Add a Comment Add a Comment