cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r225868 - in /cocoon/whiteboard/refdoc: patch-README.txt samples/snippets/searchxml-to-neutralDoc.xsl samples/snippets/to-snippets.xsl
Date Thu, 28 Jul 2005 20:14:24 GMT
Author: bdelacretaz
Date: Thu Jul 28 13:14:16 2005
New Revision: 225868

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

Added:
    cocoon/whiteboard/refdoc/patch-README.txt
    cocoon/whiteboard/refdoc/samples/snippets/searchxml-to-neutralDoc.xsl
    cocoon/whiteboard/refdoc/samples/snippets/to-snippets.xsl

Added: cocoon/whiteboard/refdoc/patch-README.txt
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/patch-README.txt?rev=225868&view=auto
==============================================================================
--- cocoon/whiteboard/refdoc/patch-README.txt (added)
+++ cocoon/whiteboard/refdoc/patch-README.txt Thu Jul 28 13:14:16 2005
@@ -0,0 +1,69 @@
+Robert Graham's notes for patch, from
+http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=112243066516358&w=2
+
+RefDoc Patch Documentation
+
+*************** Changes: ************************************************
+
+/refdoc/samples/sitemap.xmap:
+    Added match for "index.html" because "/" wasn't matching for me.
+
+/refdoc/samples/index.html
+    Added a couple links, one is to view a search for "firstExample" on the
+    (indexed) snippets
+    Also added a link to view the neutral document generated that is nearly ready
+    for publishing. Needs more testing.
+    
+/refdoc/samples/snippets/sitemap.xmap
+    Modified for the above links and some testing of indexing techniques, also
+    uses the below XSLT files.
+
+/refdoc/samples/snippets/snippets-to-index.xsl
+    Modified to include more information for indexing
+
+/refdoc/samples/snippets/to-snippets.xsl
+    Created to reaplce (a refactor albeit a bad one) of xml-to-snippets.xsl
+    and slop-to-snippets.xsl
+
+/refdoc/samples/snippets/searchxml-to-neutraldoc.xsl
+    My own creation for going from search result XML from a query
+    to a neutral publishable document that has all snippets for the
+    queried key and *may* be sorted by type. Not enough testing.
+    
+/refdoc/samples/annotated-code/xmlfile.xml
+    Modified to include commas between key value pairs
+    
+/refdoc/samples/annotated-code/subdir/dummy-sitemap.xweb
+    Modified to include commas between key value pairs
+    
+/refdoc/samples/annotated-code/org/apache/cocoon/doktorexamples/AnnotatedClass.java
+    Modified to include commas between key value pairs
+    
+/refdoc/java/org/apache/cocoon/doktor/DoktorMetadataTransformer.java
+    Modified to parse out comma separated key value pairs
+    
+*********** Changes to cocoon-lucene.xconf in /WEB-INF/xconf/  *********************
+
+Original:
+  <cocoon-crawler logger="core.search.crawler"/>
+  <lucene-xml-indexer logger="core.search.lucene"/>
+
+Needed for indexing/searching:
+  <cocoon-crawler logger="core.search.crawler" >
+      <include>.*/refdoc/snippets/samples/</include>
+  </cocoon-crawler>
+  <lucene-xml-indexer logger="core.search.lucene">
+      <index-fields>snippet_id, metadata, comment</index-fields>
+      <store-fields>snippet_id, metadata, comment, filename, key, type</store-fields>
+  </lucene-xml-indexer>
+  
+********************  To index with lucene block ********************************
+
+Head to:  <context>/samples/blocks/lucene/create
+
+Create an index (with the above configuration) on
+    <context>/samples/blocks/refdoc/snippets/samples/
+    
+**************************************************************************
+
+I think thats it, if something goes wrong contact me if you need to. It's all pretty simple.

Added: cocoon/whiteboard/refdoc/samples/snippets/searchxml-to-neutralDoc.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/snippets/searchxml-to-neutralDoc.xsl?rev=225868&view=auto
==============================================================================
--- cocoon/whiteboard/refdoc/samples/snippets/searchxml-to-neutralDoc.xsl (added)
+++ cocoon/whiteboard/refdoc/samples/snippets/searchxml-to-neutralDoc.xsl Thu Jul 28 13:14:16
2005
@@ -0,0 +1,51 @@
+<?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.
+-->
+
+<!--
+  Take the search results and create a document in a neutral XML format
+  ready for publishing
+
+  SVN $Id: searchxml-to-neutralDoc.xsl,v 1.1 2005/06/02 16:28:35 bdelacretaz Exp $
+ -->
+<xsl:transform version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:search="http://apache.org/cocoon/search/1.0"
+>
+
+  <xsl:template match="//search:results">
+    <xsl:element name="{@query-string}">
+        <xsl:apply-templates select="//search:hits/search:hit">
+            <xsl:sort order="descending" select="descendant::search:hits/search:hit/search:field[type
= @name]/."/> 
+        </xsl:apply-templates>
+    </xsl:element> 
+  </xsl:template>
+  
+
+  <xsl:template match="search:hit">
+    <snippet>
+        <uri><xsl:value-of select="@uri"/></uri>
+        <xsl:apply-templates select="descendant::search:field"/>
+    </snippet>
+  </xsl:template>
+  
+  <xsl:template match="search:field">
+    <xsl:element name="{@name}">
+        <xsl:value-of select ="."/>
+    </xsl:element>
+  </xsl:template>
+
+</xsl:transform>
\ No newline at end of file

Added: cocoon/whiteboard/refdoc/samples/snippets/to-snippets.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/refdoc/samples/snippets/to-snippets.xsl?rev=225868&view=auto
==============================================================================
--- cocoon/whiteboard/refdoc/samples/snippets/to-snippets.xsl (added)
+++ cocoon/whiteboard/refdoc/samples/snippets/to-snippets.xsl Thu Jul 28 13:14:16 2005
@@ -0,0 +1,158 @@
+<?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.
+-->
+
+<!--
+  Convert the output of mark-xml-comments.xsl to doktor snippets
+  and covert the output of mark-slop-lines.xsl to doktor snippets
+ -->
+ 
+<xsl:transform version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:slop="http://apache.org/cocoon/slop/parser/1.0"
+  xmlns:doktor="http://apache.org/cocoon/doktor/1.0"
+  exclude-result-prefixes=""
+>
+
+  <xsl:param name="filename"/>
+  <xsl:param name="extension"/>
+  <xsl:param name="mode"/>
+  
+    <xsl:template match="/">
+    <doktor:snippets filename="{$filename}" extension="{$extension}" input-mode="$mode">
+      <!-- process doktor and start comments only for text, all for xml -->
+      <xsl:choose>
+          <xsl:when test="contains($mode, 'text')">
+          <xsl:apply-templates select="//*[@doktor:doktor or @doktor:doktor-start]"/>
+          </xsl:when>          
+          <xsl:when test="contains($mode, 'xml')">
+                    <xsl:apply-templates select="//doktor:comment[@doktor:doktor or @doktor:doktor-start
or @doktor:doktor-element]"/>
+          </xsl:when>    
+      </xsl:choose>
+    </doktor:snippets>
+  </xsl:template>
+
+  <!-- XML MODE -->
+  <!-- doktor comments: generate a snippet -->
+  <xsl:template match="doktor:comment[@doktor:doktor]">
+    <doktor:snippet mode="line">
+      <xsl:call-template name="snippetId-xml"/>
+      <doktor:content>
+        <xsl:apply-templates select="." mode="copy-xml"/>
+      </doktor:content>
+    </doktor:snippet>
+  </xsl:template>
+
+  <!-- element comments: generate a snippet containing following XML element -->
+  <xsl:template match="doktor:comment[@doktor:doktor-element]">
+    <doktor:snippet mode="xml">
+      <xsl:call-template name="snippetId-xml"/>
+      <doktor:content>
+        <xsl:apply-templates select="." mode="copy-xml"/>
+        <xsl:apply-templates select="following::*[1]" mode="copy-xml"/>
+      </doktor:content>
+    </doktor:snippet>
+  </xsl:template>
+
+  <!-- start comments: generate a snippet with all nodes between this and the end comment
-->
+  <xsl:template match="doktor:comment[@doktor:doktor-start]">
+    <xsl:variable name="endLine" select="following::doktor:comment[@doktor:doktor-end][1]/@doktor:counter"/>
+    <doktor:snippet mode="xml">
+      <xsl:call-template name="snippetId-xml"/>
+      <doktor:content>
+        <xsl:apply-templates
+          select="self::*|following-sibling::node()[@doktor:counter &lt; $endLine]"
+          mode="copy"
+        />
+      </doktor:content>
+    </doktor:snippet>
+  </xsl:template>
+  
+  
+   <!-- convert doktor:comments back -->
+  <xsl:template match="doktor:comment" mode="copy-xml">
+    <xsl:comment>
+      <xsl:value-of select="."/>
+    </xsl:comment>
+  </xsl:template>
+
+  <!-- but keep doktor:comments that must be parsed -->
+  <xsl:template match="doktor:comment[@doktor:doktor-toparse]" mode="copy-xml">
+    <xsl:copy-of select="."/>
+  </xsl:template>
+
+  <!-- copy elements -->
+  <xsl:template match="*" mode="copy-xml">
+    <xsl:copy>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates mode="copy"/>
+    </xsl:copy>
+  </xsl:template>
+  
+    <!-- generate snippet id -->
+  <xsl:template name="snippetId-xml">
+    <xsl:attribute name="id">
+      <xsl:value-of select="concat('snippet_',@doktor:counter)"/>
+    </xsl:attribute>
+  </xsl:template>
+  
+  <!-- END XML MODE -->
+    
+  <!-- TEXT MODE-->
+  
+    <!-- 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-text"/>
+      <doktor:content>
+        <xsl:value-of select="."/>
+      </doktor:content>
+    </doktor:snippet>
+  </xsl:template>
+
+  <!-- start lines: generate a snippet with all elements between this and end line -->
+  <xsl:template match="slop:line[@doktor:doktor-start]">
+    <xsl:variable name="endLine" select="following::slop:line[@doktor:doktor-end][1]/@line-number"/>
+    <doktor:snippet mode="text">
+      <xsl:call-template name="snippetId-text"/>
+      <doktor:content>
+          <xsl:apply-templates
+            select="self::*|following::slop:*[@line-number &lt; $endLine]"
+            mode="copy-text"
+          />
+      </doktor:content>
+    </doktor:snippet>
+  </xsl:template>
+
+  <!-- copy slop elements, removing namespace -->
+  <xsl:template match="slop:*" mode="copy-text">
+    <line>
+      <xsl:copy-of select="@*"/>
+      <xsl:value-of select="."/>
+    </line>
+  </xsl:template>
+  
+    <!-- generate snippet id -->
+  <xsl:template name="snippetId-text">
+    <xsl:attribute name="id">
+      <xsl:value-of select="concat('snippet_',@line-number)"/>
+    </xsl:attribute>
+  </xsl:template>
+  
+  <!-- END TEXT MODE-->
+  
+</xsl:transform>



Mime
View raw message