[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Copy a binary file using Java extension

Subject: Copy a binary file using Java extension
From: Geurt Lagemaat <lagemaat@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 06 Nov 2010 17:12:26 +0100
 Copy a binary file using Java extension
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.