Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 85445 invoked from network); 7 Oct 2004 13:27:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Oct 2004 13:27:57 -0000 Received: (qmail 73142 invoked by uid 500); 7 Oct 2004 13:27:28 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 72986 invoked by uid 500); 7 Oct 2004 13:27:27 -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: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 72941 invoked by uid 99); 7 Oct 2004 13:27:26 -0000 X-ASF-Spam-Status: No, hits=-10.0 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.28) with SMTP; Thu, 07 Oct 2004 06:27:26 -0700 Received: (qmail 84737 invoked by uid 65534); 7 Oct 2004 13:27:24 -0000 Date: 7 Oct 2004 13:27:24 -0000 Message-ID: <20041007132724.84734.qmail@minotaur.apache.org> From: vgritsenko@apache.org To: cvs@cocoon.apache.org Subject: svn commit: rev 53967 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: vgritsenko Date: Thu Oct 7 06:27:23 2004 New Revision: 53967 Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java Log: Add new "SAX event": xmlizable. Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java Thu Oct 7 06:27:23 2004 @@ -1,12 +1,12 @@ /* * 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. @@ -29,7 +29,7 @@ * Any {name} expression inside of the character events can be * replaced by the content of another SaxBuffer if it is present in the map * passed to the {@link #toSAX(ContentHandler, Map)} method. - * + * * @author Vadim Gritsenko * @version CVS $Id$ */ @@ -62,7 +62,7 @@ if (i > start) { addBit(new Characters(ch, start, i - start)); } - + // Find closing brace, and construct parameter name StringBuffer name = new StringBuffer(); int j = i + 1; @@ -76,14 +76,14 @@ throw new SAXException("Unclosed '}'"); } addBit(new Parameter(name.toString())); - + // Continue processing i = j; start = j + 1; continue; } } - + // Send any tailing characters if (start < end) { addBit(new Characters(ch, start, end - start)); @@ -123,7 +123,7 @@ } public void dump(Writer writer) throws IOException { - writer.write("[ParamSaxBuffer.Parameter] name=" + name); + writer.write("[Parameter] name=" + name); } } } Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java Thu Oct 7 06:27:23 2004 @@ -161,6 +161,13 @@ // /** + * Add a bit containing XMLizable object + */ + public void xmlizable(XMLizable xml) { + saxbits.add(new XMLizableBit(xml)); + } + + /** * @return true if buffer is empty */ public boolean isEmpty() { @@ -534,6 +541,28 @@ public void dump(Writer writer) throws IOException { writer.write("[IgnorableWhitespace] ch=" + new String(ch) + "\n"); + } + } + + public final static class XMLizableBit implements SaxBit, Serializable { + public final XMLizable xml; + + public XMLizableBit(XMLizable xml) { + this.xml = xml; + } + + public void send(ContentHandler contentHandler) throws SAXException { + this.xml.toSAX(new EmbeddedXMLPipe(contentHandler)); + } + + public void dump(Writer writer) throws IOException { + if (xml instanceof SaxBuffer) { + writer.write("[XMLizable] Begin nested SaxBuffer\n"); + ((SaxBuffer)xml).dump(writer); + writer.write("[XMLizable] End nested SaxBuffer\n"); + } else { + writer.write("[XMLizable] xml=" + xml + "\n"); + } } } }