[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Calling a Java extension from XSLT using Saxon B (
Many thanks, Ken. You've saved me many additional hours of digging. The namespace declaration and code brought me back to another example Michael had posted, and the namespace was key to understanding that example. The final code is as follows for future searchers (and as long as @hsrc is not empty, it works as expected--otherwise, it throws the error XTTE0570: An empty sequence is not allowed as the value of variable $hsrcUri in built-in template rule): <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:file="http://www.jclark.com/xt/java/java.io.File" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs file" > <xsl:output method="xml"/> <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:apply-templates /> </xsl:template> <xsl:template match="img"> <!-- takes the relative path @hsrc and resolves a full URI based on the location of the current XML document --> <xsl:variable name="hsrcUri" select="resolve-uri(@hsrc, base-uri(.))" as="xs:anyURI"/> <xsl:choose> <xsl:when test="file:exists(file:new($hsrcUri))"> <xsl:message><xsl:value-of select="$hsrcUri"/> exists.</xsl:message> </xsl:when> <xsl:otherwise> <xsl:message><xsl:value-of select="$hsrcUri"/> does not exist.</xsl:message> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|