You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2004/04/02 22:40:57 UTC

cvs commit: cocoon-2.1/src/webapp/samples/blocks directory2xsamples.xsl sitemap.xmap gump2samples.xsl

joerg       2004/04/02 12:40:57

  Modified:    src/webapp/samples/blocks sitemap.xmap gump2samples.xsl
  Added:       src/webapp/samples/blocks directory2xsamples.xsl
  Log:
  refactored gump2samples:
  - don't use document() for possibly non-existing files, the behaviour is processor-dependent
  - don't show groups if they do not have samples
  
  Revision  Changes    Path
  1.2       +13 -2     cocoon-2.1/src/webapp/samples/blocks/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/blocks/sitemap.xmap,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- sitemap.xmap	1 Apr 2004 19:05:42 -0000	1.1
  +++ sitemap.xmap	2 Apr 2004 20:40:57 -0000	1.2
  @@ -42,12 +42,23 @@
     <map:pipelines>
       <map:pipeline>
         <map:match pattern="">
  -        <map:generate src="gump.xml"/>
  +        <map:aggregate element="root">
  +          <map:part src="gump.xml" element="gump"/>
  +          <map:part src="cocoon:/xsamples"/>
  +        </map:aggregate>
           <map:transform src="gump2samples.xsl"/>
           <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
             <map:parameter name="contextPath" value="{request:contextPath}"/>
           </map:transform>
           <map:serialize/>
  +      </map:match>
  +
  +      <map:match pattern="xsamples">
  +      	<map:generate type="directory" src=".">
  +      	  <map:parameter name="depth" value="2"/>
  +      	</map:generate>
  +      	<map:transform src="directory2xsamples.xsl"/>
  +      	<map:serialize tpye="xml"/>
         </map:match>
   
         <!-- ======================== Automount =============================== -->
  
  
  
  1.3       +26 -25    cocoon-2.1/src/webapp/samples/blocks/gump2samples.xsl
  
  Index: gump2samples.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/blocks/gump2samples.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- gump2samples.xsl	2 Apr 2004 12:58:01 -0000	1.2
  +++ gump2samples.xsl	2 Apr 2004 20:40:57 -0000	1.3
  @@ -23,51 +23,57 @@
   
   <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   
  -  <xsl:template match="/">
  +  <xsl:template match="/root">
       <samples name="Blocks Samples">
         <group name="Back">
  -        <sample href=".." name="Back">
  +        <sample href="./" name="Back">
             Back to the samples home page.
           </sample>
         </group>
  +      <xsl:variable name="xsamples" select="xsamples/sample"/>
  +      <xsl:variable name="blocks" select="gump/module/project[starts-with(@name, 'cocoon-block-')]"/>
  +      <xsl:variable name="includedBlocks" select="$blocks[@name = $xsamples/@name]"/>
  +      <xsl:variable name="excludedBlocks" select="$blocks[not(@name = $xsamples/@name)]"/>
  +      <xsl:variable name="includedStableBlocks" select="$includedBlocks[@status = 'stable']"/>
  +      <xsl:variable name="includedUnstableBlocks" select="$includedBlocks[@status = 'unstable']"/>
  +      <xsl:variable name="includedDeprecatedBlocks" select="$includedBlocks[@status = 'deprecated']"/>
   
  -      <group name="Stable Blocks">
  -        <xsl:apply-templates select="module/project[starts-with(@name, 'cocoon-block-')][@status = 'stable']">
  -          <xsl:sort select="@name"/>
  -        </xsl:apply-templates>
  -      </group>
  +      <xsl:if test="$includedStableBlocks">
  +        <group name="Stable Blocks">
  +          <xsl:apply-templates select="$includedStableBlocks">
  +            <xsl:sort select="@name"/>
  +          </xsl:apply-templates>
  +        </group>
  +      </xsl:if>
   
  -      <xsl:variable name="unstable" select="module/project[starts-with(@name, 'cocoon-block-')][@status = 'unstable']"/>
  -      <xsl:if test="$unstable">
  +      <xsl:if test="$includedUnstableBlocks">
           <group name="Unstable Blocks">
             <note>
               Blocks below are subject to change without notice!
             </note>
  -          <xsl:apply-templates select="$unstable">
  +          <xsl:apply-templates select="$includedUnstableBlocks">
               <xsl:sort select="@name"/>
             </xsl:apply-templates>
           </group>
         </xsl:if>
   
  -      <xsl:variable name="deprecated" select="module/project[starts-with(@name, 'cocoon-block-')][@status = 'deprecated']"/>
  -      <xsl:if test="$deprecated">
  +      <xsl:if test="$includedDeprecatedBlocks">
           <group name="Deprecated Blocks">
             <note>
               Blocks below will be removed in the future!
             </note>
  -          <xsl:apply-templates select="$deprecated">
  +          <xsl:apply-templates select="$includedDeprecatedBlocks">
               <xsl:sort select="@name"/>
             </xsl:apply-templates>
           </group>
         </xsl:if>
   
  -      <xsl:variable name="excluded" select="module/project[starts-with(@name, 'cocoon-block-')][not(document(concat(substring-after(@name,'cocoon-block-'), '/', substring-after(@name,'cocoon-block-'),'.xsamples')))]"/>
  -      <xsl:if test="$excluded">
  +      <xsl:if test="$excludedBlocks">
           <group name="Excluded Blocks">
             <note>
  -            Blocks below are either excluded from the build or has no samples.
  +            Blocks below are either excluded from the build or have no samples.
             </note>
  -          <xsl:apply-templates select="$excluded" mode="excluded">
  +          <xsl:apply-templates select="$excludedBlocks" mode="excluded">
               <xsl:sort select="@name"/>
             </xsl:apply-templates>
           </group>
  @@ -78,14 +84,9 @@
     <xsl:template match="project">
       <xsl:variable name="name" select="substring-after(@name,'cocoon-block-')"/>
       <xsl:variable name="sample" select="document(concat($name, '/', $name,'.xsamples'))/xsamples/group/sample"/>
  -    <xsl:choose>
  -      <xsl:when test="$sample">
  -        <xsl:apply-templates select="$sample"/>
  -      </xsl:when>
  -      <xsl:otherwise>
  -        <!-- Output nothing for excluded blocks -->
  -      </xsl:otherwise>
  -    </xsl:choose>
  +    <xsl:if test="$sample">
  +      <xsl:apply-templates select="$sample"/>
  +    </xsl:if>
     </xsl:template>
   
     <xsl:template match="project" mode="excluded">
  
  
  
  1.1                  cocoon-2.1/src/webapp/samples/blocks/directory2xsamples.xsl
  
  Index: directory2xsamples.xsl
  ===================================================================
  <?xml version="1.0"?>
  <!--
    Copyright 1999-2004 The Apache Software Foundation
  
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
  
        http://www.apache.org/licenses/LICENSE-2.0
  
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  -->
  
  <!-- CVS $Id: directory2xsamples.xsl,v 1.1 2004/04/02 20:40:57 joerg Exp $ -->
  
  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:dir="http://apache.org/cocoon/directory/2.0"
                  exclude-result-prefixes="dir">
  
    <xsl:template match="/dir:directory">
      <xsamples>
        <xsl:apply-templates select="*"/>
      </xsamples>
    </xsl:template>
  
    <xsl:template match="dir:directory">
      <xsl:apply-templates select="*"/>
    </xsl:template>
  
    <xsl:template match="dir:file">
      <xsl:if test="substring-before(@name, '.xsamples')">
        <sample name="cocoon-block-{substring-before(@name, '.xsamples')}"/>
      </xsl:if>
    </xsl:template>
  
  </xsl:stylesheet>