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

Re: most efficient flat file listing to hierarchical

Subject: Re: most efficient flat file listing to hierarchical
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 11 Jan 2007 10:46:48 +0000
Re:  most efficient flat file listing to hierarchical
On 1/11/07, James Fuller <jim.fuller@xxxxxxxxxxxxxx> 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>

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.