Author |
Message
|
Janice_Shania |
Posted: Mon Sep 25, 2006 8:39 am Post subject: XML Transformation Node and Functions |
|
|
Novice
Joined: 25 Sep 2006 Posts: 12
|
Hi,
I am trying out the XML Transformation Node in WMB and want to know what support has been provided for use of functions.
Since it is based on XSLT 1.0, i believe that normal <xsl:funtions> will not be supported.
However are exslt functions supported?
I tried an example, but it does not seem to work,
Any help will be greatly appreciated.
Thanx
Janice |
|
Back to top |
|
 |
XZ |
Posted: Tue Sep 26, 2006 12:51 am Post subject: |
|
|
 Apprentice
Joined: 22 May 2006 Posts: 45 Location: IBM Hursley
|
|
Back to top |
|
 |
Janice_Shania |
Posted: Tue Sep 26, 2006 2:00 am Post subject: XML Transformation Node and Functions |
|
|
Novice
Joined: 25 Sep 2006 Posts: 12
|
Hi XZ,
The site does not open, please could you confirm the URL.
Also, are you aware of any successful implementation of such functions being implemented?
Please could you let me know. Its a little urgent. Since my code has a number of reusable sections of code, and i really wanna get hold of functions of some sory.
Thanks in advance,
Janice |
|
Back to top |
|
 |
XZ |
Posted: Tue Sep 26, 2006 3:25 am Post subject: |
|
|
 Apprentice
Joined: 22 May 2006 Posts: 45 Location: IBM Hursley
|
|
Back to top |
|
 |
Janice_Shania |
Posted: Tue Sep 26, 2006 7:53 am Post subject: |
|
|
Novice
Joined: 25 Sep 2006 Posts: 12
|
Hi,
I tried the extensible style sheets too.
They dont seem to work.
has anyone got a hand over these?
please could an example be posted...
Thanks
Janice |
|
Back to top |
|
 |
Janice_Shania |
Posted: Wed Sep 27, 2006 12:53 am Post subject: |
|
|
Novice
Joined: 25 Sep 2006 Posts: 12
|
Hi XZ,
I tried this example in WMB, but it fails to work. The error message that is displayed is not very helpful: [b]Transformation failure when processing Stylesheet deployed:./func.function.1.xsl
The stylesheet could not be processed: deployed:[/b]
The style sheet is as follows.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math"
xmlns:func="http://exslt.org/functions"
exclude-result-prefixes="func">
<xsl:template match="/">
<Result>
<xsl:value-of select="func:testfunction(//Test)"/>
</Result>
</xsl:template>
<func:function name="func:testfunction">
<xsl:param name="inputString"/>
<func:result select="//Two" />
</func:function>
</xsl:stylesheet>
When i replce the call to the function with a math-function is exslt, like math:sin(3.14), it works fine in WMB.
Please could you advice.
Regards,
Janice |
|
Back to top |
|
 |
Janice_Shania |
Posted: Wed Sep 27, 2006 12:56 am Post subject: XML Transformation Node and Functions |
|
|
Novice
Joined: 25 Sep 2006 Posts: 12
|
Additionally, i would like to add, that the transformation works well in XML editor in WMB. However, when used as a part of the flow, using the XML Transformation Node, it fails.
Thanks,
Janice |
|
Back to top |
|
 |
XZ |
Posted: Wed Sep 27, 2006 2:37 am Post subject: |
|
|
 Apprentice
Joined: 22 May 2006 Posts: 45 Location: IBM Hursley
|
Janice,
It looks that you have hit a limitation of Xalan compiler (interpreter is ok with your style sheet). It reported the following exception:
Quote: |
ERROR: 'The first argument to the non-static Java function 'testfunction' is no
t a valid object reference.'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesh
eet
at org.apache.xalan.xsltc.trax.TransformerFactoryImpl.newTemplates(Trans
formerFactoryImpl.java:778)
at org.apache.xalan.xsltc.trax.SmartTransformerFactoryImpl.newTemplates(
SmartTransformerFactoryImpl.java:252)
at CompilerTest.main(CompilerTest.java:22) |
The XMLT node compiles your style sheet if your cache level > 0. You can avoid your style sheet being compiled by setting your cache level to 0 (may have a performance hit).
Otherwise, would the following style solve your problem?
Quote: |
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math"
xmlns:func="http://exslt.org/functions"
exclude-result-prefixes="func">
<xsl:template match="/">
<Result>
<xsl:call-template name="testfunction">
<xsl:with-param name="inputString" select="//Test"/>
</xsl:call-template>
</Result>
</xsl:template>
<xsl:template name="testfunction">
<xsl:param name="inputString"/>
<xsl:param name="result" select="//Two" />
</xsl:template>
</xsl:stylesheet> |
_________________ Regards,
-XZ
WMQI Development |
|
Back to top |
|
 |
Janice_Shania |
Posted: Wed Sep 27, 2006 3:10 am Post subject: XML Transformation Node and Functions |
|
|
Novice
Joined: 25 Sep 2006 Posts: 12
|
Hi XZ,
Cheers!!
Both the approaches that you suggested worked well. As you say, due to performance hit..i would rather go with the "<xsl:call-template" approach.
Thanx a million,
Janice
:D |
|
Back to top |
|
 |
|