<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dir="http://apache.org/cocoon/directory/2.0">
	<xsl:param name="startID"/>
	<xsl:param name="stopID"/>

	<xsl:template match="/">
		<xsl:element name="IDlist">
			<xsl:choose>
				<xsl:when test="$startID=''">
					<xsl:choose>
						<xsl:when test="$stopID=''">
							<xsl:apply-templates select="//dir:file[contains(@name,'.xml') and contains(@name,'K')]">
								<!-- xsl:sort order="descending" select="@name"/ -->
							</xsl:apply-templates>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates select="//dir:file[contains(@name,'.xml') and contains(@name,'K') and not( number(substring-after(substring-before(@name,'.xml'),'K'))>number($stopID) )]">
								<!-- xsl:sort order="descending" select="@name"/ -->
							</xsl:apply-templates>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<xsl:choose>
						<xsl:when test="$stopID=''">
							<xsl:apply-templates select="//dir:file[contains(@name,'.xml') and contains(@name,'K') and not ( number(substring-after(substring-before(@name,'.xml'),'K')) &lt; number($startID))]">
								<!-- xsl:sort order="descending" select="@name"/ -->
							</xsl:apply-templates>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates select="//dir:file[contains(@name,'.xml') and contains(@name,'K') and not( number(substring-after(substring-before(@name,'.xml'),'K')) &lt; number($startID) ) and not( number(substring-after(substring-before(@name,'.xml'),'K'))>number($stopID) )]">
								<!-- xsl:sort order="descending" select="@name"/ -->
							</xsl:apply-templates>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:element>
	</xsl:template>
	<xsl:template match="dir:file">
		<ID>
			<!-- xsl:value-of select="substring-before(substring-after(@name, 'K'),'.xml')"/ -->
			<xsl:value-of select="substring-before(@name,'.xml')"/>
		</ID>
	</xsl:template>
</xsl:stylesheet>
