You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/11/02 11:20:18 UTC

svn commit: r591293 - in /lenya/sandbox/modules/forrest: ./ config/cocoon-xconf/ java/src/org/apache/lenya/modules/forrest/ java/test/org/apache/lenya/modules/forrest/ resources/samples/ xslt/

Author: andreas
Date: Fri Nov  2 03:20:16 2007
New Revision: 591293

URL: http://svn.apache.org/viewvc?rev=591293&view=rev
Log:
Added support for ToC and FAQ

Added:
    lenya/sandbox/modules/forrest/config/cocoon-xconf/resourcetype-forrestFaq20.xconf
    lenya/sandbox/modules/forrest/resources/samples/forrestFaq20.xml
    lenya/sandbox/modules/forrest/xslt/copyover.xsl
    lenya/sandbox/modules/forrest/xslt/forrestFaq202document.xsl
    lenya/sandbox/modules/forrest/xslt/toc.xsl
Modified:
    lenya/sandbox/modules/forrest/java/src/org/apache/lenya/modules/forrest/Importer.java
    lenya/sandbox/modules/forrest/java/test/org/apache/lenya/modules/forrest/ImportTest.java
    lenya/sandbox/modules/forrest/sitemap.xmap
    lenya/sandbox/modules/forrest/xslt/forrestDocument202xhtml.xsl

Added: lenya/sandbox/modules/forrest/config/cocoon-xconf/resourcetype-forrestFaq20.xconf
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/config/cocoon-xconf/resourcetype-forrestFaq20.xconf?rev=591293&view=auto
==============================================================================
--- lenya/sandbox/modules/forrest/config/cocoon-xconf/resourcetype-forrestFaq20.xconf (added)
+++ lenya/sandbox/modules/forrest/config/cocoon-xconf/resourcetype-forrestFaq20.xconf Fri Nov  2 03:20:16 2007
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<!-- $Id: doctypes.xconf 164635 2005-04-25 20:01:43Z tschlabach $ -->
+
+<xconf xpath="/cocoon/resource-types" unless="/cocoon/resource-types/component-instance[@name = 'forrestFaq20']">
+  
+  <component-instance name="forrestFaq20"
+    logger="lenya.resourcetypes.forrestFaq20"
+    class="org.apache.lenya.cms.publication.ResourceTypeImpl">
+    
+    <!--
+    <schema 
+      namespace="http://relaxng.org/ns/structure/0.9"
+      uri="fallback://lenya/modules/forrest/resources/schemas/faq-v20.rng"/>
+    -->
+    
+    <!-- Default time in seconds until the resource-type has expired -->  
+    <expires seconds="3600" />
+    
+    <sample 
+      mime-type="application/xml" 
+      uri="fallback://lenya/modules/forrest/resources/samples/forrestFaq20.xml"
+    />
+    
+    <link-attribute xpath="//*/@href"/>
+    <link-attribute xpath="//*/@src"/>
+    <format name="xhtml" uri="cocoon://modules/forrest/xhtml.xml"/>
+    <format name="webdavGET" uri="cocoon://modules/forrest/davget.xml"/>
+    <format name="luceneIndex" uri="cocoon://modules/forrest/lucene-index"/>
+    <!-- "xslt-clean" format is used by webDAV (and other editors?) to "clean" xml content before it is validated/saved --> 
+    <format name="xslt-clean" uri="fallback://lenya/modules/forrest/xslt/clean-xhtml.xsl"/>
+    <format name="icon" uri="cocoon://modules/forrest/icon"/>
+    
+  </component-instance>
+  
+</xconf>

Modified: lenya/sandbox/modules/forrest/java/src/org/apache/lenya/modules/forrest/Importer.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/java/src/org/apache/lenya/modules/forrest/Importer.java?rev=591293&r1=591292&r2=591293&view=diff
==============================================================================
--- lenya/sandbox/modules/forrest/java/src/org/apache/lenya/modules/forrest/Importer.java (original)
+++ lenya/sandbox/modules/forrest/java/src/org/apache/lenya/modules/forrest/Importer.java Fri Nov  2 03:20:16 2007
@@ -51,6 +51,7 @@
 
 public class Importer extends AbstractLogEnabled {
 
+    protected static final String ELEMENT_FAQS = "faqs";
     private ServiceManager manager;
 
     public Importer(ServiceManager manager, Logger logger) {
@@ -64,6 +65,7 @@
     protected static final String ATTR_HREF = "href";
     protected static final String ATTR_LABEL = "label";
     protected static final Object RESOURCE_TYPE_NAME_FORREST = "forrestDocument20";
+    protected static final Object RESOURCE_TYPE_NAME_FAQ = "forrestFaq20";
     protected static final Object RESOURCE_TYPE_NAME_MEDIA = "resource";
     protected static final String LANGUAGE = "en";
     protected static final String EXTENSION = "xml";
@@ -84,16 +86,19 @@
         ServiceSelector selector = null;
         ResourceType forrestResourceType = null;
         ResourceType mediaResourceType = null;
+        ResourceType faqResourceType = null;
         DocumentManager docMgr = null;
         try {
             selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
             forrestResourceType = (ResourceType) selector.select(RESOURCE_TYPE_NAME_FORREST);
+            faqResourceType = (ResourceType) selector.select(RESOURCE_TYPE_NAME_FAQ);
             mediaResourceType = (ResourceType) selector.select(RESOURCE_TYPE_NAME_MEDIA);
             docMgr = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
 
             ImportInfo info = new ImportInfo();
             info.area = area;
             info.forrestResourceType = forrestResourceType;
+            info.faqResourceType = faqResourceType;
             info.mediaResourceType = mediaResourceType;
             info.helper = helper;
             info.docMgr = docMgr;
@@ -113,6 +118,9 @@
                 if (forrestResourceType != null) {
                     selector.release(forrestResourceType);
                 }
+                if (faqResourceType != null) {
+                    selector.release(faqResourceType);
+                }
                 if (mediaResourceType != null) {
                     selector.release(mediaResourceType);
                 }
@@ -147,12 +155,10 @@
         if (href.startsWith("http:")) {
             info.links.put(linkName, href);
             /*
-            String path = concatPath(basePath, nodeName);
-            SiteNode node = info.area.getSite().add(path);
-            node.setHref(href);
-            */
-        }
-        else if (sourceUri.endsWith(".png") || sourceUri.endsWith(".gif")) {
+             * String path = concatPath(basePath, nodeName); SiteNode node =
+             * info.area.getSite().add(path); node.setHref(href);
+             */
+        } else if (sourceUri.endsWith(".png") || sourceUri.endsWith(".gif")) {
             createDocument(info, info.mediaResourceType, sourceUri, basePath, nodeName, linkName,
                     title);
         } else {
@@ -169,8 +175,14 @@
                 createDocument(info, info.forrestResourceType,
                         getSampleUri(info.forrestResourceType), basePath, nodeName, linkName, title);
             } else {
-                createDocument(info, info.forrestResourceType, sourceUri, basePath, nodeName,
-                        linkName, title);
+                String localName = xml.getDocumentElement().getLocalName();
+                ResourceType type = null;
+                if (localName.equals(ELEMENT_FAQS)) {
+                    type = info.faqResourceType;
+                } else {
+                    type = info.forrestResourceType;
+                }
+                createDocument(info, type, sourceUri, basePath, nodeName, linkName, title);
             }
         }
 
@@ -213,7 +225,8 @@
             Link link = new Link();
             link.setUuid(doc.getUUID());
             info.links.put(linkName, link.getUri());
-            log("Created " + extension.toUpperCase() + " document (" + info.counterToString() + ") [" + path + "]");
+            log("Created " + extension.toUpperCase() + " document (" + info.counterToString()
+                    + ") [" + path + "]");
         } catch (Exception e) {
             log("A problem occured:");
             log("Path: '" + path + "'");
@@ -236,13 +249,14 @@
         protected int counter = 0;
         protected ResourceType mediaResourceType;
         protected ResourceType forrestResourceType;
+        protected ResourceType faqResourceType;
         protected DocumentManager docMgr;
         protected NamespaceHelper helper;
         protected Area area;
         protected Map links;
         protected long startTime;
         protected Calendar startCal;
-        
+
         protected static final String dateFormat = "HH:mm:ss";
 
         protected int next() {
@@ -254,7 +268,7 @@
             this.startTime = new Date().getTime();
             this.startCal = new GregorianCalendar();
         }
-        
+
         protected String counterToString() {
             int c = next();
             String count = Integer.toString(c);
@@ -273,7 +287,7 @@
             Date date = new Date(remaining);
             date.setHours(date.getHours() - 1);
             buf.append(new SimpleDateFormat(dateFormat).format(date));
-            
+
             return buf.toString();
         }
     }
@@ -288,7 +302,7 @@
                 docsToConvert.add(docs[i]);
             }
         }
-        for (Iterator i = docsToConvert.iterator(); i.hasNext(); ) {
+        for (Iterator i = docsToConvert.iterator(); i.hasNext();) {
             Document doc = (Document) i.next();
             log("Converting links (" + info.counterToString() + "): " + doc.getPath());
             org.w3c.dom.Document xml = DocumentHelper.readDocument(doc.getInputStream());

Modified: lenya/sandbox/modules/forrest/java/test/org/apache/lenya/modules/forrest/ImportTest.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/java/test/org/apache/lenya/modules/forrest/ImportTest.java?rev=591293&r1=591292&r2=591293&view=diff
==============================================================================
--- lenya/sandbox/modules/forrest/java/test/org/apache/lenya/modules/forrest/ImportTest.java (original)
+++ lenya/sandbox/modules/forrest/java/test/org/apache/lenya/modules/forrest/ImportTest.java Fri Nov  2 03:20:16 2007
@@ -18,6 +18,7 @@
 package org.apache.lenya.modules.forrest;
 
 import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.ac.impl.AbstractAccessControlTest;
 import org.apache.lenya.cms.linking.Link;
 import org.apache.lenya.cms.linking.LinkManager;
@@ -25,10 +26,13 @@
 import org.apache.lenya.cms.metadata.dublincore.DublinCore;
 import org.apache.lenya.cms.publication.Area;
 import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.ResourceType;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.xml.DocumentHelper;
 
 /**
  * Import example content into test publication.
@@ -54,7 +58,7 @@
         assertTrue(area.getSite().contains("/project-information"));
     }
     
-    public void testUpdateTitles() throws Exception {
+    public void disabled_testUpdateTitles() throws Exception {
         Session session = login("lenya");
         Publication pub = getPublication(session, PUB_ID);
         Area area = pub.getArea("authoring");
@@ -63,6 +67,36 @@
             String label = docs[i].getLink().getLabel();
             MetaData meta = docs[i].getMetaData(DublinCore.DC_NAMESPACE);
             meta.setValue(DublinCore.ELEMENT_TITLE, label);
+        }
+        session.commit();
+    }
+    
+    public void testUpdateResourceType() throws Exception {
+        Session session = login("lenya");
+        Publication pub = getPublication(session, PUB_ID);
+        Area area = pub.getArea("authoring");
+        Document[] docs = area.getDocuments();
+        ServiceSelector selector = null;
+        ResourceType faqResourceType = null;
+        try {
+            selector = (ServiceSelector) getManager().lookup(ResourceType.ROLE + "Selector");
+            faqResourceType = (ResourceType) selector.select(Importer.RESOURCE_TYPE_NAME_FAQ);
+            for (int i = 0; i < docs.length; i++) {
+                if (docs[i].getResourceType().getName().equals(Importer.RESOURCE_TYPE_NAME_FORREST)) {
+                    org.w3c.dom.Document xml = DocumentHelper.readDocument(docs[i].getInputStream());
+                    if (xml.getDocumentElement().getLocalName().equals(Importer.ELEMENT_FAQS)) {
+                        docs[i].setResourceType(faqResourceType);
+                    }
+                }
+            }
+        }
+        finally {
+            if (selector != null) {
+                if (faqResourceType != null) {
+                    selector.release(faqResourceType);
+                }
+                getManager().release(selector);
+            }
         }
         session.commit();
     }

Added: lenya/sandbox/modules/forrest/resources/samples/forrestFaq20.xml
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/resources/samples/forrestFaq20.xml?rev=591293&view=auto
==============================================================================
--- lenya/sandbox/modules/forrest/resources/samples/forrestFaq20.xml (added)
+++ lenya/sandbox/modules/forrest/resources/samples/forrestFaq20.xml Fri Nov  2 03:20:16 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 2002-2005 The Apache Software Foundation or its licensors,
+  as applicable.
+  
+  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.
+--><!DOCTYPE faqs PUBLIC "-//APACHE//DTD FAQ V1.2//EN" "http://forrest.apache.org/dtd/faq-v12.dtd">
+
+<faqs title="Frequently Asked Questions">
+  <part id="samplePart">
+    <title>FAQ Sample Document</title>
+    <faq id="sampleQuestion">
+      <question>
+        Is this a question?
+      </question>
+      <answer>
+        <p>
+          Yes, it is.
+        </p>
+      </answer>
+    </faq>
+  </part>
+</faqs>

Modified: lenya/sandbox/modules/forrest/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/sitemap.xmap?rev=591293&r1=591292&r2=591293&view=diff
==============================================================================
--- lenya/sandbox/modules/forrest/sitemap.xmap (original)
+++ lenya/sandbox/modules/forrest/sitemap.xmap Fri Nov  2 03:20:16 2007
@@ -85,7 +85,12 @@
       <!-- {format}.xml/{pubId}/{area}/{uuid}/{language} -->
       <map:match pattern="*.xml/*/*/*/*">
         <map:generate src="lenya-document:{4},lang={5}{link:rev}"/>
-        <map:transform src="fallback://lenya/modules/forrest/xslt/{doc-info:{2}:{3}:{4}:{5}:resourceType}2xhtml.xsl">
+        <map:select type="resource-exists">
+          <map:when test="fallback://lenya/modules/forrest/xslt/{doc-info:{2}:{3}:{4}:{5}:resourceType}2document.xsl">
+            <map:transform src="fallback://lenya/modules/forrest/xslt/{doc-info:{2}:{3}:{4}:{5}:resourceType}2document.xsl"/>
+          </map:when>
+        </map:select>
+        <map:transform src="fallback://lenya/modules/forrest/xslt/forrestDocument202xhtml.xsl">
           <map:parameter name="rendertype" value="{request-param:rendertype}"/>
           <map:parameter name="nodeid" value="{doc-info:{2}:{3}:{4}:{5}:nodeName}"/>
           <map:parameter name="language" value="{4}"/>

Added: lenya/sandbox/modules/forrest/xslt/copyover.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/xslt/copyover.xsl?rev=591293&view=auto
==============================================================================
--- lenya/sandbox/modules/forrest/xslt/copyover.xsl (added)
+++ lenya/sandbox/modules/forrest/xslt/copyover.xsl Fri Nov  2 03:20:16 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<xsl:stylesheet
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    version="1.0">
+  <xsl:template match="@*|*|text()|processing-instruction()|comment()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|*|text()|processing-instruction()|comment()"/>
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>

Modified: lenya/sandbox/modules/forrest/xslt/forrestDocument202xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/xslt/forrestDocument202xhtml.xsl?rev=591293&r1=591292&r2=591293&view=diff
==============================================================================
--- lenya/sandbox/modules/forrest/xslt/forrestDocument202xhtml.xsl (original)
+++ lenya/sandbox/modules/forrest/xslt/forrestDocument202xhtml.xsl Fri Nov  2 03:20:16 2007
@@ -22,6 +22,8 @@
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns="http://www.w3.org/1999/xhtml">
   
+  <xsl:import href="toc.xsl"/>
+  
   <xsl:preserve-space elements="source"/>
   
   <xsl:template match="/">
@@ -34,6 +36,7 @@
       <body>
         <div id="body">
           <h1><xsl:value-of select="document/header/title"/></h1>
+          <xsl:apply-templates select="document/body" mode="toc"/>
           <xsl:choose>
             <xsl:when test="document/body/row">
               <table width="100%">
@@ -44,10 +47,6 @@
               <xsl:apply-templates select="document/body/*"/>
             </xsl:otherwise>
           </xsl:choose>
-          <p class="copyright">
-            Copyright &#169; 1999-2005 <a href="http://www.apache.org/">The Apache
-              Software Foundation</a>. All rights reserved.
-          </p>
         </div>
       </body>
     </html>

Added: lenya/sandbox/modules/forrest/xslt/forrestFaq202document.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/xslt/forrestFaq202document.xsl?rev=591293&view=auto
==============================================================================
--- lenya/sandbox/modules/forrest/xslt/forrestFaq202document.xsl (added)
+++ lenya/sandbox/modules/forrest/xslt/forrestFaq202document.xsl Fri Nov  2 03:20:16 2007
@@ -0,0 +1,107 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<xsl:stylesheet
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    version="1.0">
+  <xsl:import href="copyover.xsl"/>
+  <xsl:template match="faqs">
+    <document>
+      <header>
+        <title><xsl:value-of select="@title"/></title>
+      </header>
+      <body>
+        <xsl:apply-templates select="faq|part"/>
+      </body>
+    </document>
+  </xsl:template>
+  <xsl:template match="part" mode="index">
+    <li><strong>
+<!-- Rely on <ol> numbering here -->
+<!--<xsl:number level="multiple" count="faq|part" format="1.1. "/> -->
+      <xsl:apply-templates select="title"/></strong>
+      <ul>
+        <xsl:apply-templates select="faq|part" mode="index"/>
+      </ul>
+      <br /></li>
+  </xsl:template>
+  <xsl:template match="faq" mode="index">
+    <li><xsl:attribute name="id">
+        <xsl:call-template name="generate-id"/>
+<xsl:text>-menu</xsl:text>
+      </xsl:attribute><link>
+      <xsl:attribute name="href">
+<xsl:text>#</xsl:text>
+        <xsl:call-template name="generate-id"/>
+      </xsl:attribute>
+<!--
+		  IMHO adding this makes the tightly-packed menu less legible for
+		  little benefit (JT)
+	    <xsl:number level="multiple" count="faq|part" format="1.1. "/>
+		-->
+      <xsl:apply-templates select="question" mode="index"/></link></li>
+  </xsl:template>
+  <xsl:template match="part">
+    <xsl:variable name="id">
+      <xsl:call-template name="generate-id"/>
+    </xsl:variable>
+    <section id="{$id}">
+      <title><xsl:number level="multiple" count="faq|part" format="1.1. "/>
+        <xsl:value-of select="title"/></title>
+      <xsl:apply-templates select="faq|part"/>
+    </section>
+  </xsl:template>
+  <xsl:template match="faq">
+    <xsl:variable name="id">
+      <xsl:call-template name="generate-id"/>
+    </xsl:variable>
+    <section id="{$id}">
+      <title><xsl:number level="multiple" count="faq|part" format="1.1. "/>
+        <xsl:apply-templates select="question"/></title>
+      <xsl:apply-templates select="answer"/>
+    </section>
+  </xsl:template>
+  <xsl:template name="generate-id">
+    <xsl:choose>
+      <xsl:when test="@id">
+        <xsl:value-of select="@id"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="concat(concat(local-name(.), '-'), generate-id(.))"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  <xsl:template match="question" mode="index">
+    <xsl:apply-templates select="node()[not(local-name()='elaboration')]"/>
+  </xsl:template>
+  <xsl:template match="question">
+    <xsl:apply-templates/>
+  </xsl:template>
+  <xsl:template match="answer">
+    <xsl:if test="count(p)>0">
+      <xsl:apply-templates/>
+    </xsl:if>
+    <xsl:if test="count(p)=0">
+      <p>
+        <xsl:apply-templates/>
+      </p>
+    </xsl:if>
+  </xsl:template>
+  <xsl:template match="title">
+    <xsl:apply-templates/>
+  </xsl:template>
+</xsl:stylesheet>

Added: lenya/sandbox/modules/forrest/xslt/toc.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/forrest/xslt/toc.xsl?rev=591293&view=auto
==============================================================================
--- lenya/sandbox/modules/forrest/xslt/toc.xsl (added)
+++ lenya/sandbox/modules/forrest/xslt/toc.xsl Fri Nov  2 03:20:16 2007
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+  <!--  Templates for "toc" mode.  This will generate a complete
+    Table of Contents for the document.  This will then be used
+    by the site2xhtml to generate a Menu ToC and a Page ToC -->
+  
+  
+  <xsl:template name="generate-id">
+    <xsl:choose>
+      <xsl:when test="@id">
+        <xsl:value-of select="@id"/>
+      </xsl:when>
+      <xsl:when test="@title">
+        <xsl:value-of select="@title"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="generate-id(.)"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  
+  
+  <xsl:template match="body" mode="toc">
+    <xsl:if test="section">
+      <div class="tocTitle">
+        <div>Table of Contents</div>
+      </div>
+      <ul class="toc">
+        <xsl:apply-templates select="section" mode="toc"/>
+      </ul>
+    </xsl:if>
+  </xsl:template>
+  
+  
+  <xsl:template match="section" mode="toc">
+    <xsl:param name="level" select="number(1)"/>
+    <li>
+      <a>
+        <xsl:attribute name="href">#<xsl:call-template name="generate-id"/></xsl:attribute>
+        <xsl:value-of select="title"/>
+      </a>
+      <xsl:if test="section">
+        <ul class="toc">
+          <xsl:apply-templates select="section" mode="toc">
+            <xsl:with-param name="level" select="$level+1"/>
+          </xsl:apply-templates>
+        </ul>
+      </xsl:if>
+    </li>
+  </xsl:template>
+  
+  
+  <xsl:template match="node()|@*" mode="toc"/>
+  
+</xsl:stylesheet>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org