XSLT Newbie Help !!

Here should go questions about transforming XML with XSLT and FOP.
mfq
Posts: 2
Joined: Wed Jul 04, 2007 2:00 pm

XSLT Newbie Help !!

Post by mfq »

Greetings everyone! :)

I am trying to render an xml-embedded image through XSLT. (pls if you have an example code for that it would be great help! :D )

I have the java function which would return a file source on receiving the xml embedded base-64 image string.

The code preview is as follows:

Code: Select all


<xsl:stylesheet version="1.0"
xmlns:java="http://xml.apache.org/xslt/java"
xmlns:fn="http://www.mydomain.com/xslt"
exclude-result-prefixes="java fn">
. . .
<xsl:variable name="embeddedpic"
select="formData/instance/EmployeePicture" />
<xsl:variable name="pic" select="fn:com.mydomain.utils.ConversionUtils.base64DecodeString($embeddedpic)"/>
I am getting this exception when calling the above java function from my XSLT :shock:

Code: Select all

(XalanXPathException: The function number 'http://xml.apache.org/xslt/java:com.my.utils.ConversionUtils.base64DecodeString' is not available.)
Thanks in advance for info !

Regards
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

See how you must define a Xalan extension. Use the attribute

Code: Select all

xmlns:fn="xalan://com.mydomain.utils.ConversionUtils"
and call the base64DecodeString method with:

Code: Select all

<xsl:variable name="pic" select="fn:base64DecodeString($embeddedpic)"/>

Regards,
Sorin
mfq
Posts: 2
Joined: Wed Jul 04, 2007 2:00 pm

Post by mfq »

Thanks Sorin, I did the change you told and the new error is: Namespace 'xalan:com.mydomain.utils.ConversionUtils' does not contain any functions :cry:
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Check that your class com.mydomain.utils.ConversionUtils contains a method base64DecodeString with two parameters of type org.apache.xalan.extensions.ExpressionContext and org.w3c.dom.traversal.NodeIterator and that the class ConversionUtils is set as extension in the transformation scenario.


Regards,
Sorin
Post Reply