Project

Profile

Help

Is file:exists expected to work with a URL argument?

Added by Richard Light over 2 years ago

Hi,

I'm converting a set of [XHTML] web pages, in order to upload them to Wordpress. Some of the images get a '-1' suffix when uploaded to the Media Library; others don't. Therefore I need to check the existence of the base image and its '-1', '-2', etc. variants, so the HTML points to it. My XSLT includes:

		<xsl:choose>
			<xsl:when test="expath-file:exists(concat($media-url, $image-filename))">
				<xsl:attribute name="src">
					<xsl:value-of select="concat($media-url, $image-filename)"/>
				</xsl:attribute>
			</xsl:when>
			<xsl:when test="expath-file:exists(concat($media-url, substring-before($image-filename, '.'), '-1.jpg'))">

When I run it, I get a backtrace on pages containing an image link. Is this simply because HTTP URLs are not supported, or is there a more subtle reason?

Thanks,

Richard


Replies (2)

RE: Is file:exists expected to work with a URL argument? - Added by Richard Light over 2 years ago

For the record, I have worked round the problem. I simply exported the Wordpress Media Library metadata as an RSS feed, and converted that into a simple filename lookup list.

Richard

RE: Is file:exists expected to work with a URL argument? - Added by Michael Kay over 2 years ago

The spec says that functions in the EXPath file library should accept file URIs as well as filenames.

I did a quick check and it seems to work correctly:

java net.sf.saxon.Query -qs:"Q{http://expath.org/ns/file}exists('file:///Users/mike/xxx/temp/test.xml')"

returns true.

    (1-2/2)

    Please register to reply