<?xml version="1.0"?>
<!-- _______________________________________________________ -->
<!-- check if a certain subdoc of a main FLWB doc is present at website  -->
<!-- example 50K0025004.pdf                                                                       -->
<!-- _______________________________________________________ -->
<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="dossierID"/>
	<xsl:param name="legislat"/>
	<xsl:param name="nr"/>
	<xsl:variable name="filepath" select="'/FLWB/pdf/'"/>
	<xsl:variable name="filename" select="concat(concat(concat(concat($legislat,'K'),$dossierID),$nr),'.pdf')"/>	
	<xsl:template match="/">
		<PDFDOC>
			<xsl:variable name="XML_dircontent" select="document( concat( concat( concat( concat('cocoon:/FLWB/', $legislat),'/'),$dossierID),'.pdf'))"/>			
			<xsl:choose>
				<xsl:when test="$XML_dircontent//dir:file[@name=$filename]">
						<xsl:apply-templates select="$XML_dircontent//dir:file[@name=$filename]">
						</xsl:apply-templates>
				</xsl:when>
				<xsl:otherwise>
					<DOCLINK>NO-PDF</DOCLINK>
					<DOCDATE/>
				</xsl:otherwise>
			</xsl:choose>
		</PDFDOC>
	</xsl:template>
	
<xsl:template match="dir:file">
<DOCLINK><xsl:value-of select="$filepath"/><xsl:value-of select="$legislat"/>/<xsl:value-of select="$dossierID"/>/<xsl:value-of select="$filename"/></DOCLINK>
<DOCDATE>
	<xsl:value-of select="@date"/>
</DOCDATE>
</xsl:template>	

</xsl:stylesheet>
