
I need to write a stylesheet which checks the value of an attribute to see if it is the name of an existing file. You can't do it directly in XSLT of course, so I am following the advice of Mike Kay (https://www.oxygenxml.com/archives/xsl-list/200506/msg00400.html) and trying to do it with a java extension in an XSLT2 stylesheet. Here's the relevant template, which I run with saxon EE within oXygen 18.1 <xsl:template match="tei:pb"> <xsl:variable name="filename" as="xs:string"> <xsl:value-of select="@facs"/> </xsl:variable> <xsl:variable name="resolvedFile" as="xs:anyURI" select="resolve-uri(@facs, base-uri(.))"/> <xsl:message> <xsl:value-of select="concat($filename, ' resolves to ', $resolvedFile)"/> </xsl:message> <xsl:if test="not(fs:exists(fs:new($resolvedFile)))" xmlns:fs="java.io.File"> <xsl:value-of select="concat($filename, ' Not Found')"/> </xsl:if> <xsl:text> </xsl:text> </xsl:template> The messages produced tell me that the filenames are being resolved correctly (they are all relative URLs like this ../../something/foo/foo.jpg) but the test always returns true, whether the file concerned exists or not. Am I missing something obvious? Or not obvious? This has been driving me nuts all day...