[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Re: Testing the existence of a binary file (was: How to specify 'raw' encoding in xslt:unparsed-text-available?)

Subject: [xsl] Re: Testing the existence of a binary file (was: How to specify 'raw' encoding in xslt:unparsed-text-available?)
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Sun, 14 Feb 2010 11:56:43 +0100

Since nobody answered, I tried to come up with a solution on my own.

It seems that in Java there is no such thing as a 'raw' encoding, since everything will be represented as 16-bit Unicode characters internally. http://java.sun.com/javase/7/docs/api/java/nio/charset/CharsetDecoder.html
If I supplied my own CharsetDecoder, maybe I could just ignore malformed input and unmappable characters and report success for any input of non-zero length. But I was looking for a solution that works with Saxon out of the box, not requiring users to install Java extension functions.

Looking at what I was trying to achieve, that is: testing the sheer existence of a binary file, rather than reading its raw contents, I came up with the following solution:

Image <sch:value-of select="@src"/> must be present at its @src location.

This relies on the operating system reporting a last change date for the file in question, and of course on Saxon's built-in extension functions which will be an issue for Saxon HE users.


On 05.02.2010 10:21, Imsieke, Gerrit, le-tex wrote:
Dear List Members,

In Schematron using the xslt2 binding, I want to check whether image
files (whose relative path is given in a @src attribute) are present.

So in the generated XSLT file, I have code like the following.

<xsl:when test="unparsed-text-available(resolve-uri(@src, $base-uri))"/>

This works fine if @src refers to text files in US-ASCII or UTF-8
encodings, but not for PNGs oder JPEGs.

So I was looking for an encoding name that I can use as the second
argument to unparsed-text-available. But I couldn't find an encoding
such as RAW or BINARY that Java accepts (I'm using saxon on Java

This issue must have been raised before, but unfortunately I didn't find
previous threads on this matter.

Any hints appreciated.


-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vvckler

Current Thread