Subject: Re: [xsl] Calling a Java extension from XSLT using Saxon B From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 23 Jun 2009 15:29:20 -0400 |
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.
X:\samp>type exists.xml <?xml version="1.0"?> <files> <file>exists.xml</file> <file>exists.junk</file> <file>exists.xsl</file> </files> X:\samp>type exists.xsl <?xml version="1.0"?><!--exists.xsl--> <!--XSLT 1.0 - http://www.CraneSoftwrights.com/training --> <!DOCTYPE xsl:stylesheet [ <!ENTITY nl "
"> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:file="http://www.jclark.com/xt/java/java.io.File">
<xsl:template match="/"> <xsl:if test="not( function-available('file:exists') and function-available('file:new') )"> <xsl:message terminate="yes"> <xsl:text>Required Java file facilities </xsl:text> <xsl:text>are not available</xsl:text> </xsl:message> </xsl:if> <xsl:for-each select="//file"> <!--process each file--> <xsl:text>File </xsl:text><xsl:value-of select="."/> <xsl:text>: </xsl:text> <!--display file name--> <xsl:choose> <!--report existence--> <xsl:when test="file:exists(file:new(string(.)))"> <xsl:text>exists&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>does not exist&nl;</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template>
X:\samp>java -jar p:\xml\xslt\saxon9\saxon9.jar exists.xml exists.xsl Warning: at xsl:stylesheet on line 6 column 66 of exists.xsl: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor File exists.xml: exists File exists.junk: does not exist File exists.xsl: exists
-- Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Calling a Java extension from, Blaine McNutt (rbmcn | Thread | RE: [xsl] Calling a Java extension , Blaine McNutt (rbmcn |
[xsl] Calling a Java extension from, Blaine McNutt (rbmcn | Date | RE: [xsl] Calling a Java extension , Blaine McNutt (rbmcn |
Month |