[xsl] Java list extension

Subject: [xsl] Java list extension
From: Geurt Lagemaat <lagemaat@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 05 Jul 2011 01:24:58 +0200
Dear List,

I'm within some serious project boundrys so I'm left with one and only
option: copying files with XSLT. Now I solved that a while ago (with
help of this list), like:

<xsl:value-of select="java-fc:transferTo($FileChannelIn, 0, $size,
$FileChannelOut), java-fc:close($FileChannelIn),
java-fc:close($FileChannelOut)"/>

Now I need a way to discover the contents of a directory (files and
other directorys). So far I have:

<xsl:variable name="directory" select="java-file:new($sourcefileURI)"/>
<xsl:variable name="tst">  <!-- as="class:java.io.File" -->
<xsl:value-of select="for $file in java-file:list($directory) return
concat($sourcefileURI,$file)"/>
</xsl:variable>

(xmlns:java-file="java.io.File")

This works when I put $tst to output:

<xsl:variable name="fftest" select="tokenize($tst,' ')"/>
<xsl:for-each select="$fftest">

Problem is that I converted it to a ordinary string and i do need the
collection because I want to find out if a entry is a directory or not,
like:

<xsl:value-of select="java-file:isDirectory($....)"/>

Questions:

How do I type the $tst var so it behaves like a Java collection and I
can use it like a Java File collection. What I want is something like:

<xsl:variable name="dirContents">  <!-- as="class:java.io.File" ??? -->
<xsl:value-of select="for $file in java-file:list($directory) return
concat($sourcefileURI,$file)"/>
</xsl:variable>


<xsl:for-each select=$dirContents>


<xsl:choose>

<xsl:when test=java-file:isDirectory(.)>

do this

</xsl:when>

<xsl:otherwise>

just copy the file

</xsl:otherwise>

</xsl:choose>

</xsl:for-each>

Thanks.

Regards, Geurt Lagemaat

Current Thread