cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r225867 - in /cocoon/whiteboard/refdoc: java/org/apache/cocoon/doktor/ samples/ samples/annotated-code/ samples/annotated-code/org/apache/cocoon/doktorexamples/ samples/annotated-code/subdir/ samples/snippets/
Date Thu, 28 Jul 2005 20:13:45 GMT
Author: bdelacretaz
Date: Thu Jul 28 13:13:33 2005
New Revision: 225867

URL: http://svn.apache.org/viewcvs?rev=225867&view=rev
Log:
Robert Graham's patch applied, from http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=112243066516358&w=2

Modified:
    cocoon/whiteboard/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
    cocoon/whiteboard/refdoc/samples/annotated-code/org/apache/cocoon/doktorexamples/AnnotatedClass.java
    cocoon/whiteboard/refdoc/samples/annotated-code/subdir/dummy-sitemap.xweb
    cocoon/whiteboard/refdoc/samples/annotated-code/xmlfile.xml
    cocoon/whiteboard/refdoc/samples/index.html
    cocoon/whiteboard/refdoc/samples/sitemap.xmap
    cocoon/whiteboard/refdoc/samples/snippets/sitemap.xmap
    cocoon/whiteboard/refdoc/samples/snippets/snippets-to-index.xsl

Modified: cocoon/whiteboard/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
(original)
+++ cocoon/whiteboard/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
Thu Jul 28 13:13:33 2005
@@ -64,7 +64,7 @@
     // example a line such as
     //  @ doktor-start type:code include-in-toc:true
     // should create two properties, type and include-in-toc
-    private final RE metaRegexp = new RE("@doktor[^ ]*[ ]+([a-zA-Z-_.]+:.*)+");
+    private final RE metaRegexp = new RE("@doktor[^ ]*[ ]+([a-zA-Z-_.]+:.*,?)+");
 
     /**
      * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
@@ -171,16 +171,18 @@
      * */
     private void parseMetadata(String str) throws SAXException {
         if(metaRegexp.match(str)) {
-            // start at 1, 0 contains the full matched expression
-            for(int i=1; i < metaRegexp.getParenCount(); i++) {
-                final String expr = metaRegexp.getParen(i);
-                final int pos = expr.indexOf(':');
-                if(pos > 0) {
-                    final String name = expr.substring(0,pos);
-                    final String value = expr.substring(pos+1);
-                    metadata.put(name,value);
-                }
-            }
+            /** We only getParen(1) without looping because Regexps only remember the
+             * last matches per parentheses grouping. The expression now just matches
+             * all the name-value pairs and we added a comma between them which
+             * enables us to easily process them 
+             */
+            //String of the form "name:value value, name:value, name-name: value"
+            final String pairs = metaRegexp.getParen(1);
+            String[] splitpairs = pairs.split(",");
+            for(int i=0; i<splitpairs.length; i++) {
+                String[] nameandvalue = splitpairs[i].split(":");
+                metadata.put(nameandvalue[0].trim(), nameandvalue[1].trim());
+            } 
         }
     }
 

Modified: cocoon/whiteboard/refdoc/samples/annotated-code/org/apache/cocoon/doktorexamples/AnnotatedClass.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/annotated-code/org/apache/cocoon/doktorexamples/AnnotatedClass.java?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/samples/annotated-code/org/apache/cocoon/doktorexamples/AnnotatedClass.java
(original)
+++ cocoon/whiteboard/refdoc/samples/annotated-code/org/apache/cocoon/doktorexamples/AnnotatedClass.java
Thu Jul 28 13:13:33 2005
@@ -35,7 +35,7 @@
   */
 public class AnnotatedClass {
 
-    /** @doktor-start type:code include-in-toc:true
+    /** @doktor-start type:code, include-in-toc:true
      *  To include code in a doktor annotation, surround it with
      *  -start and -end doktor tags
      * */

Modified: cocoon/whiteboard/refdoc/samples/annotated-code/subdir/dummy-sitemap.xweb
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/annotated-code/subdir/dummy-sitemap.xweb?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/samples/annotated-code/subdir/dummy-sitemap.xweb (original)
+++ cocoon/whiteboard/refdoc/samples/annotated-code/subdir/dummy-sitemap.xweb Thu Jul 28 13:13:33
2005
@@ -23,7 +23,7 @@
   <map:pipelines>
 
     <map:pipeline>
-      <!-- @doktor-start type:pipeline key:firstExample -->
+      <!-- @doktor-start type:pipeline, key:firstExample -->
       <!-- doktor will create a snippet with all nodes found between -start end -end tags
-->
       <!-- useful to include several consecutive elements in a snippet -->
       <map:match pattern="dummy-sitemap">

Modified: cocoon/whiteboard/refdoc/samples/annotated-code/xmlfile.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/annotated-code/xmlfile.xml?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/samples/annotated-code/xmlfile.xml (original)
+++ cocoon/whiteboard/refdoc/samples/annotated-code/xmlfile.xml Thu Jul 28 13:13:33 2005
@@ -22,7 +22,7 @@
 
 <somedata>
   <!-- @doktor key: firstExample -->
-  <!-- @doktor sitemap-param: something info: this parameter could set some value -->
+  <!-- @doktor sitemap-param: something, info: this parameter could set some value -->
   <parameter name="something"/>
   <nothing-here>
     <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

Modified: cocoon/whiteboard/refdoc/samples/index.html
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/index.html?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/samples/index.html (original)
+++ cocoon/whiteboard/refdoc/samples/index.html Thu Jul 28 13:13:33 2005
@@ -91,5 +91,18 @@
         </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/firstExample">Try to search our index for "firstExample"</a>
+      </li>
+      <li>
+        <a href="snippets/searchQuery/firstExample/neutraldoc">Neutral Document Generated
from searchQuery for "firstExample"</a>
+      </li>
+
+    </ul>
+    
   </body>
 </html>

Modified: cocoon/whiteboard/refdoc/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/sitemap.xmap?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/samples/sitemap.xmap (original)
+++ cocoon/whiteboard/refdoc/samples/sitemap.xmap Thu Jul 28 13:13:33 2005
@@ -22,6 +22,10 @@
   <map:pipelines>
     <map:pipeline>
       <map:match pattern="">
+          <map:redirect-to uri="index.html"/>
+      </map:match>
+
+      <map:match pattern="index.html">
           <map:read src="index.html"/>
       </map:match>
 

Modified: cocoon/whiteboard/refdoc/samples/snippets/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/snippets/sitemap.xmap?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/samples/snippets/sitemap.xmap (original)
+++ cocoon/whiteboard/refdoc/samples/snippets/sitemap.xmap Thu Jul 28 13:13:33 2005
@@ -25,6 +25,9 @@
         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>
 
@@ -55,6 +58,27 @@
     </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/">
@@ -71,7 +95,9 @@
         <map:transform src="snippet-selector.xsl">
           <map:parameter name="snippetId" value="{2}"/>
         </map:transform>
-        <map:transform src="snippets-to-index.xsl"/>
+        <map:transform src="snippets-to-index.xsl">
+            <map:parameter name="filename" value="{1}"/>
+        </map:transform>
         <map:serialize type="xml"/>
       </map:match>
 

Modified: cocoon/whiteboard/refdoc/samples/snippets/snippets-to-index.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/snippets/snippets-to-index.xsl?rev=225867&r1=225866&r2=225867&view=diff
==============================================================================
--- cocoon/whiteboard/refdoc/samples/snippets/snippets-to-index.xsl (original)
+++ cocoon/whiteboard/refdoc/samples/snippets/snippets-to-index.xsl Thu Jul 28 13:13:33 2005
@@ -25,16 +25,34 @@
   xmlns:doktor="http://apache.org/cocoon/doktor/1.0"
 >
 
+  <xsl:param name="filename"/>
+
   <xsl:template match="/">
     <indexable-snippets>
       <xsl:apply-templates/>
     </indexable-snippets>
   </xsl:template>
+  
 
   <xsl:template match="doktor:snippet">
     <snippet>
+      <filename><xsl:value-of select="$filename"/></filename>
       <snippet-id><xsl:value-of select="@id"/></snippet-id>
+      <xsl:apply-templates select="//doktor:comment"/>
+      <xsl:apply-templates select="//doktor:metadata"/>
     </snippet>
+  </xsl:template>
+  
+  <xsl:template match="doktor:comment">
+      <comment>
+      <xsl:value-of select="."/>
+      </comment>
+  </xsl:template>
+  
+  <xsl:template match="doktor:metadata">
+      <metadata>
+      <xsl:copy-of select="child::*"/>
+      </metadata>
   </xsl:template>
 
 </xsl:transform>



Mime
View raw message