diff options
author | Adrian Kummerlaender | 2014-12-07 17:13:26 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2014-12-07 17:13:26 +0100 |
commit | 26c0da85cef1915c06661c913c4f2b5fb695a39f (patch) | |
tree | e3d16822c3c1ad325f850c1fac6962c61b35f5af /src/steps | |
parent | 6a71a56fec2d0dc6465a1e24b8c8d24d629148f5 (diff) | |
download | StaticXSLT-26c0da85cef1915c06661c913c4f2b5fb695a39f.tar StaticXSLT-26c0da85cef1915c06661c913c4f2b5fb695a39f.tar.gz StaticXSLT-26c0da85cef1915c06661c913c4f2b5fb695a39f.tar.bz2 StaticXSLT-26c0da85cef1915c06661c913c4f2b5fb695a39f.tar.lz StaticXSLT-26c0da85cef1915c06661c913c4f2b5fb695a39f.tar.xz StaticXSLT-26c0da85cef1915c06661c913c4f2b5fb695a39f.tar.zst StaticXSLT-26c0da85cef1915c06661c913c4f2b5fb695a39f.zip |
Replaced recursive call based directory listing with template application
* using `apply-templates` with a call to `read-directory` as its `select` attribute is more straight forward
* additionally it reduces code overhead and eliminates custom flow control
** i.e. its the superior way of traversing directories
Diffstat (limited to 'src/steps')
-rw-r--r-- | src/steps/list.xsl | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/steps/list.xsl b/src/steps/list.xsl index c70a6bf..40dee98 100644 --- a/src/steps/list.xsl +++ b/src/steps/list.xsl @@ -15,34 +15,23 @@ <xsl:include href="../utility/datasource.xsl"/> -<xsl:template name="list"> - <xsl:param name="base"/> +<xsl:template match="entry[@type != 'directory']"> + <file name="{./name}" extension="{./extension}"> + <xsl:copy-of select="full"/> + </file> +</xsl:template> - <xsl:for-each select="InputXSLT:read-directory($base)/entry"> - <xsl:choose> - <xsl:when test="@type = 'directory'"> - <directory name="{./name}"> - <xsl:call-template name="list"> - <xsl:with-param name="base" select="./full"/> - </xsl:call-template> - </directory> - </xsl:when> - <xsl:otherwise> - <file name="{./name}" extension="{./extension}"> - <xsl:copy-of select="full"/> - </file> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> +<xsl:template match="entry[@type = 'directory']"> + <directory name="{./name}"> + <xsl:apply-templates select="InputXSLT:read-directory(./full)"/> + </directory> </xsl:template> <xsl:template match="datasource"> <xsl:copy-of select="meta"/> <source> - <xsl:call-template name="list"> - <xsl:with-param name="base" select="meta/source"/> - </xsl:call-template> + <xsl:apply-templates select="InputXSLT:read-directory(meta/source)/entry"/> </source> </xsl:template> |