xsl-list
[Top] [All Lists]

[xsl] Copy a binary file using Java extension

2010-11-06 11:12:41
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>