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 / xmldb2samples.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  4.6 KB  |  147 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.  
  18. <!--+
  19.     | Simple XMLDB browser
  20.     | CVS $Id: xmldb2samples.xsl,v 1.2 2004/03/06 02:26:11 antonio Exp $
  21.     +-->
  22.  
  23. <xsl:stylesheet version="1.0"
  24.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  25.                 xmlns:x="http://apache.org/cocoon/xmldb/1.0">
  26.  
  27.   <xsl:import href="context://stylesheets/system/xml2html.xslt"/>
  28.  
  29.   <xsl:template match="/">
  30.     <xsl:choose>
  31.       <xsl:when test="x:collections">
  32.         <xsl:apply-templates/>
  33.       </xsl:when>
  34.       <xsl:when test="x:results">
  35.         <xsl:apply-templates/>
  36.       </xsl:when>
  37.       <xsl:otherwise>
  38.         <xsl:call-template name="resource"/>
  39.       </xsl:otherwise>
  40.     </xsl:choose>
  41.   </xsl:template>
  42.  
  43.   <xsl:template match="x:collections">
  44.     <samples name="XMLDB Browser" xmlns:xlink="http://www.w3.org/1999/xlink">
  45.       <group name="Back">
  46.         <sample name="Back" href="..">to parent collection</sample>
  47.       </group>
  48.       <group name="Collection">
  49.         <note>
  50.           You are browsing collection <strong><xsl:value-of select="@base"/></strong>.
  51.           <br/>
  52.           This collection has <strong><xsl:value-of select="@collections"/></strong>
  53.           nested collections and it stores <strong><xsl:value-of select="@resources"/></strong>
  54.           resources.
  55.         </note>
  56.       </group>
  57.       <group name="Collections">
  58.         <xsl:if test="not(x:collection)">
  59.           <note>Collection does not have nested collections</note>
  60.         </xsl:if>
  61.         <xsl:apply-templates select="x:collection"/>
  62.       </group>
  63.       <group name="Resources">
  64.         <xsl:if test="not(x:resource)">
  65.           <note>Collection does not have resources</note>
  66.         </xsl:if>
  67.         <xsl:apply-templates select="x:resource"/>
  68.       </group>
  69.       <group name="Query">
  70.         <form method="get" action="{@name}">
  71.           <input name="xpath"/>
  72.           <input type="submit"/>
  73.         </form>
  74.       </group>
  75.     </samples>
  76.   </xsl:template>
  77.  
  78.   <xsl:template name="resource">
  79.     <samples name="XMLDB Browser" xmlns:xlink="http://www.w3.org/1999/xlink">
  80.       <group name="Back">
  81.         <sample name="Back" href=".">to parent collection</sample>
  82.       </group>
  83.       <group name="Resource">
  84.         <note>
  85.           You are viewing resource.
  86.         </note>
  87.       </group>
  88.       <group name="Resource Content">
  89.         <xsl:call-template name="head"/>
  90.         <xsl:apply-templates/>
  91.       </group>
  92.       <group name="Query">
  93.         <form method="get" action="?">
  94.           <input name="xpath"/>
  95.           <input type="submit"/>
  96.         </form>
  97.       </group>
  98.     </samples>
  99.   </xsl:template>
  100.  
  101.   <xsl:template match="x:results">
  102.     <samples name="XMLDB Browser" xmlns:xlink="http://www.w3.org/1999/xlink">
  103.       <group name="Back">
  104.         <sample name="Back" href="?">to collection/resource</sample>
  105.       </group>
  106.       <group name="Query">
  107.         <note>
  108.           You are viewing query results.
  109.           <br/>
  110.           Query was <strong><xsl:value-of select="@query"/></strong>
  111.           and it produced <strong><xsl:value-of select="@resources"/></strong>
  112.           results.
  113.         </note>
  114.       </group>
  115.       <group name="Results">
  116.         <xsl:call-template name="head"/>
  117.         <xsl:if test="@resources = 0">
  118.           <note>Query produced no results</note>
  119.         </xsl:if>
  120.         <xsl:apply-templates select="x:result"/>
  121.       </group>
  122.       <group name="Query">
  123.         <form method="get" action="{@name}">
  124.           <input name="xpath"/>
  125.           <input type="submit"/>
  126.         </form>
  127.       </group>
  128.     </samples>
  129.   </xsl:template>
  130.  
  131.   <xsl:template match="x:collection">
  132.     <sample name="{@name}" href="{@name}/">Browse Collection</sample>
  133.   </xsl:template>
  134.  
  135.   <xsl:template match="x:resource">
  136.     <sample name="{@name}" href="{@name}">View Resource</sample>
  137.   </xsl:template>
  138.  
  139.   <xsl:template match="x:result">
  140.     <p>
  141.       Result <strong><xsl:value-of select="position()"/></strong>, from the document
  142.       <strong><xsl:value-of select="@docid"/></strong>:
  143.     </p>
  144.     <xsl:apply-templates/>
  145.   </xsl:template>
  146. </xsl:stylesheet>
  147.