home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / collection2propfind.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  3.8 KB  |  108 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <xsl:stylesheet version="1.0"
  18.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  19.   xmlns:collection="http://apache.org/cocoon/collection/1.0"
  20.   xmlns:D="DAV:">
  21.   
  22.   <xsl:param name="requestURI"></xsl:param>
  23.   <xsl:variable name="adjustedRequestURI">
  24.     <xsl:choose>
  25.       <xsl:when test="substring($requestURI, string-length($requestURI),1)='/'"><xsl:value-of select="$requestURI"/></xsl:when>
  26.       <xsl:otherwise><xsl:value-of select="$requestURI"/>/</xsl:otherwise>
  27.     </xsl:choose>
  28.   </xsl:variable>
  29.   
  30.   <xsl:template match="/">
  31.     <D:multistatus>
  32.       <xsl:apply-templates />
  33.     </D:multistatus>
  34.   </xsl:template>
  35.   
  36.   <xsl:template match="/collection:collection">
  37.     <xsl:call-template name="collection">
  38.       <xsl:with-param name="href" select="$adjustedRequestURI" />
  39.     </xsl:call-template>
  40.   </xsl:template>
  41.   
  42.   <xsl:template match="collection:collection">
  43.     <xsl:param name="parent-href" />
  44.     <xsl:call-template name="collection">
  45.       <xsl:with-param name="href">
  46.         <xsl:value-of select="$parent-href" /><xsl:value-of select="@name"/>
  47.       </xsl:with-param>
  48.     </xsl:call-template>
  49.   </xsl:template>
  50.   
  51.   <xsl:template match="/collection:resource">
  52.     <xsl:call-template name="resource">
  53.       <xsl:with-param name="href" select="$adjustedRequestURI" />
  54.     </xsl:call-template>
  55.   </xsl:template>
  56.   
  57.   <xsl:template match="collection:resource">
  58.     <xsl:param name="parent-href" />
  59.     <xsl:call-template name="resource">
  60.       <xsl:with-param name="href">
  61.         <xsl:value-of select="$parent-href" /><xsl:value-of select="@name"/>
  62.       </xsl:with-param>
  63.     </xsl:call-template>
  64.   </xsl:template>
  65.   
  66.   <xsl:template name="collection">
  67.     <xsl:param name="href" />
  68.     <D:response>
  69.       <D:href><xsl:value-of select="$href"/></D:href>
  70.       <D:propstat>
  71.         <D:prop>
  72.           <D:displayname><xsl:value-of select="@name"/></D:displayname>
  73.           <D:getlastmodified><xsl:value-of select="@date"/></D:getlastmodified>
  74.           <D:creationdate />
  75.           <D:resourcetype><D:collection/></D:resourcetype>
  76.           <D:getcontenttype>httpd/unix-directory</D:getcontenttype>
  77.           <D:contentlength>0</D:contentlength>
  78.           <xsl:copy-of select="collection:properties/child::node()" />
  79.         </D:prop>
  80.         <D:status>HTTP/1.1 200 OK</D:status>
  81.       </D:propstat>
  82.     </D:response>
  83.     <xsl:apply-templates>
  84.       <xsl:with-param name="parent-href" select="$href" />
  85.     </xsl:apply-templates>
  86.   </xsl:template>
  87.     
  88.   <xsl:template name="resource">
  89.     <xsl:param name="href" />
  90.     <D:response>
  91.       <D:href><xsl:value-of select="$href"/></D:href>
  92.       <D:propstat>
  93.         <D:prop>
  94.           <D:displayname><xsl:value-of select="@name"/></D:displayname>
  95.           <D:getlastmodified><xsl:value-of select="@date"/></D:getlastmodified>
  96.           <D:creationdate />
  97.           <D:getcontenttype><xsl:value-of select="@mimeType"/></D:getcontenttype>
  98.           <D:getcontentlength><xsl:value-of select="@size" /></D:getcontentlength>
  99.           <D:resourcetype />
  100.           <xsl:copy-of select="collection:properties/child::node()" />
  101.         </D:prop>
  102.         <D:status>HTTP/1.1 200 OK</D:status>
  103.       </D:propstat>
  104.     </D:response>
  105.   </xsl:template>
  106.  
  107. </xsl:stylesheet>
  108.