On 1/11/07, James Fuller <jim(_dot_)fuller(_at_)ruminate(_dot_)co(_dot_)uk>
wrote:
nice....the recursion route seems to be the general approach, just about
scratched it out myself (w/o the part bit)
Mine can be tidied a bit to get rid of two of the tokenize()'s - first
by using current-grouping-key() for $part as it evaluates to the same
thing (bit slow this morning) and then using Georges neat way of
passing current-group() to further process the group:
<xsl:template name="process">
<xsl:param name="depth" as="xs:integer"/>
<xsl:param name="seq"/>
<xsl:for-each-group select="$seq" group-by="tokenize(., '/')[$depth]">
<xsl:variable name="part" select="current-grouping-key()"/>
<xsl:choose>
<xsl:when test="contains($part, '.')">
<file name="{$part}"/>
</xsl:when>
<xsl:otherwise>
<dir name="{$part}">
<xsl:call-template name="process">
<xsl:with-param name="depth"
select="$depth + 1"/>
<xsl:with-param name="seq"
select="current-group()"/>
</xsl:call-template>
</dir>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>
--~------------------------------------------------------------------
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>
--~--