Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 26643 invoked from network); 29 Aug 2005 17:42:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Aug 2005 17:42:37 -0000 Received: (qmail 22265 invoked by uid 500); 29 Aug 2005 17:42:37 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 22214 invoked by uid 500); 29 Aug 2005 17:42:37 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 22201 invoked by uid 99); 29 Aug 2005 17:42:36 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 29 Aug 2005 10:42:36 -0700 Received: (qmail 20547 invoked by uid 65534); 29 Aug 2005 12:15:55 -0000 Message-ID: <20050829121555.20543.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r264123 - in /cocoon/trunk: src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java src/java/org/apache/cocoon/transformation/CIncludeTransformer.java status.xml Date: Mon, 29 Aug 2005 12:15:54 -0000 To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: cziegeler Date: Mon Aug 29 05:15:47 2005 New Revision: 264123 URL: http://svn.apache.org/viewcvs?rev=264123&view=rev Log: Add possibility to remove comments to all text based serializers and to cinclude transformer. Modified: cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java cocoon/trunk/status.xml Modified: cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java?rev=264123&r1=264122&r2=264123&view=diff ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java Mon Aug 29 05:15:47 2005 @@ -27,6 +27,7 @@ import org.apache.cocoon.xml.XMLConsumer; import org.apache.cocoon.xml.XMLUtils; +import org.apache.commons.lang.BooleanUtils; import org.apache.excalibur.source.SourceValidity; import org.apache.excalibur.source.impl.validity.NOPValidity; import org.xml.sax.Attributes; @@ -86,6 +87,18 @@ */ private String cachingKey = "1"; + /** + * Do we remove all comments? + */ + private boolean removeComments = false; + + /** + * If we remove comments, do we keep the document comment? + */ + private boolean keepDocumentComment = true; + + /** Did we get the root element already? */ + private boolean gotRootElement = false; /** * Interpose namespace pipe if needed. @@ -257,14 +270,25 @@ } catch (Exception e) { getLogger().warn("Cannot know if transformer needs namespaces attributes - assuming NO.", e); } + + this.removeComments = conf.getChild("remove-comments").getValueAsBoolean(this.removeComments); + this.keepDocumentComment = conf.getChild("keep-document-comment").getValueAsBoolean(this.keepDocumentComment); + if ( this.getLogger().isDebugEnabled() ) { + this.getLogger().debug("Comment settings: remove comments: " + this.removeComments + + ", keep document comment: " + this.keepDocumentComment); + } } + /** + * @see org.apache.avalon.excalibur.pool.Recyclable#recycle() + */ public void recycle() { super.recycle(); if (this.namespacePipe != null) { this.namespacePipe.recycle(); } + this.gotRootElement = false; } /** @@ -335,7 +359,7 @@ getLogger().debug("Trax handler " + handler.getClass().getName() + msg); - needsNamespaceCache.put(factory.getClass().getName(), new Boolean(needsIt)); + needsNamespaceCache.put(factory.getClass().getName(), BooleanUtils.toBooleanObject(needsIt)); return needsIt; } @@ -554,6 +578,23 @@ // } catch (IOException ignored) { // } // } + } + + /** + * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int) + */ + public void comment(char[] ch, int start, int len) throws SAXException { + if ( !this.removeComments + || (!this.gotRootElement && this.keepDocumentComment)) { + super.comment(ch, start, len); + } + } + /** + * @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 loc, String raw, Attributes a) throws SAXException { + this.gotRootElement = true; + super.startElement(uri, loc, raw, a); } } 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=264123&r1=264122&r2=264123&view=diff ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java Mon Aug 29 05:15:47 2005 @@ -32,6 +32,7 @@ import org.apache.cocoon.xml.XMLConsumer; import org.apache.cocoon.xml.XMLUtils; +import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; @@ -182,7 +183,7 @@ * Set the namespace */ public CIncludeTransformer() { - super.defaultNamespaceURI = CINCLUDE_NAMESPACE_URI; + this.defaultNamespaceURI = CINCLUDE_NAMESPACE_URI; } /** @@ -276,8 +277,8 @@ if (ignoreErrors == null || ignoreErrors.length() == 0) { ignoreErrors = "false"; } - this.stack.push(new Boolean(this.ignoreEmptyCharacters)); - this.stack.push(new Boolean(this.ignoreWhitespaces)); + this.stack.push(BooleanUtils.toBooleanObject(this.ignoreEmptyCharacters)); + this.stack.push(BooleanUtils.toBooleanObject(this.ignoreWhitespaces)); this.stack.push(ignoreErrors); this.ignoreEmptyCharacters = false; @@ -537,8 +538,8 @@ int length = list.getLength(); for (int i=0; i + + Add possibility to remove comments to all text based serializers and to cinclude transformer. + Updated hsqldb to 1.8.0.2.