cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r169358 - /cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AnnotationsFilter.java /cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java /cocoon/trunk/src/test/anteater/sitemapAnnotationsFilter.xml /cocoon/trunk/status.xml
Date Mon, 09 May 2005 21:05:50 GMT
Author: bdelacretaz
Date: Mon May  9 14:05:49 2005
New Revision: 169358

URL: http://svn.apache.org/viewcvs?rev=169358&view=rev
Log:
patch 25352 applied (including anteater test), TreeProcessor ignores new 'annotations' namespace
in sitemaps

Added:
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AnnotationsFilter.java
    cocoon/trunk/src/test/anteater/sitemapAnnotationsFilter.xml
Modified:
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
    cocoon/trunk/status.xml

Added: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AnnotationsFilter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AnnotationsFilter.java?rev=169358&view=auto
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AnnotationsFilter.java
(added)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/AnnotationsFilter.java
Mon May  9 14:05:49 2005
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+package org.apache.cocoon.components.treeprocessor;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/** Filter out annotations in the sitemap
+ *  (bugzilla 25352)
+ *  $Id$
+ */
+class AnnotationsFilter implements ContentHandler {
+    public static final String ANNOTATIONS_NAMESPACE = "http://apache.org/cocoon/sitemap/annotations/1.0";
+
+    private ContentHandler delegate;
+
+    private int nestingLevel;
+
+    private boolean isOutsideAnnotation()
+    {
+        return nestingLevel == 0;
+    }
+
+    public AnnotationsFilter(ContentHandler delegate) {
+        this.delegate = delegate;
+    }
+
+    public void setDocumentLocator(Locator locator) {
+        delegate.setDocumentLocator(locator);
+    }
+
+    public void startDocument() throws SAXException {
+        delegate.startDocument();
+    }
+
+    public void endDocument() throws SAXException {
+        delegate.endDocument();
+    }
+
+    public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException
{
+        if (isOutsideAnnotation()) {
+            delegate.startPrefixMapping(prefix, namespaceURI);
+        }
+    }
+
+    public void endPrefixMapping(String prefix) throws SAXException {
+        if (isOutsideAnnotation()) {
+            delegate.endPrefixMapping(prefix);
+        }
+    }
+
+    public void startElement(String namespaceURI, String localName, String qName, Attributes
attributes) throws SAXException {
+        if (namespaceURI !=  null && namespaceURI.equals(ANNOTATIONS_NAMESPACE))
{
+            nestingLevel++;
+        }
+        if (isOutsideAnnotation()) {
+            delegate.startElement(namespaceURI, localName, qName, attributes);
+        }
+    }
+
+    public void endElement(String namespaceURI, String localName, String qName) throws SAXException
{
+        if (isOutsideAnnotation()) {
+            delegate.endElement(namespaceURI, localName, qName);
+        }
+        if (namespaceURI !=  null && namespaceURI.equals(ANNOTATIONS_NAMESPACE))
{
+            nestingLevel--;
+        }
+    }
+
+    public void characters(char[] ch, int start, int len) throws SAXException {
+        if (isOutsideAnnotation()) {
+            delegate.characters(ch, start, len);
+        }
+    }
+
+    public void ignorableWhitespace(char[] ch, int start, int len) throws SAXException {
+        if (isOutsideAnnotation()) {
+            delegate.ignorableWhitespace(ch, start, len);
+        }
+    }
+
+    public void processingInstruction(String target, String data) throws SAXException {
+        if (isOutsideAnnotation()) {
+            delegate.processingInstruction(target, data);
+        }
+    }
+
+    public void skippedEntity(String name) throws SAXException {
+        if (isOutsideAnnotation()) {
+            delegate.skippedEntity(name);
+        }
+    }
+}

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java?rev=169358&r1=169357&r2=169358&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java Mon
May  9 14:05:49 2005
@@ -393,7 +393,8 @@
 
             // Build a namespace-aware configuration object
             NamespacedSAXConfigurationHandler handler = new NamespacedSAXConfigurationHandler();
-            SourceUtil.toSAX(this.source, handler);
+            AnnotationsFilter annotationsFilter = new AnnotationsFilter(handler);
+            SourceUtil.toSAX(this.source, annotationsFilter );
             Configuration sitemapProgram = handler.getConfiguration();
             newLastModified = this.source.getLastModified();
 

Added: cocoon/trunk/src/test/anteater/sitemapAnnotationsFilter.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/anteater/sitemapAnnotationsFilter.xml?rev=169358&view=auto
==============================================================================
--- cocoon/trunk/src/test/anteater/sitemapAnnotationsFilter.xml (added)
+++ cocoon/trunk/src/test/anteater/sitemapAnnotationsFilter.xml Mon May  9 14:05:49 2005
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  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.
+-->
+
+<project name="sitemapAnnotationsFilter" default="annotatedSitemapWorks">
+
+  <group id="default">
+    <property name="usetidy" value="false"/>
+  </group>
+
+  <target name="annotatedSitemapWorks">
+    <property name="url" value="${anteater.env.cocoon}samples/test/sitemap-annotations/annotations"/>
+
+    <!-- check that the "annotations" page contains annotations from the test sitemap
-->
+    <httpRequest href="${url}" description="Test annotations extraction">
+      <match>
+        <xpath select="//info/author" value="The Cocoon team"/>
+      </match>
+    </httpRequest>
+
+  </target>
+</project>

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=169358&r1=169357&r2=169358&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Mon May  9 14:05:49 2005
@@ -195,6 +195,11 @@
 
   <changes>
   <release version="@version@" date="@date@">
+   <action dev="BD" type="add" fixes-bug="25352" due-to="Johan Stuyts" due-to-email="j.stuyts@hippo.nl">
+     The new "annotations" namespace (http://apache.org/cocoon/sitemap/annotations/1.0)
+     can be used to add information to sitemaps. The sitemap processor ignores this information,
+     which can be used for documentation purposes.
+   </action>
    <action dev="LG" type="update">
      Removed o.a.c.generation.JXTemplateGenerator from core. 
      Introduced o.a.c.template.jxtg.JXTemplateGenerator as the official templating language.



Mime
View raw message