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

[xsl] Copy a binary file using Java extension


Subject: [xsl] Copy a binary file using Java extension
From: Geurt Lagemaat <lagemaat@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 06 Nov 2010 17:12:26 +0100

Hi,

I'm trying to copy a binary file using XSLT (2) (Saxon8) with java
extensions.

I know I can use xmlns:fos="java.io.FileOutputStream",
xmlns:file="java.io.File" to write functions like

<xsl:variable name="testfile" select="file:new(resolve-uri($filename))"/>
<xsl:choose>
<xsl:when test="not(file:exists($testfile))">
<xsl:value-of select="false()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="true()"/>
</xsl:otherwise>
</xsl:choose>

and

<xsl:variable name="fos" select="fos:new($ImgFilePath)"/>
<!-- de base64 content as string -->
<xsl:variable name="b64" select="b64:new(string(image/binair))"/>
<!-- write to filestream while converting base64 to binary -->
<xsl:value-of select="fos:write($fos, b64:getBinaryValue($b64))"/>
<xsl:value-of select="fos:close($fos)"/>

But I cant rework these fragments to a functional copyFile. Problem is
there is no simple binary fileCopy available without opening streams
etc. So the most obvious way is to work with the fos, but how to read a
binary file in a way that fos can write it?

Another idea was to use the java.io.File  renameTo , but I cant
translate the Java code is a XSLT way to do it.

Anyone has a idea? I don't want to use a Java class because the target
environment is a sort of restricted area with no access to classpaths
etc (I'm suspecting trouble with the classpath if I want to use a Java
class to get this functionality).

Regards,

Geurt Lagemaat


Current Thread
Keywords