1 <?xml version="1.0" encoding="utf-8"?> 2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:D="DAV:" 4 version="1.0"> 5 6 <xsl:param name="path"/> 7 <xsl:param name="start"/> 8 9 <xsl:template match="database"> 10 <D:multistatus> 11 <xsl:choose> 12 <!-- Specified part of the database. --> 13 <xsl:when test="$start != ''"> 14 <!-- Emit the container. --> 15 <xsl:call-template name="resource"> 16 <xsl:with-param name="element" select="//*[local-name() = $start][1]"/> 17 <xsl:with-param name="container">true</xsl:with-param> 18 </xsl:call-template> 19 <!-- Emit all resources. --> 20 <xsl:for-each select="//*[local-name() = $start]/*"> 21 <xsl:call-template name="resource"> 22 <xsl:with-param name="element" select="."/> 23 </xsl:call-template> 24 </xsl:for-each> 25 </xsl:when> 26 <!-- Top level. --> 27 <xsl:otherwise> 28 <!-- Emit the container. --> 29 <xsl:call-template name="resource"> 30 <xsl:with-param name="element" select="."/> 31 <xsl:with-param name="container">true</xsl:with-param> 32 </xsl:call-template> 33 <!-- Emit all resources. --> 34 <xsl:for-each select="*"> 35 <xsl:call-template name="resource"> 36 <xsl:with-param name="element" select="."/> 37 </xsl:call-template> 38 </xsl:for-each> 39 </xsl:otherwise> 40 </xsl:choose> 41 </D:multistatus> 42 </xsl:template> 43 44 <xsl:template name="resource"> 45 <xsl:param name="element"/> 46 <xsl:param name="container"/> 47 <D:response> 48 <xsl:choose> 49 <xsl:when test="$container != ''"> 50 <D:href><xsl:value-of select="$path"/>/</D:href> 51 </xsl:when> 52 <xsl:otherwise> 53 <D:href><xsl:value-of select="$path"/>/<xsl:value-of select="local-name()"/><xsl:if test="count($element/*) != 0">/</xsl:if></D:href> 54 </xsl:otherwise> 55 </xsl:choose> 56 <D:propstat> 57 <D:prop> 58 <D:creationdate>2004-10-13T23:57:00Z</D:creationdate> 59 <xsl:choose> 60 <xsl:when test="$container != ''"> 61 <D:displayname><xsl:value-of select="$path"/></D:displayname> 62 </xsl:when> 63 <xsl:otherwise> 64 <D:displayname><xsl:value-of select="local-name()"/></D:displayname> 65 </xsl:otherwise> 66 </xsl:choose> 67 <D:resourcetype> 68 <xsl:if test="count($element/*) != 0"> 69 <D:collection/> 70 </xsl:if> 71 </D:resourcetype> 72 <xsl:if test="count($element/*) = 0"> 73 <D:getcontenttype>text/html</D:getcontenttype> 74 </xsl:if> 75 </D:prop> 76 <D:status>HTTP/1.1 200 OK</D:status> 77 </D:propstat> 78 </D:response> 79 </xsl:template> 80 81 </xsl:stylesheet>