aboutsummaryrefslogtreecommitdiff
path: root/list.xsl
blob: 7eba25542848f49f6df0a25c483fc88d137b4b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:InputXSLT="function.inputxslt.application"
	exclude-result-prefixes="InputXSLT"
>

<xsl:output
	method="xml"
	omit-xml-declaration="yes"
	encoding="UTF-8"
	indent="no"
/>

<xsl:template name="list">
	<xsl:param name="base"/>

	<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:otherwise>
		</xsl:choose>
	</xsl:for-each>
</xsl:template>

<xsl:template match="datasource">
	<source>
		<xsl:call-template name="list">
			<xsl:with-param name="base" select="."/>
		</xsl:call-template>
	</source>
</xsl:template>

</xsl:stylesheet>