[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Dear Stefan,
Thank you so much. I wasn't aware of the fact that it's so easy to inline Java method calls. Your solution serves our purpose better because it doesn't rely on Saxon-EE functionality. (Of course it would serve Saxonica's case better if it relied on saxon extension functions. I'll try to find other ways to make our suppliers buy licenses, Michael...)
And, yes, it works with Schematron (as long as a Java-implemented XSLT2 processor is being used), see for example http://github.com/gimsieke/letex-xhtml-tables
Gerrit
On 14.02.2010 13:55, Stefan Krause wrote:
Re: [xsl] Re: Testing the existence of a binary file
Subject: Re: [xsl] Re: Testing the existence of a binary file From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Sun, 14 Feb 2010 15:10:01 +0100 |
Dear Stefan,
Thank you so much. I wasn't aware of the fact that it's so easy to inline Java method calls. Your solution serves our purpose better because it doesn't rely on Saxon-EE functionality. (Of course it would serve Saxonica's case better if it relied on saxon extension functions. I'll try to find other ways to make our suppliers buy licenses, Michael...)
And, yes, it works with Schematron (as long as a Java-implemented XSLT2 processor is being used), see for example http://github.com/gimsieke/letex-xhtml-tables
Gerrit
On 14.02.2010 13:55, Stefan Krause wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello Gerrit,
if java is accessible in your environment, you can use the following function:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:java-file="java:java.io.File" xmlns:java-uri="java:java.net.URI" xmlns:misc="someURI" > <xsl:function name="misc:file-exists" as="xs:boolean"> <xsl:param name="uri" as="xs:string?"/> <xsl:value-of select="java-file:exists(java-file:new(java-uri:new($uri)))"/> </xsl:function> </xsl:stylesheet>
I ended up with this solution, because it only depends on the availability of java (it works also with AltovaXML), and there was some changes in the support of saxon:last-modified/saxon:file-last-modified during the saxon revisions.
I don't know how it's fit to Schematron, but maybe you find a way.
Best regards,
Stefan
Imsieke, Gerrit, le-tex schrieb: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:
<sch:assert test="saxon:try( format-dateTime( saxon:last-modified( resolve-uri( @src, $base-uri ) ), '[Y]' ), false() )" id="ImageMissing"> Image<sch:value-of select="@src"/> must be present at its @src location. </sch:assert>
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.
Gerrit
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 9.2.0.3 on Java 1.6.0_17).
This issue must have been raised before, but unfortunately I didn't find previous threads on this matter.
Any hints appreciated.
Gerrit
-----BEGIN PGP SIGNATURE----- Comment: GnuPT v3.6.6 Comment: Download: http://www.gnupt.de Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkt38r8ACgkQ9H2ejphQ4SF9fACeKVWZ3ryIl0krfTSFEYbP1ZZX P50AniMjNo4q6012zddFhIQ72V5zxYG0 =gPYN -----END PGP SIGNATURE-----
-- 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: Testing the existence, Stefan Krause | Thread | [xsl] context (size) when evaluatin, Martin Honnen |
Re: [xsl] global language parameter, G. Ken Holman | Date | [xsl] Can I predict the build order, Kevin Brown |
Month |