cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r344101 - in /cocoon: blocks/portal-sample/trunk/samples/coplets/gallery/ blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/ trunk/ trunk/src/java/org/apache/cocoon/transformation/
Date Mon, 14 Nov 2005 11:10:08 GMT
Author: cziegeler
Date: Mon Nov 14 03:09:50 2005
New Revision: 344101

URL: http://svn.apache.org/viewcvs?rev=344101&view=rev
Log:
AbstractSAXTransformer supports removal of own namespace prefixes.
Clean up portal transformer, remove namespace prefixes

Modified:
    cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl
    cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLEventLinkTransformer.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLRootTransformer.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/RSSTransformer.java
    cocoon/trunk/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
    cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
    cocoon/trunk/status.xml

Modified: cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl (original)
+++ cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl Mon Nov 14 03:09:50
2005
@@ -19,7 +19,8 @@
 -->
 <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:java="http://xml.apache.org/xalan/java">
+                xmlns:java="http://xml.apache.org/xalan/java"
+                exclude-result-prefixes="java">
 
 <!-- The current picture (index) to display -->
 <xsl:param name="pic"/>
@@ -30,7 +31,7 @@
   <xsl:variable name="maxp" select="count(picture)"/>
 
   <xsl:choose>
-    <xsl:when test="$size='3'">
+    <xsl:when test="$size &gt; 1">
       <!-- This is the two column version: 
       <table><tbody>
         <xsl:for-each select="picture">

Modified: cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl (original)
+++ cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl Mon Nov 14 03:09:50
2005
@@ -19,7 +19,8 @@
 -->
 <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:java="http://xml.apache.org/xalan/java">
+                xmlns:java="http://xml.apache.org/xalan/java"
+                exclude-result-prefixes="java">
 
 <!-- The current picture to display -->
 <xsl:param name="pic"/>

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
Mon Nov 14 03:09:50 2005
@@ -84,7 +84,7 @@
     protected CopletInstanceData getCopletInstanceData(String copletId) 
     throws SAXException {
         final Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
-        
+
         if ( copletId == null ) {
             // determine coplet id
             if (context != null) {
@@ -106,7 +106,7 @@
         }
 
         CopletInstanceData object = this.portalService.getComponentManager().getProfileManager().getCopletInstanceData(
copletId );
-            
+
         return object;
     }
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Mon Nov 14 03:09:50 2005
@@ -100,6 +100,7 @@
      */
     public CopletTransformer() {
         this.defaultNamespaceURI = NAMESPACE_URI;
+        this.removeOurNamespacePrefixes = true;
     }
 
     /**
@@ -219,7 +220,7 @@
         } else if ( name.equals(CONTENT_ELEM) && this.insideLinks ) {
             this.startSAXRecording();
         } else {
-            super.startTransformingElement(uri, name, raw, attr);
+            throw new SAXException("Unknown element '"+name+"' in namespace '"+NAMESPACE_URI+"'.");
         }
     }
 
@@ -270,7 +271,7 @@
         } else if ( name.equals(CONTENT_ELEM) && this.insideLinks ) {
             this.content = this.endSAXRecording();
         } else if (!name.equals(COPLET_ELEM) && !name.equals(PARAMETER_ELEM)) {
-            super.endTransformingElement(uri, name, raw);
+            throw new SAXException("Unknown element '"+name+"' in namespace '"+NAMESPACE_URI+"'.");
         }
     }
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLEventLinkTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLEventLinkTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLEventLinkTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLEventLinkTransformer.java
Mon Nov 14 03:09:50 2005
@@ -33,9 +33,9 @@
  * that only contain an anchor are ignored.
  * In addition if a link has the attribute "external" with the value
  * "true", the link is also ignored.
- * 
+ *
  * TODO: Support target attribute
- * 
+ *
  * @version $Id$
  */
 public class HTMLEventLinkTransformer
@@ -47,7 +47,7 @@
     /** The jxpath for the attribute */
     protected String jxPath;
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
      */
     public void setup(SourceResolver resolver,
@@ -60,7 +60,7 @@
         this.jxPath = "temporaryAttributes/" + this.attributeName;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
org.xml.sax.Attributes)
      */
     public void startElement(String uri, String name, String raw, Attributes attr)
@@ -86,7 +86,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
      */
     public void endElement(String uri, String name, String raw)
@@ -156,7 +156,6 @@
                 CopletTransformer.LINK_ELEM,
                 "coplet:" + CopletTransformer.LINK_ELEM,
                 newAttributes);
-
     }
 
     protected String getLink(String base, String link) {
@@ -207,5 +206,4 @@
         }
         return false;
     }
-    
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLRootTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLRootTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLRootTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/HTMLRootTransformer.java
Mon Nov 14 03:09:50 2005
@@ -50,14 +50,14 @@
 
     /** the operating mode: true means adding the root elements, false means removing them
*/
     protected boolean addMode;
-        
+
     /** do we remove the root tag? */
     protected boolean ignoreRootElement;
     protected int     ignoreRootElementCount;
 
     protected boolean insideBodyTag;
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
      */
     public void setup(SourceResolver resolver,
@@ -71,7 +71,7 @@
         this.insideBodyTag = false;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.xml.sax.ContentHandler#endDocument()
      */
     public void endDocument() throws SAXException {
@@ -82,7 +82,7 @@
         super.endDocument();
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.xml.sax.ContentHandler#startDocument()
      */
     public void startDocument() throws SAXException {
@@ -93,7 +93,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
org.xml.sax.Attributes)
      */
     public void startElement(String uri, String local, String qName, Attributes attr) throws
SAXException {
@@ -108,7 +108,7 @@
         this.ignoreRootElementCount++;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
      */
     public void endElement(String uri, String local, String qName) throws SAXException {
@@ -122,8 +122,8 @@
             }
         }
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.xml.sax.ContentHandler#characters(char[], int, int)
      */
     public void characters(char[] c, int start, int len) throws SAXException {
@@ -131,15 +131,15 @@
             super.characters(c, start, len);
         }
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.cocoon.caching.CacheableProcessingComponent#getKey()
      */
     public Serializable getKey() {
         return new Boolean[] { BooleanUtils.toBooleanObject(this.addMode), BooleanUtils.toBooleanObject(this.ignoreRootElement)};
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.caching.CacheableProcessingComponent#getValidity()
      */
     public SourceValidity getValidity() {

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
Mon Nov 14 03:09:50 2005
@@ -17,10 +17,11 @@
 
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.event.impl.CopletLinkEvent;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.XMLUtils;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
 
 /**
  * This transformer is used to replace links (URIs) from elements
@@ -80,6 +81,7 @@
      */
     public NewEventLinkTransformer() {
         this.defaultNamespaceURI = NAMESPACE_URI;
+        this.removeOurNamespacePrefixes = true;
     }
 
     /**
@@ -118,22 +120,11 @@
                     + ".");
         }
 
-        //remove ATTRIBUTE_ATTR and ELEMENT_ATTR from attributes
-        AttributesImpl newAttributes = null;
-
-        if (attributes instanceof AttributesImpl) {
-            newAttributes = (AttributesImpl) attributes;
-        } else {
-            newAttributes = new AttributesImpl(attributes);
-        }
-
-        //always iterate backwards when removing elements!
-        for (int i = newAttributes.getLength() - 1; i >= 0; i--) {
-            if (ELEMENT_ATTR.equals(attributes.getLocalName(i))
-                || ATTRIBUTE_ATTR.equals(attributes.getLocalName(i))) {
-                newAttributes.removeAttribute(i);
-            }
-        }
+        // remove ATTRIBUTE_ATTR, ELEMENT_ATTR and "coplet" from attributes
+        AttributesImpl newAttributes = this.getMutableAttributes(attributes);
+        newAttributes.removeAttribute(ELEMENT_ATTR);
+        newAttributes.removeAttribute(ATTRIBUTE_ATTR);
+        newAttributes.removeAttribute("coplet");
 
         int index = newAttributes.getIndex(attributeName);
         String link = newAttributes.getValue(index);
@@ -189,13 +180,9 @@
 
         this.stack.push(elementName);
 
-        contentHandler.startElement(
-            "",
-            elementName,
-            elementName,
-            newAttributes);
+        XMLUtils.createElement(contentHandler, elementName, newAttributes);
 
-        //generate hidden inputs to add request parameters to the form action
+        // generate hidden inputs to add request parameters to the form action
         if (formSpecialTreatment) {
             sendHiddenFields(contentHandler, portalAction, portalEvent);
         }
@@ -216,28 +203,17 @@
                                   String portalEvent)
     throws SAXException {
         AttributesImpl attributes = new AttributesImpl();
-        attributes.addAttribute("", "type", "type", "CDATA", "hidden");
-        attributes.addAttribute(
-            "",
-            "name",
-            "name",
-            "CDATA",
-            "cocoon-portal-action");
-        attributes.addAttribute("", "value", "value", "CDATA", portalAction);
-        contentHandler.startElement("", "input", "input", attributes);
-        contentHandler.endElement("", "input", "input");
-
-        attributes = new AttributesImpl();
-        attributes.addAttribute("", "type", "type", "CDATA", "hidden");
-        attributes.addAttribute(
-            "",
-            "name",
-            "name",
-            "CDATA",
-            "cocoon-portal-event");
-        attributes.addAttribute("", "value", "value", "CDATA", portalEvent);
-        contentHandler.startElement("", "input", "input", attributes);
-        contentHandler.endElement("", "input", "input");
+        if ( portalAction != null && portalAction.trim().length() > 0 ) {
+            attributes.addCDATAAttribute("type", "hidden");
+            attributes.addCDATAAttribute("name", "cocoon-portal-action");
+            attributes.addCDATAAttribute("value", portalAction);
+            XMLUtils.createElement(contentHandler, "input", attributes);
+            attributes.clear();
+        }
+        attributes.addCDATAAttribute("type", "hidden");
+        attributes.addCDATAAttribute("name", "cocoon-portal-event");
+        attributes.addCDATAAttribute("value", portalEvent);
+        XMLUtils.createElement(contentHandler, "input", attributes);
     }
 
     /**
@@ -245,7 +221,6 @@
      */
     public void endTransformingElement(String uri, String name, String raw)
     throws SAXException {
-        String elementName = (String) this.stack.pop();
-        contentHandler.endElement("", elementName, elementName);
+        XMLUtils.createElement(contentHandler, (String) this.stack.pop());
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
Mon Nov 14 03:09:50 2005
@@ -89,7 +89,7 @@
 
     /** The default value for the envelope Tag. */
     protected String defaultEnvelopeTag;
-    
+
     /** This tag will include the external XHMTL. */
     protected String envelopeTag;
 
@@ -184,7 +184,6 @@
      * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
      */
     public void recycle() {
-        super.recycle();
         this.envelopeTag = null;
         this.userAgent = null;
         this.documentBase = null;
@@ -192,17 +191,17 @@
         this.request = null;
         this.parameters = null;
         this.copletInstanceData = null;
+        super.recycle();
     }
 
     /**
      * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
      */
-    public void startElement(
-        String uri,
-        String name,
-        String raw,
-        Attributes attributes)
-        throws SAXException {
+    public void startElement(String uri,
+                             String name,
+                             String raw,
+                             Attributes attributes)
+    throws SAXException {
         super.startElement(uri, name, raw, attributes);
 
         if (name.equalsIgnoreCase(this.envelopeTag)) {
@@ -323,7 +322,7 @@
      * Check the http status code of the http response to detect any redirects.
      * @param connection The HttpURLConnection
      * @param documentBase The current documentBase (needed for relative redirects)
-     * @return the redirected URL or null if no redirects are detected.
+     * @return The redirected URL or null if no redirects are detected.
      * @throws IOException if exceptions occure while analysing the response
      */
     protected String checkForRedirect(HttpURLConnection connection,

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/RSSTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/RSSTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/RSSTransformer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/RSSTransformer.java
Mon Nov 14 03:09:50 2005
@@ -48,15 +48,15 @@
 extends AbstractSAXTransformer
 implements CacheableProcessingComponent {
 
-    /** The xmlizer for converting html to xml */
+    /** The xmlizer for converting html to xml. */
     protected XMLizer xmlizer;
-    
-    /** The xml deserializer */
+
+    /** The xml deserializer. */
     protected XMLDeserializer deserializer;
-    
+
     /** The filter */
     protected XMLConsumer filter;
-    
+
     /**
      *  receive notification of start element event.
      **/
@@ -76,7 +76,7 @@
         if ("description".equals(name)) {
             final String text = this.endTextRecording();
             final String html = "<html><body>"+text+"</body></html>";
-            
+
             Object parsed = null;            
             XMLSerializer serializer = null; 
             try {
@@ -103,7 +103,7 @@
         super.endElement(uri,name,raw);
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
      */
     public void recycle() {
@@ -115,7 +115,7 @@
         super.recycle();
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
      */
     public void setup(SourceResolver resolver,
@@ -133,9 +133,9 @@
     }
 
    static class HTMLFilter extends IncludeXMLConsumer {
-       
+
        int bodyCount = 0;
-       
+
        public HTMLFilter(XMLConsumer consumer) {
            super(consumer);
        }
@@ -157,30 +157,28 @@
                super.endElement(uri, local, qName );
            } 
        }
-
    }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.transformation.AbstractSAXTransformer#setupTransforming()
      */
     public void setupTransforming()
-        throws IOException, ProcessingException, SAXException {
+    throws IOException, ProcessingException, SAXException {
         super.setupTransforming();
         this.filter = new HTMLFilter( this.xmlConsumer );
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.caching.CacheableProcessingComponent#getKey()
      */
     public Serializable getKey() {
         return "1";
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.caching.CacheableProcessingComponent#getValidity()
      */
     public SourceValidity getValidity() {
         return NOPValidity.SHARED_INSTANCE;
     }
-
 }

Modified: cocoon/trunk/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java Mon
Nov 14 03:09:50 2005
@@ -230,18 +230,20 @@
      */
     private String ourPrefix;
 
-    //
-    // Lifecycle
-    //
+    /**
+     * Remove namespace prefixes for our namespace?
+     * @since 2.2
+     */
+    protected boolean removeOurNamespacePrefixes = false;
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see Configurable#configure(Configuration)
      */
     public void configure(Configuration configuration) throws ConfigurationException {
@@ -262,7 +264,7 @@
         tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(SourceResolver, Map, String,
Parameters)
      */
     public void setup(SourceResolver resolver,
@@ -270,7 +272,6 @@
                       String         src,
                       Parameters     params)
     throws ProcessingException, SAXException, IOException {
-
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Setup resolver=" + resolver +
                               ", objectModel=" + objectModel +
@@ -302,7 +303,7 @@
         this.ignoreEmptyCharacters = false;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
      */
     public void recycle() {
@@ -322,6 +323,9 @@
         super.recycle();
     }
 
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
     public void dispose() {
         this.manager = null;
     }
@@ -380,14 +384,18 @@
      */
     public void startPrefixMapping(String prefix, String uri)
     throws SAXException {
+        boolean isOurPrefix = false;
         if (prefix != null) {
             this.namespaces.add(new String[] {prefix, uri});
         }
         if (namespaceURI.equals(uri)) {
             this.ourPrefix = prefix;
+            isOurPrefix = true;
         }
         if (this.ignoreEventsCount == 0) {
-            super.startPrefixMapping(prefix, uri);
+            if ( !removeOurNamespacePrefixes || !isOurPrefix) {
+                super.startPrefixMapping(prefix, uri);
+            }
         }
     }
 
@@ -397,7 +405,7 @@
      */
     public void endPrefixMapping(String prefix)
     throws SAXException {
-
+        boolean isOurPrefix = false;
         if (prefix != null) {
             // Find and remove the namespace prefix
             boolean found = false;
@@ -414,6 +422,7 @@
             }
 
             if (prefix.equals(this.ourPrefix)) {
+                isOurPrefix = true;
                 // Reset our current prefix
                 this.ourPrefix = null;
 
@@ -429,7 +438,9 @@
         }
 
         if (this.ignoreEventsCount == 0) {
-            super.endPrefixMapping(prefix);
+            if ( !removeOurNamespacePrefixes || !isOurPrefix) {
+                super.endPrefixMapping(prefix);
+            }
         }
     }
 
@@ -1020,7 +1031,6 @@
      */
     public void sendParametersEvents(SourceParameters pars)
     throws SAXException {
-
         if (pars != null) {
             Iterator names = pars.getParameterNames();
             while (names.hasNext()) {

Modified: cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java Mon Nov
14 03:09:50 2005
@@ -180,15 +180,13 @@
     /** Remember the start time of the request for profiling */
     protected long startTime;
 
-    /** A {@link NamespacesTable} used to filter namespace declarations. */
-    protected NamespacesTable namespaces;
-
     /**
      * Constructor
      * Set the namespace
      */
     public CIncludeTransformer() {
         this.defaultNamespaceURI = CINCLUDE_NAMESPACE_URI;
+        this.removeOurNamespacePrefixes = true;
     }
 
     /**
@@ -208,7 +206,6 @@
             getLogger().debug("Starting, session " + this.cachingSession);
             this.startTime = System.currentTimeMillis();
         }
-        this.namespaces = new NamespacesTable();
     }
 
     /**
@@ -256,7 +253,6 @@
             this.startTime = 0;
         }
         this.filter = null;
-        this.namespaces = null;
 
         super.recycle();
     }
@@ -663,41 +659,6 @@
             }
         }
         super.endDocument();
-    }
-
-    /**
-     * <p>Receive notification of the start of a prefix mapping.</p>
-     *
-     * <p>This transformer will remove all prefix mapping declarations for those
-     * prefixes associated with the <code>http://apache.org/cocoon/include/1.0</code>
-     * namespace.</p>
-     *
-     * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
-     */
-    public void startPrefixMapping(String prefix, String nsuri)
-    throws SAXException {
-        // Skipping mapping for our namespace
-        this.namespaces.addDeclaration(prefix, nsuri);
-        if (!CINCLUDE_NAMESPACE_URI.equals(nsuri)) {
-            super.startPrefixMapping(prefix, nsuri);
-        }
-    }
-
-    /**
-     * <p>Receive notification of the end of a prefix mapping.</p>
-     *
-     * <p>This transformer will remove all prefix mapping declarations for those
-     * prefixes associated with the <code>http://apache.org/cocoon/include/1.0</code>
-     * namespace.</p>
-     *
-     * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
-     */
-    public void endPrefixMapping(String prefix)
-    throws SAXException {
-        Declaration d = this.namespaces.removeDeclaration(prefix);
-        if ( d == null || !CINCLUDE_INCLUDE_ELEMENT.equals(d.getUri()) ) {
-            super.endPrefixMapping(prefix);
-        }
     }
 
     /**

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=344101&r1=344100&r2=344101&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Mon Nov 14 03:09:50 2005
@@ -175,6 +175,12 @@
   <!-- These are the changes from the last 2.1.x version. -->
  <changes>
   <release version="@version@" date="@date@">
+    <action dev="CZ" type="update">
+      AbstractSAXTransformer supports removal of own namespace prefixes.
+    </action>
+    <action dev="CZ" type="update">
+      CInclude transformer now removes its namespace prefixes.
+    </action>
     <action dev="AN" type="add" fixes-bug="COCOON-1616">
       Source that declares namespace fails JXPath/Linkrewriter/Input Modules.
     </action>



Mime
View raw message