cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [67/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/log/package.html
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/log/package.html?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/log/package.html (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/log/package.html Thu Nov  3 05:41:06 2005
@@ -0,0 +1,25 @@
+<!--
+  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.
+-->
+<html>
+<head>
+ <title>LogKit related utilities</title>
+</head>
+<body>
+ <h1>LogKit related utilities</h1>
+ <p>
+ </p>
+</body>
+</html>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/log/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/mime.types
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/mime.types?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/mime.types (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/mime.types Thu Nov  3 05:41:06 2005
@@ -0,0 +1,28 @@
+# MIME type mappings
+text/plain  txt text
+text/html   html htm
+text/xml    xml
+text/css    css
+text/rtf    rtf
+application/rtf rtf
+text/vnd.wap.wml    wml
+image/jpeg  jpeg jpg jpe
+image/png   png
+image/gif   gif
+image/tiff  tiff tif
+image/svg+xml   svg svgz
+image/svg-xml   svg
+application/pdf pdf
+model/vrml  wrl
+application/smil    smil
+text/javascript js
+application/x-javascript    js
+text/vbscript   vbs
+application/zip zip
+video/mpeg  mpeg mpg mpe
+video/quicktime mov
+audio/midi  mid
+audio/mpeg  mp3
+text/x-vcard    vcf
+text/rdf    rdf
+application/octet-stream

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/util/mime.types
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractDOMFragment.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractDOMFragment.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractDOMFragment.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractDOMFragment.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,72 @@
+/*
+ * 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.xml;
+
+import org.apache.cocoon.xml.dom.DOMStreamer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * Abstract implementation of {@link XMLFragment} for objects that are more
+ * easily represented as a DOM.
+ *
+ * <p>The {@link #toSAX} method is implemented by streaming (using a
+ * {@link DOMStreamer}) the results of the {@link #toDOM} that must be
+ * implemented by concrete subclasses.</p>
+ *
+ * @author <a href="mailto:sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
+ * @version CVS $Id: AbstractDOMFragment.java 55391 2004-10-23 18:15:02Z cziegeler $
+ */
+public abstract class AbstractDOMFragment implements XMLFragment {
+
+    /**
+     * Generates SAX events representing the object's state by serializing the
+     * result of <code>toDOM()</code>.
+     */
+    public void toSAX(ContentHandler handler) throws SAXException {
+        // The ServiceManager is unknown here : use JAXP to create a document
+        DocumentBuilder builder;
+        try {
+            builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        } catch (ParserConfigurationException e) {
+            throw new SAXException("Couldn't get a DocumentBuilder", e);
+        }
+
+        Document doc = builder.newDocument();
+
+        // Create a DocumentFragment that will hold the results of toDOM()
+        // (which can create several top-level elements)
+        Node df = doc.createDocumentFragment();
+
+        // Build the DOM representation of this object
+        try {
+            toDOM(df);
+        } catch(Exception e) {
+            throw new SAXException("Exception while converting object to DOM", e);
+        }
+
+        // Stream the document fragment
+        handler.startDocument();
+        new DOMStreamer(handler).stream(df);
+        handler.endDocument();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractDOMFragment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,41 @@
+/*
+ * 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.xml;
+
+import org.apache.cocoon.xml.dom.DOMBuilder;
+import org.w3c.dom.Node;
+
+/**
+ * Abstract implementation of {@link XMLFragment} for objects that are more
+ * easily represented as SAX events.
+ *
+ * <p>The {@link #toDOM} method is implemented by piping in a {@link DOMBuilder}
+ * the results of {@link #toSAX} that must be implemented by concrete
+ * subclasses.</p>
+ *
+ * @author <a href="mailto:sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
+ * @version CVS $Id: AbstractSAXFragment.java 53979 2004-10-07 14:26:29Z vgritsenko $
+ */
+public abstract class AbstractSAXFragment implements XMLFragment {
+
+    /**
+     * Appends children representing the object's state to the given node
+     * by using the results of <code>toSAX()</code>.
+     */
+    public void toDOM(Node node) throws Exception {
+        toSAX(new DOMBuilder(node));
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,215 @@
+/*
+ * 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.xml;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * This abstract class provides default implementation of the methods specified
+ * by the <code>XMLConsumer</code> interface.
+ *
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
+ *         (Apache Software Foundation)
+ * @version CVS $Id: AbstractXMLConsumer.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public abstract class AbstractXMLConsumer extends AbstractLogEnabled implements XMLConsumer {
+
+    /**
+     * Receive an object for locating the origin of SAX document events.
+     *
+     * @param locator An object that can return the location of any SAX
+     *                document event.
+     */
+    public void setDocumentLocator(Locator locator) {
+    }
+
+    /**
+     * Receive notification of the beginning of a document.
+     */
+    public void startDocument()
+    throws SAXException {
+    }
+
+    /**
+     * Receive notification of the end of a document.
+     */
+    public void endDocument()
+    throws SAXException {
+    }
+
+    /**
+     * Begin the scope of a prefix-URI Namespace mapping.
+     *
+     * @param prefix The Namespace prefix being declared.
+     * @param uri The Namespace URI the prefix is mapped to.
+     */
+    public void startPrefixMapping(String prefix, String uri)
+    throws SAXException {
+    }
+
+    /**
+     * End the scope of a prefix-URI mapping.
+     *
+     * @param prefix The prefix that was being mapping.
+     */
+    public void endPrefixMapping(String prefix)
+    throws SAXException {
+    }
+
+    /**
+     * Receive notification of the beginning of an element.
+     *
+     * @param uri The Namespace URI, or the empty string if the element has no
+     *            Namespace URI or if Namespace
+     *            processing is not being performed.
+     * @param loc The local name (without prefix), or the empty string if
+     *            Namespace processing is not being performed.
+     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
+     *            raw names are not available.
+     * @param a The attributes attached to the element. If there are no
+     *          attributes, it shall be an empty Attributes object.
+     */
+    public void startElement(String uri, String loc, String raw, Attributes a)
+    throws SAXException {
+    }
+
+
+    /**
+     * Receive notification of the end of an element.
+     *
+     * @param uri The Namespace URI, or the empty string if the element has no
+     *            Namespace URI or if Namespace
+     *            processing is not being performed.
+     * @param loc The local name (without prefix), or the empty string if
+     *            Namespace processing is not being performed.
+     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
+     *            raw names are not available.
+     */
+    public void endElement(String uri, String loc, String raw)
+    throws SAXException {
+    }
+
+    /**
+     * Receive notification of character data.
+     *
+     * @param ch The characters from the XML document.
+     * @param start The start position in the array.
+     * @param len The number of characters to read from the array.
+     */
+    public void characters(char ch[], int start, int len)
+    throws SAXException {
+    }
+
+    /**
+     * Receive notification of ignorable whitespace in element content.
+     *
+     * @param ch The characters from the XML document.
+     * @param start The start position in the array.
+     * @param len The number of characters to read from the array.
+     */
+    public void ignorableWhitespace(char ch[], int start, int len)
+    throws SAXException {
+    }
+
+    /**
+     * Receive notification of a processing instruction.
+     *
+     * @param target The processing instruction target.
+     * @param data The processing instruction data, or null if none was
+     *             supplied.
+     */
+    public void processingInstruction(String target, String data)
+    throws SAXException {
+    }
+
+    /**
+     * Receive notification of a skipped entity.
+     *
+     * @param name The name of the skipped entity.  If it is a  parameter
+     *             entity, the name will begin with '%'.
+     */
+    public void skippedEntity(String name)
+    throws SAXException {
+    }
+
+    /**
+     * Report the start of DTD declarations, if any.
+     *
+     * @param name The document type name.
+     * @param publicId The declared public identifier for the external DTD
+     *                 subset, or null if none was declared.
+     * @param systemId The declared system identifier for the external DTD
+     *                 subset, or null if none was declared.
+     */
+    public void startDTD(String name, String publicId, String systemId)
+    throws SAXException {
+    }
+
+    /**
+     * Report the end of DTD declarations.
+     */
+    public void endDTD()
+    throws SAXException {
+    }
+
+    /**
+     * Report the beginning of an entity.
+     *
+     * @param name The name of the entity. If it is a parameter entity, the
+     *             name will begin with '%'.
+     */
+    public void startEntity(String name)
+    throws SAXException {
+    }
+
+    /**
+     * Report the end of an entity.
+     *
+     * @param name The name of the entity that is ending.
+     */
+    public void endEntity(String name)
+    throws SAXException {
+    }
+
+    /**
+     * Report the start of a CDATA section.
+     */
+    public void startCDATA()
+    throws SAXException {
+    }
+
+    /**
+     * Report the end of a CDATA section.
+     */
+    public void endCDATA()
+    throws SAXException {
+    }
+
+
+    /**
+     * Report an XML comment anywhere in the document.
+     *
+     * @param ch An array holding the characters in the comment.
+     * @param start The starting position in the array.
+     * @param len The number of characters to use from the array.
+     */
+    public void comment(char ch[], int start, int len)
+    throws SAXException {
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,231 @@
+/*
+ * 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.xml;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * This class provides a bridge class to connect to existing content
+ * handlers and lexical handlers.
+ *
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @version CVS $Id: AbstractXMLPipe.java 233343 2005-08-18 18:06:44Z sylvain $
+ */
+public abstract class AbstractXMLPipe extends AbstractXMLProducer
+                                      implements XMLPipe {
+
+    /**
+     * Receive an object for locating the origin of SAX document events.
+     *
+     * @param locator An object that can return the location of any SAX
+     *                document event.
+     */
+    public void setDocumentLocator(Locator locator) {
+        contentHandler.setDocumentLocator(locator);
+    }
+
+    /**
+     * Receive notification of the beginning of a document.
+     */
+    public void startDocument()
+    throws SAXException {
+        contentHandler.startDocument();
+    }
+
+    /**
+     * Receive notification of the end of a document.
+     */
+    public void endDocument()
+    throws SAXException {
+        contentHandler.endDocument();
+    }
+
+    /**
+     * Begin the scope of a prefix-URI Namespace mapping.
+     *
+     * @param prefix The Namespace prefix being declared.
+     * @param uri The Namespace URI the prefix is mapped to.
+     */
+    public void startPrefixMapping(String prefix, String uri)
+    throws SAXException {
+        contentHandler.startPrefixMapping(prefix, uri);
+    }
+
+    /**
+     * End the scope of a prefix-URI mapping.
+     *
+     * @param prefix The prefix that was being mapping.
+     */
+    public void endPrefixMapping(String prefix)
+    throws SAXException {
+        contentHandler.endPrefixMapping(prefix);
+    }
+
+    /**
+     * Receive notification of the beginning of an element.
+     *
+     * @param uri The Namespace URI, or the empty string if the element has no
+     *            Namespace URI or if Namespace
+     *            processing is not being performed.
+     * @param loc The local name (without prefix), or the empty string if
+     *            Namespace processing is not being performed.
+     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
+     *            raw names are not available.
+     * @param a The attributes attached to the element. If there are no
+     *          attributes, it shall be an empty Attributes object.
+     */
+    public void startElement(String uri, String loc, String raw, Attributes a)
+    throws SAXException {
+        contentHandler.startElement(uri, loc, raw, a);
+    }
+
+
+    /**
+     * Receive notification of the end of an element.
+     *
+     * @param uri The Namespace URI, or the empty string if the element has no
+     *            Namespace URI or if Namespace
+     *            processing is not being performed.
+     * @param loc The local name (without prefix), or the empty string if
+     *            Namespace processing is not being performed.
+     * @param raw The raw XML 1.0 name (with prefix), or the empty string if
+     *            raw names are not available.
+     */
+    public void endElement(String uri, String loc, String raw)
+    throws SAXException {
+        contentHandler.endElement(uri, loc, raw);
+    }
+
+    /**
+     * Receive notification of character data.
+     *
+     * @param c The characters from the XML document.
+     * @param start The start position in the array.
+     * @param len The number of characters to read from the array.
+     */
+    public void characters(char c[], int start, int len)
+    throws SAXException {
+        contentHandler.characters(c, start, len);
+    }
+
+    /**
+     * Receive notification of ignorable whitespace in element content.
+     *
+     * @param c The characters from the XML document.
+     * @param start The start position in the array.
+     * @param len The number of characters to read from the array.
+     */
+    public void ignorableWhitespace(char c[], int start, int len)
+    throws SAXException {
+        contentHandler.ignorableWhitespace(c, start, len);
+    }
+
+    /**
+     * Receive notification of a processing instruction.
+     *
+     * @param target The processing instruction target.
+     * @param data The processing instruction data, or null if none was
+     *             supplied.
+     */
+    public void processingInstruction(String target, String data)
+    throws SAXException {
+        contentHandler.processingInstruction(target, data);
+    }
+
+    /**
+     * Receive notification of a skipped entity.
+     *
+     * @param name The name of the skipped entity.  If it is a  parameter
+     *             entity, the name will begin with '%'.
+     */
+    public void skippedEntity(String name)
+    throws SAXException {
+        contentHandler.skippedEntity(name);
+    }
+
+    /**
+     * Report the start of DTD declarations, if any.
+     *
+     * @param name The document type name.
+     * @param publicId The declared public identifier for the external DTD
+     *                 subset, or null if none was declared.
+     * @param systemId The declared system identifier for the external DTD
+     *                 subset, or null if none was declared.
+     */
+    public void startDTD(String name, String publicId, String systemId)
+    throws SAXException {
+        lexicalHandler.startDTD(name, publicId, systemId);
+    }
+
+    /**
+     * Report the end of DTD declarations.
+     */
+    public void endDTD()
+    throws SAXException {
+        lexicalHandler.endDTD();
+    }
+
+    /**
+     * Report the beginning of an entity.
+     *
+     * @param name The name of the entity. If it is a parameter entity, the
+     *             name will begin with '%'.
+     */
+    public void startEntity(String name)
+    throws SAXException {
+        lexicalHandler.startEntity(name);
+    }
+
+    /**
+     * Report the end of an entity.
+     *
+     * @param name The name of the entity that is ending.
+     */
+    public void endEntity(String name)
+    throws SAXException {
+        lexicalHandler.endEntity(name);
+    }
+
+    /**
+     * Report the start of a CDATA section.
+     */
+    public void startCDATA()
+    throws SAXException {
+        lexicalHandler.startCDATA();
+    }
+
+    /**
+     * Report the end of a CDATA section.
+     */
+    public void endCDATA()
+    throws SAXException {
+        lexicalHandler.endCDATA();
+    }
+
+    /**
+     * Report an XML comment anywhere in the document.
+     *
+     * @param ch An array holding the characters in the comment.
+     * @param start The starting position in the array.
+     * @param len The number of characters to use from the array.
+     */
+    public void comment(char ch[], int start, int len)
+    throws SAXException {
+        lexicalHandler.comment(ch, start, len);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,87 @@
+/*
+ * 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.xml;
+
+import org.apache.avalon.excalibur.pool.Recyclable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * This abstract class provides default implementation of the methods specified
+ * by the <code>XMLProducer</code> interface.
+ *
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
+ *         (Apache Software Foundation)
+ * @version CVS $Id: AbstractXMLProducer.java 225810 2005-07-28 16:11:03Z sylvain $
+ */
+public abstract class AbstractXMLProducer extends AbstractLogEnabled
+                                          implements XMLProducer, Recyclable {
+    
+    protected static final ContentHandler EMPTY_CONTENT_HANDLER = new DefaultHandler();
+
+    /** The <code>XMLConsumer</code> receiving SAX events. */
+    protected XMLConsumer xmlConsumer;
+
+    /** The <code>ContentHandler</code> receiving SAX events. */
+    protected ContentHandler contentHandler = EMPTY_CONTENT_HANDLER;
+
+    /** The <code>LexicalHandler</code> receiving SAX events. */
+    protected LexicalHandler lexicalHandler = DefaultLexicalHandler.NULL_HANDLER;
+
+    /**
+     * Set the <code>XMLConsumer</code> that will receive XML data.
+     * <br>
+     * This method will simply call <code>setContentHandler(consumer)</code>
+     * and <code>setLexicalHandler(consumer)</code>.
+     */
+    public void setConsumer(XMLConsumer consumer) {
+        this.xmlConsumer = consumer;
+        setContentHandler(consumer);
+        setLexicalHandler(consumer);
+    }
+
+    /**
+     * Set the <code>ContentHandler</code> that will receive XML data.
+     * <br>
+     * Subclasses may retrieve this <code>ContentHandler</code> instance
+     * accessing the protected <code>super.contentHandler</code> field.
+     */
+    public void setContentHandler(ContentHandler handler) {
+        this.contentHandler = handler;
+    }
+
+    /**
+     * Set the <code>LexicalHandler</code> that will receive XML data.
+     * <br>
+     * Subclasses may retrieve this <code>LexicalHandler</code> instance
+     * accessing the protected <code>super.lexicalHandler</code> field.
+     */
+    public void setLexicalHandler(LexicalHandler handler) {
+        this.lexicalHandler = handler;
+    }
+
+    /**
+     * Recycle the producer by removing references, and resetting handlers to
+     * null (empty) implementations.
+     */
+    public void recycle() {
+        this.xmlConsumer = null;
+        this.contentHandler = EMPTY_CONTENT_HANDLER;
+        this.lexicalHandler = DefaultLexicalHandler.NULL_HANDLER;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributeTypes.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributeTypes.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributeTypes.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributeTypes.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,41 @@
+/*
+ * 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.xml;
+
+/**
+ * Insert the type's description here.
+ * 
+ * @author <a href="mailto:volker.schmitt@basf-ag.de">Volker Schmitt</a>
+ * @version CVS $Id: AttributeTypes.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public interface AttributeTypes
+{
+    String CDATA = "CDATA";
+    String ENTITY = "ENTITY";
+    String ENTITIES = "ENTITIES";
+    String ID = "ID";
+    String IDREF = "IDREF";
+    String IDREFS = "IDREFS";
+    String NAME = "NAME";
+    String NAMES = "NAMES";
+    String NMTOKEN = "NMTOKEN";
+    String NMTOKENS = "NMTOKENS";
+    String NOTATION = "NOTATION";
+    String NUMBER = "NUMBER";
+    String NUMBERS = "NUMBERS";
+    String NUTOKEN = "NUTOKEN";
+    String NUTOKENS = "NUTOKENS";
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributeTypes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributesImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributesImpl.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributesImpl.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributesImpl.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,114 @@
+/*
+ * 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.xml;
+
+import org.xml.sax.Attributes;
+
+/**
+ * A helper Class creating SAX Attributes
+ * 
+ * @author <a href="mailto:volker.schmitt@basf-ag.de">Volker Schmitt</a>
+ * @version CVS $Id: AttributesImpl.java 230421 2005-08-05 09:29:42Z cziegeler $
+ */
+public class AttributesImpl extends org.xml.sax.helpers.AttributesImpl {
+
+    /**
+     * Constructor
+     */
+    public AttributesImpl() {
+        super();
+    }
+
+    /**
+     *  Constructor
+     */
+    public AttributesImpl(Attributes attr) {
+        super(attr);
+    }
+
+	/**
+	 * Add an attribute of type CDATA with empty Namespace to the end of the list.
+	 *
+	 * <p>For the sake of speed, this method does no checking
+	 * to see if the attribute is already in the list: that is
+	 * the responsibility of the application.</p>
+	 *
+	 * @param localName The local name.
+	 * @param value The attribute value.
+	 */
+	public void addCDATAAttribute(String localName, String value) {
+		addAttribute("", localName, localName, AttributeTypes.CDATA, value);
+	}
+    
+    /**
+     * Add an attribute of type CDATA with the namespace to the end of the list.
+     *
+     * <p>For the sake of speed, this method does no checking
+     * to see if the attribute is already in the list: that is
+     * the responsibility of the application.</p>
+     *
+     * @param namespace The namespace.
+     * @param localName The local name.
+     * @param value The attribute value.
+     */
+    public void addCDATAAttribute(String namespace, String localName, String value) {
+        addAttribute(namespace, localName, localName, AttributeTypes.CDATA, value);
+    }
+
+    /**
+	 * Add an attribute of type CDATA to the end of the list.
+	 *
+	 * <p>For the sake of speed, this method does no checking
+	 * to see if the attribute is already in the list: that is
+	 * the responsibility of the application.</p>
+	 *
+	 * @param uri The Namespace URI, or the empty string if
+	 *        none is available or Namespace processing is not
+	 *        being performed.
+	 * @param localName The local name, or the empty string if
+	 *        Namespace processing is not being performed.
+	 * @param qName The qualified (prefixed) name, or the empty string
+	 *        if qualified names are not available.
+	 * @param value The attribute value.
+	 */
+	public void addCDATAAttribute(String uri,
+                            		String localName,
+                            		String qName,
+                            		String value) {
+		addAttribute(uri, localName, qName, AttributeTypes.CDATA, value);
+	}
+    
+    /**
+     * Remove an attribute
+     */
+    public void removeAttribute(String localName) {
+        final int index = this.getIndex(localName);
+        if ( index != -1 ) {
+            this.removeAttribute(index);
+        }
+    }
+
+    /**
+     * Remove an attribute
+     */
+    public void removeAttribute(String uri, String localName) {
+        final int index = this.getIndex(uri, localName);
+        if ( index != -1 ) {
+            this.removeAttribute(index);
+        }
+    }
+}
+  
\ No newline at end of file

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/AttributesImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,272 @@
+/*
+ * 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.xml;
+
+import org.apache.avalon.excalibur.pool.Recyclable;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * This class is an utility class &quot;wrapping&quot; around a SAX version 2.0
+ * <code>ContentHandler</code> and forwarding it those events received throug
+ * its <code>XMLConsumers</code> interface.
+ * <br>
+ *
+ * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
+ *         (Apache Software Foundation, Computer Associates)
+ * @version CVS $Id: ContentHandlerWrapper.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class ContentHandlerWrapper extends AbstractXMLConsumer implements Recyclable {
+
+    /** The current <code>ContentHandler</code>. */
+    protected ContentHandler contentHandler;
+
+    /** The optional <code>LexicalHandler</code> */
+    protected LexicalHandler lexicalHandler;
+
+    /**
+     * Create a new <code>ContentHandlerWrapper</code> instance.
+     */
+    public ContentHandlerWrapper() {
+        super();
+     }
+
+    /**
+     * Create a new <code>ContentHandlerWrapper</code> instance.
+     */
+    public ContentHandlerWrapper(ContentHandler contentHandler) {
+        this();
+        this.setContentHandler(contentHandler);
+    }
+
+    /**
+     * Create a new <code>ContentHandlerWrapper</code> instance.
+     */
+    public ContentHandlerWrapper(ContentHandler contentHandler,
+                                 LexicalHandler lexicalHandler) {
+        this();
+        this.setContentHandler(contentHandler);
+        this.setLexicalHandler(lexicalHandler);
+    }
+
+    /**
+     * Set the <code>ContentHandler</code> that will receive XML data.
+     *
+     * @exception IllegalStateException If the <code>ContentHandler</code>
+     *                                  was already set.
+     */
+    public void setContentHandler(ContentHandler contentHandler)
+    throws IllegalStateException {
+        if (this.contentHandler!=null) throw new IllegalStateException();
+        this.contentHandler=contentHandler;
+    }
+
+    /**
+     * Set the <code>LexicalHandler</code> that will receive XML data.
+     *
+     * @exception IllegalStateException If the <code>LexicalHandler</code>
+     *                                  was already set.
+     */
+    public void setLexicalHandler(LexicalHandler lexicalHandler)
+    throws IllegalStateException {
+        if (this.lexicalHandler!=null) throw new IllegalStateException();
+        this.lexicalHandler=lexicalHandler;
+    }
+
+    public void recycle () {
+        this.contentHandler = null;
+        this.lexicalHandler = null;
+    }
+
+    /**
+     * Receive an object for locating the origin of SAX document events.
+     */
+    public void setDocumentLocator (Locator locator) {
+        if (this.contentHandler==null) return;
+        else this.contentHandler.setDocumentLocator(locator);
+    }
+
+    /**
+     * Receive notification of the beginning of a document.
+     */
+    public void startDocument ()
+    throws SAXException {
+        if (this.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        this.contentHandler.startDocument();
+    }
+
+    /**
+     * Receive notification of the end of a document.
+     */
+    public void endDocument ()
+    throws SAXException {
+        this.contentHandler.endDocument();
+    }
+
+    /**
+     * Begin the scope of a prefix-URI Namespace mapping.
+     */
+    public void startPrefixMapping(String prefix, String uri)
+    throws SAXException {
+        if (this.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        this.contentHandler.startPrefixMapping(prefix, uri);
+    }
+
+    /**
+     * End the scope of a prefix-URI mapping.
+     */
+    public void endPrefixMapping(String prefix)
+    throws SAXException {
+        this.contentHandler.endPrefixMapping(prefix);
+    }
+
+    /**
+     * Receive notification of the beginning of an element.
+     */
+    public void startElement(String uri, String loc, String raw, Attributes a)
+    throws SAXException {
+        this.contentHandler.startElement(uri, loc, raw, a);
+    }
+
+
+    /**
+     * Receive notification of the end of an element.
+     */
+    public void endElement(String uri, String loc, String raw)
+    throws SAXException {
+        this.contentHandler.endElement(uri, loc, raw);
+    }
+
+    /**
+     * Receive notification of character data.
+     */
+    public void characters(char ch[], int start, int len)
+    throws SAXException {
+        this.contentHandler.characters(ch,start,len);
+    }
+
+    /**
+     * Receive notification of ignorable whitespace in element content.
+     */
+    public void ignorableWhitespace(char ch[], int start, int len)
+    throws SAXException {
+        this.contentHandler.ignorableWhitespace(ch,start,len);
+    }
+
+    /**
+     * Receive notification of a processing instruction.
+     */
+    public void processingInstruction(String target, String data)
+    throws SAXException {
+        this.contentHandler.processingInstruction(target,data);
+    }
+
+    /**
+     * Receive notification of a skipped entity.
+     *
+     * @param name The name of the skipped entity.  If it is a  parameter
+     *             entity, the name will begin with '%'.
+     */
+    public void skippedEntity(String name)
+    throws SAXException {
+        this.contentHandler.skippedEntity(name);
+    }
+
+        /**
+     * Report the start of DTD declarations, if any.
+     *
+     * @param name The document type name.
+     * @param publicId The declared public identifier for the external DTD
+     *                 subset, or null if none was declared.
+     * @param systemId The declared system identifier for the external DTD
+     *                 subset, or null if none was declared.
+     */
+    public void startDTD(String name, String publicId, String systemId)
+    throws SAXException {
+        if (this.lexicalHandler != null)
+            this.lexicalHandler.startDTD(name, publicId, systemId);
+    }
+
+    /**
+     * Report the end of DTD declarations.
+     */
+    public void endDTD()
+    throws SAXException {
+        if (this.lexicalHandler != null)
+            this.lexicalHandler.endDTD();
+    }
+
+    /**
+     * Report the beginning of an entity.
+     *
+     * @param name The name of the entity. If it is a parameter entity, the
+     *             name will begin with '%'.
+     */
+    public void startEntity(String name)
+    throws SAXException {
+        if (this.lexicalHandler != null)
+            this.lexicalHandler.startEntity(name);
+    }
+
+    /**
+     * Report the end of an entity.
+     *
+     * @param name The name of the entity that is ending.
+     */
+    public void endEntity(String name)
+    throws SAXException {
+        if (this.lexicalHandler != null)
+            this.lexicalHandler.endEntity(name);
+    }
+
+    /**
+     * Report the start of a CDATA section.
+     */
+    public void startCDATA()
+    throws SAXException {
+        if (this.lexicalHandler != null)
+            this.lexicalHandler.startCDATA();
+    }
+
+    /**
+     * Report the end of a CDATA section.
+     */
+    public void endCDATA()
+    throws SAXException {
+        if (this.lexicalHandler != null)
+            this.lexicalHandler.endCDATA();
+    }
+
+
+    /**
+     * Report an XML comment anywhere in the document.
+     *
+     * @param ch An array holding the characters in the comment.
+     * @param start The starting position in the array.
+     * @param len The number of characters to use from the array.
+     */
+    public void comment(char ch[], int start, int len)
+    throws SAXException {
+        if (this.lexicalHandler != null)
+            this.lexicalHandler.comment(ch, start, len);
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2005 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.xml;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * Default implementation of SAX's <code>LexicalHandler</code> interface. Empty implementation
+ * of all methods so that you only have to redefine the ones of interest.
+ *
+ * @version $Id: DefaultLexicalHandler.java 225806 2005-07-28 16:01:18Z sylvain $
+ */
+public class DefaultLexicalHandler implements LexicalHandler {
+    
+    /**
+     * Shared instance that can be used when lexical events should be ignored.
+     */
+    public static final LexicalHandler NULL_HANDLER = new DefaultLexicalHandler();
+
+    public void startDTD(String name, String publicId, String systemId) throws SAXException {
+        // nothing
+    }
+
+    public void endDTD() throws SAXException {
+        // nothing
+    }
+
+    public void startEntity(String name) throws SAXException {
+        // nothing
+    }
+
+    public void endEntity(String name) throws SAXException {
+        // nothing
+    }
+
+    public void startCDATA() throws SAXException {
+        // nothing
+    }
+
+    public void endCDATA() throws SAXException {
+        // nothing
+    }
+
+    public void comment(char[] ch, int start, int length) throws SAXException {
+        // nothing
+    }
+}
\ No newline at end of file

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerAdapter.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerAdapter.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerAdapter.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,203 @@
+/*
+ * 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.xml;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.xml.sax.AttributeList;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DocumentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * This class is an utility class &quot;adapting&quot; a SAX version 1.0
+ * <code>DocumentHandler</code>, to SAX version 2 <code>ContentHandler</code>.
+ * <br>
+ * This class fully supports XML namespaces, converting <code>xmlns</code> and
+ * <code>xmlns:...</code> element attributes into appropriate
+ * <code>startPrefixMapping(...)</code> and <code>endPrefixMapping(...)</code>
+ * calls.
+ *
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
+ *         (Apache Software Foundation)
+ * @version CVS $Id: DocumentHandlerAdapter.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class DocumentHandlerAdapter extends AbstractXMLProducer
+implements DocumentHandler {
+
+    /** The element-oriented namespace-uri stacked mapping table. */
+    private Hashtable stackedNS=new Hashtable();
+    /** The current namespaces table. */
+    private NamespacesTable namespaces=new NamespacesTable();
+    /** The current stack depth.*/
+    private int stack=0;
+
+    /**
+     * Create a new <code>DocumentHandlerAdapter</code> instance.
+     */
+    public DocumentHandlerAdapter() {
+        super();
+    }
+
+    /**
+     * Create a new <code>DocumentHandlerAdapter</code> instance.
+     */
+    public DocumentHandlerAdapter(XMLConsumer consumer) {
+        this();
+        super.setConsumer(consumer);
+    }
+
+    /**
+     * Create a new <code>DocumentHandlerAdapter</code> instance.
+     */
+    public DocumentHandlerAdapter(ContentHandler content) {
+        this();
+        super.setContentHandler(content);
+    }
+
+    /**
+     * Receive an object for locating the origin of SAX document events.
+     */
+    public void setDocumentLocator (Locator locator) {
+        if (super.contentHandler==null) return;
+        else super.contentHandler.setDocumentLocator(locator);
+    }
+
+    /**
+     * Receive notification of the beginning of a document.
+     */
+    public void startDocument ()
+        throws SAXException {
+        if (super.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        super.contentHandler.startDocument();
+    }
+
+    /**
+     * Receive notification of the end of a document.
+     */
+    public void endDocument ()
+        throws SAXException {
+        if (super.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        super.contentHandler.endDocument();
+    }
+
+    /**
+     * Receive notification of the beginning of an element.
+     */
+    public void startElement (String name, AttributeList a)
+        throws SAXException {
+        if (super.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        // Check for namespace declarations (two loops because we're not sure
+        // about attribute ordering.
+        AttributesImpl a2=new AttributesImpl();
+        Vector nslist=new Vector();
+        for (int x=0; x<a.getLength(); x++) {
+            String att=a.getName(x);
+            String uri=a.getValue(x);
+            if (att.equals("xmlns") || att.startsWith("xmlns:")) {
+                String pre="";
+                if (att.length()>5) pre=att.substring(6);
+                this.namespaces.addDeclaration(pre,uri);
+                nslist.addElement(pre);
+                super.contentHandler.startPrefixMapping(pre,uri);
+            }
+        }
+        if (nslist.size()>0) this.stackedNS.put(new Integer(this.stack),nslist);
+        // Resolve the element namespaced name
+        NamespacesTable.Name w=this.namespaces.resolve(null,name,null,null);
+        // Second loop through attributes to fill AttributesImpl
+        for (int x=0; x<a.getLength(); x++) {
+            String att=a.getName(x);
+            if (att.equals("xmlns") || att.startsWith("xmlns:")) continue;
+            // We have something different from a namespace declaration
+            NamespacesTable.Name k=this.namespaces.resolve(null,att,null,null);
+            String val=a.getValue(x);
+            String typ=a.getType(x);
+            String uri=k.getPrefix().length()==0?"":k.getUri();
+            a2.addAttribute(uri,k.getLocalName(),k.getQName(),typ,val);
+        }
+        // Notify the contentHandler
+        super.contentHandler.startElement(w.getUri(),w.getLocalName(),
+                                          w.getQName(),a2);
+        // Forward on the stack
+        this.stack++;
+    }
+
+    /**
+     * Receive notification of the end of an element.
+     */
+    public void endElement (String name)
+        throws SAXException {
+        if (super.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+            // Get back on the stack
+            this.stack--;
+        // Notify the contentHandler
+        NamespacesTable.Name w=this.namespaces.resolve(null,name,null,null);
+        super.contentHandler.endElement(w.getUri(),w.getLocalName(),
+                                        w.getQName());
+        // Undeclare namespaces
+        Vector nslist=(Vector)this.stackedNS.remove(new Integer(this.stack));
+        if (nslist==null) return;
+        if (nslist.size()==0) return;
+        Enumeration e=nslist.elements();
+        while (e.hasMoreElements()) {
+            String prefix=(String)e.nextElement();
+            NamespacesTable.Declaration d=namespaces.removeDeclaration(prefix);
+            super.contentHandler.endPrefixMapping(d.getPrefix());
+        }
+    }
+
+
+    /**
+     * Receive notification of character data.
+     */
+    public void characters (char ch[], int start, int len)
+        throws SAXException {
+        if (super.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        super.contentHandler.characters(ch,start,len);
+    }
+
+
+    /**
+     * Receive notification of ignorable whitespace in element content.
+     */
+    public void ignorableWhitespace (char ch[], int start, int len)
+        throws SAXException {
+        if (super.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        super.contentHandler.ignorableWhitespace(ch,start,len);
+    }
+
+
+    /**
+     * Receive notification of a processing instruction.
+     */
+    public void processingInstruction (String target, String data)
+        throws SAXException {
+        if (super.contentHandler==null)
+            throw new SAXException("ContentHandler not set");
+        super.contentHandler.processingInstruction(target,data);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerWrapper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerWrapper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerWrapper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,220 @@
+/*
+ * 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.xml;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.DocumentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributeListImpl;
+
+import java.util.Vector;
+
+/**
+ * This class is an utility class &quot;wrapping&quot; around a SAX version 1.0
+ * <code>DocumentHandler</code> and forwarding it those events received throug
+ * its <code>XMLConsumers</code> interface.
+ * <br>
+ * This class fully supports XML namespaces, converting
+ * <code>startPrefixMapping(...)</code> and <code>endPrefixMapping(...)</code>
+ * calls into appropriate <code>xmlns</code> and <code>xmlns:...</code> element
+ * attributes.
+ *
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
+ *         (Apache Software Foundation)
+ * @version CVS $Id: DocumentHandlerWrapper.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class DocumentHandlerWrapper extends AbstractXMLConsumer implements LogEnabled /*, Recyclable*/ {
+
+    protected Logger log;
+
+    /** The current namespaces table. */
+    private NamespacesTable namespaces=new NamespacesTable();
+    /** The vector of namespaces declarations to include in the next element. */
+    private Vector undecl=new Vector();
+
+    /** The current <code>DocumentHandler</code>. */
+    protected DocumentHandler documentHandler=null;
+
+    /**
+     * Create a new <code>DocumentHandlerWrapper</code> instance.
+     */
+    public DocumentHandlerWrapper() {
+        super();
+     }
+
+    /**
+     * Create a new <code>DocumentHandlerWrapper</code> instance.
+     */
+    public DocumentHandlerWrapper(DocumentHandler document) {
+        this();
+        this.setDocumentHandler(document);
+    }
+
+    /**
+     * Provide component with a logger.
+     * 
+     * @param logger the logger
+     */
+    public void enableLogging(Logger logger) {
+        if (this.log == null) {
+            this.log = logger;
+        }
+    }
+
+    /**
+     * Implementation of the recycle method
+     */
+    public void recycle() {
+        this.documentHandler = null;
+    }
+
+    /**
+     * Set the <code>DocumentHandler</code> that will receive XML data.
+     *
+     * @exception IllegalStateException If the <code>DocumentHandler</code>
+     *                                  was already set.
+     */
+    public void setDocumentHandler(DocumentHandler document)
+    throws IllegalStateException {
+        if (this.documentHandler!=null) throw new IllegalStateException();
+        this.documentHandler=document;
+    }
+
+    /**
+     * Receive an object for locating the origin of SAX document events.
+     */
+    public void setDocumentLocator (Locator locator) {
+        if (this.documentHandler==null) return;
+        else this.documentHandler.setDocumentLocator(locator);
+    }
+
+    /**
+     * Receive notification of the beginning of a document.
+     */
+    public void startDocument ()
+    throws SAXException {
+        if (this.documentHandler==null)
+            throw new SAXException("DocumentHandler not set");
+        this.documentHandler.startDocument();
+    }
+
+    /**
+     * Receive notification of the end of a document.
+     */
+    public void endDocument ()
+    throws SAXException {
+        if (this.documentHandler==null)
+            throw new SAXException("DocumentHandler not set");
+        this.documentHandler.endDocument();
+    }
+
+    /**
+     * Begin the scope of a prefix-URI Namespace mapping.
+     */
+    public void startPrefixMapping(String prefix, String uri)
+    throws SAXException {
+        this.undecl.addElement(this.namespaces.addDeclaration(prefix,uri));
+    }
+
+    /**
+     * End the scope of a prefix-URI mapping.
+     */
+    public void endPrefixMapping(String prefix)
+    throws SAXException {
+        if (namespaces.removeDeclaration(prefix)==null)
+            throw new SAXException("Namespace prefix \""+prefix+
+                                   "\" never declared");
+    }
+
+    /**
+     * Receive notification of the beginning of an element.
+     */
+    public void startElement(String uri, String loc, String raw, Attributes a)
+    throws SAXException {
+        if (this.documentHandler==null)
+            throw new SAXException("DocumentHandler not set");
+        NamespacesTable.Name name=this.namespaces.resolve(uri,raw,null,loc);
+        // Create the AttributeList
+        AttributeListImpl a2=new AttributeListImpl();
+        // Set the xmlns:...="..." attributes
+        if (this.undecl.size()>0) {
+            for (int x=0; x<this.undecl.size(); x++) {
+                NamespacesTable.Declaration dec=null;
+                dec=(NamespacesTable.Declaration)this.undecl.elementAt(x);
+                String aname="xmlns";
+                if (dec.getPrefix().length()>0) aname="xmlns:"+dec.getPrefix();
+                a2.addAttribute(aname,"CDATA",dec.getUri());
+            }
+            this.undecl.clear();
+        }
+        // Set the real attributes
+        for (int x=0; x<a.getLength(); x++) {
+            NamespacesTable.Name aname=namespaces.resolve(a.getURI(x),
+                                                          a.getQName(x),
+                                                          null,
+                                                          a.getLocalName(x));
+            a2.addAttribute(aname.getQName(),a.getType(x),a.getValue(x));
+        }
+        // Call the document handler startElement() method.
+        this.documentHandler.startElement(name.getQName(),a2);
+    }
+
+
+    /**
+     * Receive notification of the end of an element.
+     */
+    public void endElement(String uri, String loc, String raw)
+    throws SAXException {
+        if (this.documentHandler==null)
+            throw new SAXException("DocumentHandler not set");
+        NamespacesTable.Name name=this.namespaces.resolve(uri,raw,null,loc);
+        this.documentHandler.endElement(name.getQName());
+    }
+
+    /**
+     * Receive notification of character data.
+     */
+    public void characters(char ch[], int start, int len)
+    throws SAXException {
+        if (this.documentHandler==null)
+            throw new SAXException("DocumentHandler not set");
+        this.documentHandler.characters(ch,start,len);
+    }
+
+    /**
+     * Receive notification of ignorable whitespace in element content.
+     */
+    public void ignorableWhitespace(char ch[], int start, int len)
+    throws SAXException {
+        if (this.documentHandler==null)
+            throw new SAXException("DocumentHandler not set");
+        this.documentHandler.ignorableWhitespace(ch,start,len);
+    }
+
+    /**
+     * Receive notification of a processing instruction.
+     */
+    public void processingInstruction(String target, String data)
+    throws SAXException {
+        if (this.documentHandler==null)
+            throw new SAXException("DocumentHandler not set");
+        this.documentHandler.processingInstruction(target,data);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/DocumentHandlerWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,111 @@
+/*
+ * 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.xml;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * This class implements a ContentHandler for embedding a full SAX
+ * event stream into an existing stream of SAX events. An instance of
+ * this class will pass unmodified all the SAX events to the linked
+ * ContentHandler, but it will ignore the startDocument/endDocument
+ * and startDTD/endDTD events, as well as all comment events within
+ * the DTD.
+ *
+ * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
+ * @version CVS $Id: EmbeddedXMLPipe.java 53971 2004-10-07 14:03:55Z vgritsenko $
+ */
+public class EmbeddedXMLPipe extends AbstractXMLPipe {
+
+    private boolean inDTD;
+
+    /**
+     * Creates an EmbeddedXMLPipe that writes into the given XMLConsumer.
+     */
+    public EmbeddedXMLPipe(XMLConsumer consumer) {
+        setConsumer(consumer);
+    }
+
+    /**
+     * Creates an EmbeddedXMLPipe that writes into the given ContentHandler.
+     */
+    public EmbeddedXMLPipe(ContentHandler handler) {
+        setContentHandler(handler);
+        if (handler instanceof LexicalHandler) {
+            setLexicalHandler((LexicalHandler) handler);
+        }
+    }
+
+    /**
+     * Creates an EmbeddedXMLPipe that writes into the given ContentHandler.
+     */
+    public EmbeddedXMLPipe(ContentHandler contentHandler, LexicalHandler lexicalHandler) {
+        setContentHandler(contentHandler);
+        setLexicalHandler(lexicalHandler);
+    }
+
+    /**
+     * Ignore the <code>startDocument</code> event: this method does nothing.
+     *
+     * @exception SAXException if an error occurs
+     */
+    public void startDocument() throws SAXException {
+    }
+
+    /**
+     * Ignore the <code>endDocument</code> event: this method does nothing.
+     *
+     * @exception SAXException if an error occurs
+     */
+    public void endDocument() throws SAXException {
+    }
+
+    /**
+     * Ignore the <code>startDTD</code> event: this method does nothing.
+     *
+     * @exception SAXException if an error occurs
+     */
+    public void startDTD(String name, String publicId, String systemId)
+    throws SAXException {
+        // Ignored
+        this.inDTD = true;
+    }
+
+    /**
+     * Ignore the <code>endDTD</code> event: this method does nothing.
+     *
+     * @exception SAXException if an error occurs
+     */
+    public void endDTD() throws SAXException {
+        // Ignored
+        this.inDTD = false;
+    }
+
+    /**
+     * Ignore all <code>comment</code> events if between
+     * startDTD/endDTD events.
+     *
+     * @exception SAXException if an error occurs
+     */
+    public void comment(char ch[], int start, int len)
+    throws SAXException {
+        if (!inDTD) {
+            super.comment(ch, start, len);
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005 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.xml;
+
+import org.xml.sax.Attributes;
+
+/**
+ * Immutable attributes
+ *
+ * @version $Id: ImmutableAttributesImpl.java 164043 2005-04-21 12:11:55Z vgritsenko $
+ */
+public class ImmutableAttributesImpl extends AttributesImpl {
+
+    public ImmutableAttributesImpl() {
+        super();
+    }
+
+    public ImmutableAttributesImpl(Attributes attrs) {
+        super(attrs);
+    }
+
+    public void clear() {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void removeAttribute(int index) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void setLocalName(int index, String localName) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void setQName(int index, String qName) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void setType(int index, String type) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void setURI(int index, String uri) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void setValue(int index, String value) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void setAttributes(Attributes atts) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void setAttribute(int index, String uri, String localName, String qName, String type, String value) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+
+    public void addAttribute(String uri, String localName, String qName, String type, String value) {
+        throw new UnsupportedOperationException("immutable attributes");
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,248 @@
+/*
+ * 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.xml;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+import org.w3c.dom.Node;
+
+/**
+ * A special purpose <code>XMLConsumer</code> which can:
+ * <ul>
+ * <li>Trim empty characters if
+ *     {@link #setIgnoreEmptyCharacters(boolean) ignoreEmptyCharacters} is set.
+ * <li>Ignore root element if
+ *     {@link #setIgnoreRootElement(boolean) ignoreRootElement} is set.
+ * <li>Ignore startDocument, endDocument events.
+ * <li>Ignore startDTD, endDTD, and all comments within DTD.
+ * </ul>
+ *
+ * <p>It is more complicated version of {@link EmbeddedXMLPipe} which, except
+ * being used to include other files into the SAX events stream, can perform
+ * optional operations described above.</p>
+ *
+ * @see EmbeddedXMLPipe
+ * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: IncludeXMLConsumer.java 326891 2005-10-20 11:33:28Z cziegeler $
+ */
+public class IncludeXMLConsumer implements XMLConsumer {
+
+    /** The TrAX factory for serializing xml */
+    private static final TransformerFactory FACTORY = TransformerFactory.newInstance();
+
+    private final ContentHandler contentHandler;
+    private final LexicalHandler lexicalHandler;
+
+    private boolean ignoreEmptyCharacters;
+    private boolean ignoreRootElement;
+    private int     ignoreRootElementCount;
+    private boolean inDTD;
+
+    /**
+     * Constructor
+     */
+    public IncludeXMLConsumer (XMLConsumer consumer) {
+        this.contentHandler = consumer;
+        this.lexicalHandler = consumer;
+    }
+
+    /**
+     * Constructor
+     */
+    public IncludeXMLConsumer (ContentHandler contentHandler, LexicalHandler lexicalHandler) {
+        this.contentHandler = contentHandler;
+        this.lexicalHandler = lexicalHandler;
+    }
+
+    /**
+     * Constructor
+     */
+    public IncludeXMLConsumer (ContentHandler contentHandler) {
+        this.contentHandler = contentHandler;
+        this.lexicalHandler = contentHandler instanceof LexicalHandler ? (LexicalHandler)contentHandler : null;
+    }
+
+    /**
+     * Utility method to stream a DOM node into the provided content handler,
+     * lexical handler.
+     *
+     * @param node The DOM Node to be included
+     * @param contentHandler The SAX ContentHandler receiving the information
+     * @param lexicalHandler The SAX LexicalHandler receiving the information (optional)
+     */
+    public static void includeNode(Node           node,
+                                   ContentHandler contentHandler,
+                                   LexicalHandler lexicalHandler)
+    throws SAXException {
+        if (node != null) {
+            if (node.getNodeType() == Node.TEXT_NODE){
+                String value = node.getNodeValue();
+                contentHandler.characters(value.toCharArray(), 0, value.length());
+            } else {
+                try {
+                    IncludeXMLConsumer filter = new IncludeXMLConsumer(contentHandler, lexicalHandler);
+                    Transformer transformer = FACTORY.newTransformer();
+                    DOMSource source = new DOMSource(node);
+                    SAXResult result = new SAXResult(filter);
+                    result.setLexicalHandler(filter);
+                    transformer.transform(source, result);
+                } catch (TransformerConfigurationException e) {
+                    throw new SAXException("TransformerConfigurationException", e);
+                } catch (TransformerException e) {
+                    throw new SAXException("TransformerException", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Control SAX event handling.
+     * If set to <code>true</code> all empty characters events are ignored.
+     * The default is <code>false</code>.
+     */
+    public void setIgnoreEmptyCharacters(boolean value) {
+        this.ignoreEmptyCharacters = value;
+    }
+
+    /**
+     * Control SAX event handling.
+     * If set to <code>true</code> the root element is ignored.
+     * The default is <code>false</code>.
+     */
+    public void setIgnoreRootElement(boolean value) {
+        this.ignoreRootElement = value;
+        this.ignoreRootElementCount = 0;
+    }
+
+    //
+    // ContentHandler interface
+    //
+
+    public void setDocumentLocator(Locator loc) {
+        this.contentHandler.setDocumentLocator(loc);
+    }
+
+    public void startDocument() throws SAXException {
+        // Ignored
+    }
+
+    public void endDocument() throws SAXException {
+        // Ignored
+    }
+
+    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+        this.contentHandler.startPrefixMapping(prefix, uri);
+    }
+
+    public void endPrefixMapping(String prefix) throws SAXException {
+        this.contentHandler.endPrefixMapping(prefix);
+    }
+
+    public void startElement(String uri, String local, String qName, Attributes attr) throws SAXException {
+        if (this.ignoreRootElement == false ||
+            this.ignoreRootElementCount > 0) {
+            this.contentHandler.startElement(uri,local,qName,attr);
+        }
+        this.ignoreRootElementCount++;
+    }
+
+    public void endElement(String uri, String local, String qName) throws SAXException {
+        this.ignoreRootElementCount--;
+        if (!this.ignoreRootElement  || this.ignoreRootElementCount > 0) {
+            this.contentHandler.endElement(uri, local, qName);
+        }
+    }
+
+    public void characters(char[] ch, int start, int end) throws SAXException {
+        if (this.ignoreEmptyCharacters) {
+            String text = new String(ch, start, end).trim();
+            if (text.length() > 0) {
+                this.contentHandler.characters(text.toCharArray(), 0, text.length());
+            }
+        } else {
+            this.contentHandler.characters(ch, start, end);
+        }
+    }
+
+    public void ignorableWhitespace(char[] ch, int start, int end) throws SAXException {
+        if (!this.ignoreEmptyCharacters) {
+            this.contentHandler.ignorableWhitespace(ch, start, end);
+        }
+    }
+
+    public void processingInstruction(String name, String value) throws SAXException {
+        this.contentHandler.processingInstruction(name, value);
+    }
+
+    public void skippedEntity(String ent) throws SAXException {
+        this.contentHandler.skippedEntity(ent);
+    }
+
+    //
+    // LexicalHandler interface
+    //
+
+    public void startDTD(String name, String public_id, String system_id)
+    throws SAXException {
+        // Ignored
+        this.inDTD = true;
+    }
+
+    public void endDTD() throws SAXException {
+        // Ignored
+        this.inDTD = false;
+    }
+
+    public void startEntity(String name) throws SAXException {
+        if (lexicalHandler != null) {
+            lexicalHandler.startEntity(name);
+        }
+    }
+
+    public void endEntity(String name) throws SAXException {
+        if (lexicalHandler != null) {
+            lexicalHandler.endEntity(name);
+        }
+    }
+
+    public void startCDATA() throws SAXException {
+        if (lexicalHandler != null) {
+            lexicalHandler.startCDATA();
+        }
+    }
+
+    public void endCDATA() throws SAXException {
+        if (lexicalHandler != null) {
+            lexicalHandler.endCDATA();
+        }
+    }
+
+    public void comment(char ary[], int start, int length) throws SAXException {
+        if (!inDTD && lexicalHandler != null) {
+            lexicalHandler.comment(ary,start,length);
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/LoggingContentHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/LoggingContentHandler.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/LoggingContentHandler.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/LoggingContentHandler.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,125 @@
+/*
+ * 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.xml;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ContentHandler;
+
+/**
+ * Logging content handler logs all events going through to the logger.
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: LoggingContentHandler.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class LoggingContentHandler extends AbstractLogEnabled implements ContentHandler {
+
+    /**
+     * All debug messages from this handler are prefixed with this id.
+     */
+    String id;
+
+    /** The current <code>ContentHandler</code>. */
+    ContentHandler contentHandler;
+
+    /**
+     * Creates new <code>LoggingContentHandler</code> with specified
+     * <code>id</code> and destination <code>contentHandler</code>.
+     */
+    public LoggingContentHandler(String id, ContentHandler contentHandler) {
+        this.id = id;
+        this.contentHandler = contentHandler;
+    }
+
+    public void setDocumentLocator(Locator locator) {
+        log("setDocumentLocator", "");
+        contentHandler.setDocumentLocator(locator);
+    }
+
+    public void startDocument() throws SAXException {
+        log("startDocument", "");
+        this.contentHandler.startDocument();
+    }
+
+    public void endDocument() throws SAXException {
+        log ("endDocument", "");
+        this.contentHandler.endDocument();
+    }
+
+    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+        log ("startPrefixMapping", "prefix="+prefix+",uri="+uri);
+        this.contentHandler.startPrefixMapping(prefix,uri);
+    }
+
+    public void endPrefixMapping(String prefix) throws SAXException {
+        log ("endPrefixMapping", "prefix="+prefix);
+        this.contentHandler.endPrefixMapping(prefix);
+    }
+
+    public void startElement(String uri, String loc, String raw, Attributes a)
+    throws SAXException {
+        log ("startElement", "uri="+uri+",local="+loc+",raw="+raw);
+        for (int i = 0; i < a.getLength(); i++) {
+            log ("            ", Integer.toString(i + 1)
+                 + ". uri=" + a.getURI(i)
+                 + ",local=" + a.getLocalName(i)
+                 + ",qname=" + a.getQName(i)
+                 + ",type=" + a.getType(i)
+                 + ",value=" + a.getValue(i));
+        }
+        this.contentHandler.startElement(uri,loc,raw,a);
+    }
+
+
+    public void endElement(String uri, String loc, String qname) throws SAXException {
+        log ("endElement", "uri="+uri+",local="+loc+",qname="+qname);
+        this.contentHandler.endElement(uri,loc,qname);
+    }
+
+    public void characters(char ch[], int start, int len) throws SAXException {
+        log ("characters", new String(ch,start,len));
+        this.contentHandler.characters(ch,start,len);
+    }
+
+    public void ignorableWhitespace(char ch[], int start, int len) throws SAXException {
+        log ("ignorableWhitespace", new String(ch,start,len));
+        this.contentHandler.ignorableWhitespace(ch,start,len);
+    }
+
+    public void processingInstruction(String target, String data) throws SAXException {
+        log ("processingInstruction", "target="+target+",data="+data);
+        this.contentHandler.processingInstruction(target,data);
+    }
+
+    public void skippedEntity(String name) throws SAXException {
+        log ("skippedEntity", "name="+name);
+        this.contentHandler.skippedEntity(name);
+    }
+
+    private void log(String location, String description) {
+        StringBuffer logEntry = new StringBuffer();
+        logEntry.append(id);
+        logEntry.append("[");
+        logEntry.append(location);
+        logEntry.append("] ");
+        logEntry.append(description);
+        logEntry.append("\n");
+        getLogger().debug(logEntry.toString());
+        // System.out.print(logEntry.toString());
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/xml/LoggingContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message