cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgra...@apache.org
Subject svn commit: r230609 - in /cocoon/gsoc/rgraham/refdoc: java/org/apache/cocoon/doktor/ samples/ samples/snippets/
Date Sat, 06 Aug 2005 22:45:59 GMT
Author: rgraham
Date: Sat Aug  6 15:45:49 2005
New Revision: 230609

URL: http://svn.apache.org/viewcvs?rev=230609&view=rev
Log:
Fixed a bug in DoktorMetadataTransformer where it replaced the key metadata for every snippet
with the first one found.

Updated index.html to match for slop.html

Added slop.html and updated sitemap.xmap in the snippets directory. The sum of that is we're
using the comments from the SLOP block now to toy with. To switch back, just reinstate sitemap.back
to sitemap.xmap.

Fixed a bug where slop-to-snippets.xsl would put the doktor:to-parse attribute in the snippets
element for lines that were just @doktor and not @doktor-element or @doktor-start thus keeping
the information from being processed in slop files.


Added:
    cocoon/gsoc/rgraham/refdoc/samples/slop.html
    cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.back.xmap
Modified:
    cocoon/gsoc/rgraham/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
    cocoon/gsoc/rgraham/refdoc/samples/index.html
    cocoon/gsoc/rgraham/refdoc/samples/sitemap.xmap
    cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.xmap
    cocoon/gsoc/rgraham/refdoc/samples/snippets/slop-to-snippets.xsl

Modified: cocoon/gsoc/rgraham/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/rgraham/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java?rev=230609&r1=230608&r2=230609&view=diff
==============================================================================
--- cocoon/gsoc/rgraham/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
(original)
+++ cocoon/gsoc/rgraham/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
Sat Aug  6 15:45:49 2005
@@ -46,6 +46,7 @@
     public static final String E_METADATA = "metadata";
     public static final String E_METADATA_RAW = "doktor:metadata";
     public static final String A_TOPARSE = "doktor-toparse";
+    public static final String DOKTOR_METADATA_KEY = "key";
 
     /** Store state of current element */
     private static class ElementState {
@@ -57,7 +58,7 @@
     private ElementState currentElement = null;
 
     /** accumulate metadata (assuming elements which use this are not nested */
-    private Map metadata = new HashMap();
+    private Map<String, String> metadata = new HashMap<String, String>();
 
     /** Regexp for metadata parsing */
     // TODO the parsing of multiple values does not work yet, for
@@ -67,7 +68,7 @@
     private final RE metaRegexp = new RE("@doktor[^ ]*[ ]+([a-zA-Z-_.]+:.*,?)+");
     
     //The last key value found in the parsing
-    private String lastKey;
+    private String lastKey = null;
 
     /**
      * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
@@ -133,13 +134,11 @@
             parseMetadata(currentElement.buffer.toString());
         }
 
-        //check to see if the metadata has a key value, if not add the last seen key
-         if (!metadata.containsKey("key") && this.lastKey != null) {
-             metadata.put("key", lastKey);
-         }
+
         
         // if ending a doktor:content element, write accumulated metadata
         if(DOKTOR_NS_URL.equals(uri) && E_CONTENT.equals(loc)) {
+            boolean keyFlag = false;
             super.startElement(DOKTOR_NS_URL,E_METADATA,E_METADATA_RAW,XMLUtils.EMPTY_ATTRIBUTES);
             for (Iterator iterator = metadata.entrySet().iterator(); iterator.hasNext();)
{
                 final Map.Entry e = (Map.Entry)iterator.next();
@@ -149,6 +148,7 @@
                 writeContentString(e.getValue().toString());
                 super.endElement("",elementName,elementName);
             }
+            
             super.endElement(DOKTOR_NS_URL,E_METADATA,E_METADATA_RAW);
 
             // clear accumulated metadata, we have output it
@@ -186,16 +186,18 @@
              */
             //String of the form "name:value value, name:value, name-name: value"
             final String pairs = metaRegexp.getParen(1);
+            writeContentString("< " + pairs + " />");
             String[] splitpairs = pairs.split(",");
-            String strz = "";
+            String strKey;
             for(int i=0; i<splitpairs.length; i++) {
                 String[] nameandvalue = splitpairs[i].split(":");
                 metadata.put(nameandvalue[0].trim(), nameandvalue[1].trim());
-                strz = nameandvalue[0].trim();
-                if (strz.compareTo("key") == 0) {
-                    this.lastKey = nameandvalue[1].trim();
-                }
-            } 
+            }
+             if (metadata.containsKey(DOKTOR_METADATA_KEY)) {
+                lastKey = metadata.get(DOKTOR_METADATA_KEY);
+            } else if (lastKey != null) {
+                metadata.put(DOKTOR_METADATA_KEY, lastKey);
+            }            
         }
     }
 
@@ -209,4 +211,5 @@
     public void characters(char c[], int start, int len) throws SAXException {
         currentElement.buffer.append(c,start,len);
     }
+    
 }

Modified: cocoon/gsoc/rgraham/refdoc/samples/index.html
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/rgraham/refdoc/samples/index.html?rev=230609&r1=230608&r2=230609&view=diff
==============================================================================
--- cocoon/gsoc/rgraham/refdoc/samples/index.html (original)
+++ cocoon/gsoc/rgraham/refdoc/samples/index.html Sat Aug  6 15:45:49 2005
@@ -104,5 +104,9 @@
 
     </ul>
     
+    <p>
+    <a href="slop.html">Extended Examples with SLOP block</a>
+    </p>
+    
   </body>
 </html>

Modified: cocoon/gsoc/rgraham/refdoc/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/rgraham/refdoc/samples/sitemap.xmap?rev=230609&r1=230608&r2=230609&view=diff
==============================================================================
--- cocoon/gsoc/rgraham/refdoc/samples/sitemap.xmap (original)
+++ cocoon/gsoc/rgraham/refdoc/samples/sitemap.xmap Sat Aug  6 15:45:49 2005
@@ -28,6 +28,10 @@
       <map:match pattern="index.html">
           <map:read src="index.html"/>
       </map:match>
+      
+      <map:match pattern="slop.html">
+          <map:read src="slop.html"/>
+      </map:match>
 
       <map:match pattern="*/**">
         <map:mount check-reload="yes" src="{1}/" uri-prefix="{1}"/>

Added: cocoon/gsoc/rgraham/refdoc/samples/slop.html
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/rgraham/refdoc/samples/slop.html?rev=230609&view=auto
==============================================================================
--- cocoon/gsoc/rgraham/refdoc/samples/slop.html (added)
+++ cocoon/gsoc/rgraham/refdoc/samples/slop.html Sat Aug  6 15:45:49 2005
@@ -0,0 +1,99 @@
+<html>
+  <!--
+    Copyright 1999-2005 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.
+  -->
+  <head>
+    <title>Cocoon refdoc block, extended examples page</title>
+  </head>
+  <body>
+    <h1>Cocoon refdoc block, extended examples page</h1>
+
+    <h2>Views meant for Lucene indexing</h2>
+    <ul>
+      <li>
+        <a href="snippets/samples/">
+          Top-level directory
+        </a>
+      </li>
+      <li>
+        <a href="snippets/samples/?cocoon-view=links">
+          Top-level directory, links view (this is where Lucene starts indexing)
+        </a>
+      </li>
+      <li>
+        <a href="snippets/samples/javateach/">
+          Subdirectory
+        </a>
+      </li>
+      <li>
+        <a href="snippets/samples/javateach/?cocoon-view=links">
+          Subdirectory, links view
+        </a>
+      </li>
+    </ul>
+
+    <h2>Snippets extraction</h2>
+    <ul>
+      <li>
+        <a href="snippets/samples/sitemap.xmap/doktor-snippets/">
+          List of snippets in sitemap.xmap
+        </a>
+      </li>
+
+      <li>
+        <a href="snippets/samples/org/apache/cocoon/slop/generation/SlopGenerator.java/doktor-snippets/">
+          List of snippets in SlopGenerator.java
+        </a>
+      </li>
+      <li>
+        <a href="snippets/samples/sitemap.xmap/doktor-snippets/snippet_1">
+          Access a single snippet in sitemap.xmap, ready for Lucene indexing
+        </a>
+      </li>
+
+    </ul>
+
+    <h2>Snippets extraction primitives</h2>
+    <ul>
+      <li>
+        <a href="snippets/samples/org/apache/cocoon/slop/generation/SlopGenerator.java">
+          Java source file snippets</a>
+          (here's the
+        <a href="snippets/samples/org/apache/cocoon/slop/generation/SlopGenerator.java?cocoon-view=raw-snippets">
+            raw snippet data
+        </a>
+          before metadata parsing).
+      </li>
+
+      <li>
+        <a href="snippets/samples/sitemap.xmap">
+          Sitemap snippets
+        </a>
+      </li></ul>
+
+        <h2>Indexing, Searching, and Neutral Documents</h2>
+    (see patch-README.txt for how to create the index)
+    <ul>
+      <li>
+        <a href="snippets/searchQuery/slop">Try to search our index for "slop"</a>
+      </li>
+      <li>
+        <a href="snippets/searchQuery/slop/neutraldoc">Neutral Document Generated from
searchQuery for "slop"</a>
+      </li>
+
+    </ul>
+    
+  </body>
+</html>
\ No newline at end of file

Added: cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.back.xmap
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.back.xmap?rev=230609&view=auto
==============================================================================
--- cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.back.xmap (added)
+++ cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.back.xmap Sat Aug  6 15:45:49 2005
@@ -0,0 +1,151 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2005 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.
+-->
+
+<!-- @version $Id: sitemap.xmap,v 1.7 2005/06/10 16:19:42 bdelacretaz Exp $ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:components>
+    <map:transformers default="xslt">
+      <map:transformer
+        logger="sitemap.transformer.dotkor"
+        name="doktor"
+        src="org.apache.cocoon.doktor.DoktorMetadataTransformer"/>
+       <map:transformer name="index" 
+        logger="sitemap.transformer.luceneindextransformer" 
+        src="org.apache.cocoon.transformation.LuceneIndexTransformer"/>
+    </map:transformers>
+  </map:components>
+
+  <map:views>
+    <map:view name="marked" from-label="marked">
+      <map:serialize type="xml"/>
+    </map:view>
+    <map:view name="raw-snippets" from-label="raw-snippets">
+      <map:serialize type="xml"/>
+    </map:view>
+
+    <!-- Lucene uses these views to crawl our documents -->
+    <map:view from-position="last" name="content">
+      <map:serialize type="xml"/>
+    </map:view>
+
+    <map:view from-position="last" name="links">
+      <map:serialize type="links"/>
+    </map:view>
+  </map:views>
+
+  <map:pipelines>
+    <map:component-configurations>
+      <global-variables>
+        <!-- TODO this should be configurable, maybe with several possible roots -->
+        <codebase>../annotated-code</codebase>
+      </global-variables>
+    </map:component-configurations>
+
+    <map:pipeline>
+      <!-- Testing the indexing of LuceneIndexTransformer -->
+      <map:match pattern="lit">
+        <map:generate src="{global:codebase}/luceneIndexTransformerTest.xml"/>
+        <map:transform type="index"/> 
+        <map:serialize type="xml"/>
+      </map:match>
+      
+      <!-- Testing searching from the pipeline -->
+      <map:match pattern="searchQuery/*">
+        <map:generate type="search">
+          <map:parameter name="query" value="{1}"/>
+        </map:generate>  
+        <map:serialize type="xml"/>
+      </map:match>
+      
+      <!-- Testing searching from the pipeline -->
+      <map:match pattern="**/neutraldoc">
+        <map:generate src="cocoon:/{1}"/>
+        <map:transform src="searchxml-to-neutralDoc.xsl"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- retrieve the list of snippets in a file -->
+      <map:match pattern="**/doktor-snippets/">
+        <map:generate src="cocoon:/{1}"/>
+        <map:transform src="snippet-links.xsl">
+          <map:parameter name="filename" value="{1}"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- retrieve a single snippet, for indexing -->
+      <map:match pattern="**/doktor-snippets/*">
+        <map:generate src="cocoon:/{1}"/>
+        <map:transform src="snippet-selector.xsl">
+          <map:parameter name="snippetId" value="{2}"/>
+        </map:transform>
+        <map:transform src="snippets-to-index.xsl">
+            <map:parameter name="filename" value="{1}"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- top-level directory listing -->
+      <map:match pattern="*/">
+        <map:generate type="directory" src="{global:codebase}"/>
+        <map:transform label="links" src="dir-to-links.xsl"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- subdirectories listing -->
+      <map:match pattern="*/**/">
+        <map:generate type="directory" src="{global:codebase}/{2}"/>
+        <map:transform label="links" src="dir-to-links.xsl"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- XML files, xconf, sitemaps: use xml mode -->
+      <!-- TODO: {1} should be used to select different code repositories -->
+      <map:match type="regexp" pattern="^([^\./]+)/([^\.]+)\.(xml|xconf|xmap|xweb|xsamples)$">
+        <map:generate src="{global:codebase}/{2}.{3}"/>
+        <map:transform label="marked" src="mark-xml-comments.xsl"/>
+        <map:transform label="raw-snippets" src="xml-to-snippets.xsl">
+          <map:parameter name="filename" value="{2}.{3}"/>
+          <map:parameter name="extension" value="{3}"/>
+        </map:transform>
+        <map:transform type="doktor"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- all other files: use text mode snippets extraction -->
+      <!-- TODO: {1} should be used to select different code repositories -->
+      <!--@doktor-start key:slop, type:sitemap-example, name:SlopGenerator-->
+      <map:match pattern="*/**.*">
+        <map:generate type="slop" src="{global:codebase}/{2}.{3}">
+       <!-- ... @doktor-end --> 
+          <map:parameter name="preserve-space" value="true"/>
+          <map:parameter name="valid-tagname-chars" value=""/>
+        </map:generate>
+        <map:transform label="marked" src="mark-slop-lines.xsl"/>
+        <map:transform label="raw-snippets" src="slop-to-snippets.xsl">
+          <map:parameter name="filename" value="{2}.{3}"/>
+          <map:parameter name="extension" value="{3}"/>
+        </map:transform>
+        <map:transform type="doktor"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>

Modified: cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.xmap?rev=230609&r1=230608&r2=230609&view=diff
==============================================================================
--- cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.xmap (original)
+++ cocoon/gsoc/rgraham/refdoc/samples/snippets/sitemap.xmap Sat Aug  6 15:45:49 2005
@@ -54,6 +54,7 @@
       <global-variables>
         <!-- TODO this should be configurable, maybe with several possible roots -->
         <codebase>../annotated-code</codebase>
+        <slopbase>../../slop</slopbase>
       </global-variables>
     </map:component-configurations>
 
@@ -103,14 +104,14 @@
 
       <!-- top-level directory listing -->
       <map:match pattern="*/">
-        <map:generate type="directory" src="{global:codebase}"/>
+        <map:generate type="directory" src="{global:slopbase}"/>
         <map:transform label="links" src="dir-to-links.xsl"/>
         <map:serialize type="xml"/>
       </map:match>
 
       <!-- subdirectories listing -->
       <map:match pattern="*/**/">
-        <map:generate type="directory" src="{global:codebase}/{2}"/>
+        <map:generate type="directory" src="{global:slopbase}/{2}"/>
         <map:transform label="links" src="dir-to-links.xsl"/>
         <map:serialize type="xml"/>
       </map:match>
@@ -118,7 +119,7 @@
       <!-- XML files, xconf, sitemaps: use xml mode -->
       <!-- TODO: {1} should be used to select different code repositories -->
       <map:match type="regexp" pattern="^([^\./]+)/([^\.]+)\.(xml|xconf|xmap|xweb|xsamples)$">
-        <map:generate src="{global:codebase}/{2}.{3}"/>
+        <map:generate src="{global:slopbase}/{2}.{3}"/>
         <map:transform label="marked" src="mark-xml-comments.xsl"/>
         <map:transform label="raw-snippets" src="xml-to-snippets.xsl">
           <map:parameter name="filename" value="{2}.{3}"/>
@@ -130,8 +131,10 @@
 
       <!-- all other files: use text mode snippets extraction -->
       <!-- TODO: {1} should be used to select different code repositories -->
+      <!--@doktor-start key:slop, type:sitemap-example, name:SlopGenerator-->
       <map:match pattern="*/**.*">
-        <map:generate type="slop" src="{global:codebase}/{2}.{3}">
+        <map:generate type="slop" src="{global:slopbase}/{2}.{3}">
+       <!-- ... @doktor-end --> 
           <map:parameter name="preserve-space" value="true"/>
           <map:parameter name="valid-tagname-chars" value=""/>
         </map:generate>

Modified: cocoon/gsoc/rgraham/refdoc/samples/snippets/slop-to-snippets.xsl
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/rgraham/refdoc/samples/snippets/slop-to-snippets.xsl?rev=230609&r1=230608&r2=230609&view=diff
==============================================================================
--- cocoon/gsoc/rgraham/refdoc/samples/snippets/slop-to-snippets.xsl (original)
+++ cocoon/gsoc/rgraham/refdoc/samples/snippets/slop-to-snippets.xsl Sat Aug  6 15:45:49 2005
@@ -44,9 +44,9 @@
   <!-- doktor lines: generate a snippet -->
   <xsl:template match="slop:line[@doktor:doktor]">
     <doktor:snippet line-number="{@line-number}" mode="line">
-      <xsl:copy-of select="@*"/>
       <xsl:call-template name="snippetId"/>
       <doktor:content>
+        <xsl:copy-of select="@*"/>
         <xsl:value-of select="."/>
       </doktor:content>
     </doktor:snippet>



Mime
View raw message