| From | Sent On | Attachments |
|---|---|---|
| Blaine McNutt (rbmcnutt) | Jun 23, 2009 12:19 pm | |
| G. Ken Holman | Jun 23, 2009 12:28 pm | |
| Blaine McNutt (rbmcnutt) | Jun 23, 2009 1:09 pm | |
| Michael Kay | Jun 23, 2009 2:57 pm | |
| Ganesh Babu N | Jun 23, 2009 9:53 pm | |
| Michael Kay | Jun 24, 2009 12:09 am |
| Subject: | RE: [xsl] Calling a Java extension from XSLT using Saxon B | |
|---|---|---|
| From: | Michael Kay (mi...@saxonica.com) | |
| Date: | Jun 23, 2009 2:57:19 pm | |
| List: | com.mulberrytech.lists.xsl-list | |
It's always useful to use the -TJ option when debugging this kind of problem.
I think your problem is that you used the -jar option on the command line. This causes the classpath to be ignored. You need to use the
java -cp ... net.sf.saxon.Transform
way of invoking the transformation.
I'm afraid this is an elephant trap that many people fall into. However prominently I put the warnings in the documentation, they still fall in.
Incidentally, questions about specific XSLT products are best asked on a product specific list. For Saxon that's the saxon-help list which you can find via the saxon project on SourceForge.
Regards,
-----Original Message----- From: Blaine McNutt (rbmcnutt) [mailto:rbmc...@cisco.com] Sent: 23 June 2009 20:20 To: xsl-...@lists.mulberrytech.com Subject: [xsl] Calling a Java extension from XSLT using Saxon B
I am not a Java programmer, but I would like to use an extension to check for the existence of an image file referenced by an XML file (as I believe that is the only way to check for the existence of a non-XML file). This topic has been discussed a lot on various aliases, and despite my best efforts, I'm unable to unravel the mystery.
I've included what I believe to be relevant information.
Error Message:
-------------- Error at xsl:value-of on line 15 column 48 of nxs-test-image-exists.xsl: XPST0017: XPath syntax error at char 20 on line 15 in {nxs:fileExist(@osrc)}: Cannot find a matching 1-argument function named {java:FileExist}fileExist() Failed to compile stylesheet. 1 error detected.
Saxon-B 9.1.7 J stored in xmlsrc/xTools/saxon9.
-----------------------------------------------
Java program (compiled and the FileExist.class file stored in xmlsrc/xTools/saxon9/classes)
/* Source: http://p2p.wrox.com/xslt/71563-xslt-check-if-directory-exist.html */
import java.io.File;
public class FileExist {
private static boolean exist;
public static boolean fileExist(String myfile) {
exist = new File(myfile).exists();
return exist;
} }
XML Snippet for img element
---------------------------
... <img osrc="../../images/1982.jpg" />
...
XSLT
------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:nxs="java:FileExist">
<xsl:output method="xml"/>
<xsl:template match="/"> <xsl:apply-templates /> </xsl:template>
<xsl:template match="img"> <xsl:value-of select="nxs:fileExist(@osrc)" /> </xsl:template> </xsl:stylesheet>
Korn Shell script/command line call:
------------------------------------
# define saxon command line saxon="java -classpath xTools/saxon9/classes; -jar -Xmx1G xTools/saxon9/saxon9.jar -tree:tiny -dtd:off -ext:on " # call transform $saxon deliverables/help/helpFile.xml xslt/nxs-test-image-exists.xsl > imageerror.xml
Thank you for any insights you might offer.
Blaine
--~------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-...@lists.mulberrytech.com>
--~--
--~------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-...@lists.mulberrytech.com>
--~--





