[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Calling a Java extension from XSLT using Saxon B
Subject: [xsl] Calling a Java extension from XSLT using Saxon B From: "Blaine McNutt (rbmcnutt)" <rbmcnutt@xxxxxxxxx> Date: Tue, 23 Jun 2009 12:19:40 -0700 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Merging changes via ID, Michael Ludwig | Thread | Re: [xsl] Calling a Java extension , G. Ken Holman |
Re: [xsl] multiple range expansion, G. Ken Holman | Date | Re: [xsl] Calling a Java extension , G. Ken Holman |
Month |