You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/04/13 17:12:21 UTC

svn commit: r764500 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/impl/builder/ axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/ axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/ axio...

Author: veithen
Date: Mon Apr 13 15:12:21 2009
New Revision: 764500

URL: http://svn.apache.org/viewvc?rev=764500&view=rev
Log:
* Added new test cases for OMSource/OMResult.
* Fixed some issues in OMSource/OMResult and OMXMLReader/SAXOMBuilder.
* Added a CDATASection implementation to DOOM.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTestCase.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
      - copied, changed from r764380, webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMResult.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMSource.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/OMXMLReader.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
    webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/SAXOMBuilderSAXParserTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java Mon Apr 13 15:12:21 2009
@@ -198,9 +198,6 @@
 
     public void characterData(char[] ch, int start, int length, int nodeType)
             throws SAXException {
-        if (lastNode == null) {
-            throw new SAXException("");
-        }
         addNode(factory.createOMText(getContainer(), new String(ch, start, length), nodeType));
     }
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMResult.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMResult.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMResult.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMResult.java Mon Apr 13 15:12:21 2009
@@ -21,21 +21,35 @@
 
 import javax.xml.transform.sax.SAXResult;
 
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.impl.builder.SAXOMBuilder;
 
 /**
  * Implementation of {@link javax.xml.transform.Result} for AXIOM.
  * The implementation is based on {@link SAXResult} and transforms the stream
  * of SAX events to an AXIOM tree using {@link SAXOMBuilder}.
+ * <p>
+ * Note that building {@link org.apache.axiom.om.OMDocType} nodes from DTD information is
+ * not supported.
  */
 public class OMResult extends SAXResult {
     private final SAXOMBuilder builder;
     
-    public OMResult() {
-        builder = new SAXOMBuilder();
+    public OMResult(OMFactory omFactory) {
+        builder = new SAXOMBuilder(omFactory);
         setHandler(builder);
     }
+    
+    public OMResult() {
+        this(OMAbstractFactory.getOMFactory());
+    }
+
+    public OMDocument getDocument() {
+        return builder.getDocument();
+    }
 
     public OMElement getRootElement() {
         return builder.getRootElement();

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMSource.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMSource.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMSource.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/jaxp/OMSource.java Mon Apr 13 15:12:21 2009
@@ -29,6 +29,9 @@
  * Implementation of {@link javax.xml.transform.Source} for AXIOM.
  * The implementation is based on {@link SAXSource} and directly transforms an AXIOM
  * tree into a stream of SAX events using {@link OMXMLReader}.
+ * <p>
+ * Note that {@link org.apache.axiom.om.OMDocType} nodes are not supported and will be
+ * silently skipped.
  */
 public class OMSource extends SAXSource {
     public OMSource(OMElement element) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/OMXMLReader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/OMXMLReader.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/OMXMLReader.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/OMXMLReader.java Mon Apr 13 15:12:21 2009
@@ -32,6 +32,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMProcessingInstruction;
 import org.apache.axiom.om.OMText;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -50,6 +51,9 @@
  * callback methods on the configured {@link ContentHandler}. This can be used to
  * serialize an Axiom tree to SAX.
  * <p>
+ * Note that this class doesn't support serializing {@link org.apache.axiom.om.OMDocType}
+ * nodes. They will be silently skipped.
+ * <p>
  * This class can also generate SAX events for a subtree. This is the case if the
  * element passed to the constructor is not the root element of the document. In this
  * case, care is taken to properly generate <code>startPrefixMapping</code> and
@@ -247,13 +251,16 @@
                     generateEvents((OMElement)node);
                     break;
                 case OMNode.TEXT_NODE:
-                    generateEvents((OMText)node);
+                    generateEvents((OMText)node, false);
+                    break;
+                case OMNode.SPACE_NODE:
+                    generateEvents((OMText)node, true);
                     break;
                 case OMNode.CDATA_SECTION_NODE:
                     if (lexicalHandler != null) {
                         lexicalHandler.startCDATA();
                     }
-                    generateEvents((OMText)node);
+                    generateEvents((OMText)node, false);
                     if (lexicalHandler != null) {
                         lexicalHandler.endCDATA();
                     }
@@ -263,15 +270,23 @@
                         char[] ch = ((OMComment)node).getValue().toCharArray();
                         lexicalHandler.comment(ch, 0, ch.length);
                     }
+                    break;
+                case OMNode.PI_NODE:
+                    OMProcessingInstruction pi = (OMProcessingInstruction)node;
+                    contentHandler.processingInstruction(pi.getTarget(), pi.getValue());
             }
         }
         contentHandler.endElement(uri, localName, qName);
         generatePrefixMappingEvents(omElement, false);
     }
     
-    private void generateEvents(OMText omText) throws SAXException {
+    private void generateEvents(OMText omText, boolean space) throws SAXException {
         char[] ch = omText.getTextCharacters();
-        contentHandler.characters(ch, 0, ch.length);
+        if (space) {
+            contentHandler.ignorableWhitespace(ch, 0, ch.length);
+        } else {
+            contentHandler.characters(ch, 0, ch.length);
+        }
     }
 
     protected static class AttributesAdapter implements Attributes {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java Mon Apr 13 15:12:21 2009
@@ -29,8 +29,11 @@
 
 import javax.activation.DataSource;
 import javax.activation.URLDataSource;
+import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.custommonkey.xmlunit.XMLTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
 
 /** Abstract base class for test cases. */
 public abstract class AbstractTestCase
@@ -106,5 +109,14 @@
         }
         return new File(f, filename);
     }
+
+    public static Document toDocumentWithoutDTD(InputStream in) throws Exception {
+        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
+        DocumentType docType = doc.getDoctype();
+        if (docType != null) {
+            doc.removeChild(docType);
+        }
+        return doc;
+    }
 }
 

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTestCase.java?rev=764500&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTestCase.java Mon Apr 13 15:12:21 2009
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.jaxp;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+public class OMSourceToStreamResultTestCase extends AbstractTestCase {
+    private final OMMetaFactory omMetaFactory;
+    private final TransformerFactory transformerFactory;
+    private final String file;
+    
+    private OMSourceToStreamResultTestCase(OMMetaFactory omMetaFactory,
+            TransformerFactory transformerFactory, String name, String file) {
+        super(name);
+        this.omMetaFactory = omMetaFactory;
+        this.transformerFactory = transformerFactory;
+        this.file = file;
+    }
+
+    protected void runTest() throws Throwable {
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        // Turn off coalescing mode so that CDATA sections are reported by the StAX parser
+        inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(getTestResource(file));
+        StAXOMBuilder builder = new StAXOMBuilder(omMetaFactory.getOMFactory(), reader);
+        OMSource source = new OMSource(builder.getDocumentElement());
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        StreamResult result = new StreamResult(out);
+        transformerFactory.newTransformer().transform(source, result);
+        assertXMLIdentical(compareXML(
+                toDocumentWithoutDTD(getTestResource(file)),
+                toDocumentWithoutDTD(new ByteArrayInputStream(out.toByteArray()))), true);
+    }
+    
+    public static TestSuite suite(OMMetaFactory omMetaFactory,
+            TransformerFactory transformerFactory) throws Exception {
+        TestSuite suite = new TestSuite();
+        String[] files = getConformanceTestFiles();
+        for (int i=0; i<files.length; i++) {
+            String file = files[i];
+            int idx = file.lastIndexOf('/');
+            String name = file.substring(idx+1);
+            suite.addTest(new OMSourceToStreamResultTestCase(omMetaFactory, transformerFactory,
+                    name, file));
+        }
+        return suite;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java?rev=764500&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java Mon Apr 13 15:12:21 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.jaxp;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMMetaFactory;
+
+public class StreamSourceToOMResultTestCase extends AbstractTestCase {
+    private final OMMetaFactory omMetaFactory;
+    private final TransformerFactory transformerFactory;
+    private final String file;
+    
+    private StreamSourceToOMResultTestCase(OMMetaFactory omMetaFactory,
+            TransformerFactory transformerFactory, String name, String file) {
+        super(name);
+        this.omMetaFactory = omMetaFactory;
+        this.transformerFactory = transformerFactory;
+        this.file = file;
+    }
+    
+    protected void runTest() throws Throwable {
+        StreamSource source = new StreamSource(getTestResource(file));
+        OMResult result = new OMResult(omMetaFactory.getOMFactory());
+        transformerFactory.newTransformer().transform(source, result);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        result.getDocument().serialize(out);
+        assertXMLIdentical(compareXML(
+                toDocumentWithoutDTD(getTestResource(file)),
+                toDocumentWithoutDTD(new ByteArrayInputStream(out.toByteArray()))), true);
+    }
+
+    public static TestSuite suite(OMMetaFactory omMetaFactory,
+            TransformerFactory transformerFactory) throws Exception {
+        TestSuite suite = new TestSuite();
+        String[] files = getConformanceTestFiles();
+        for (int i=0; i<files.length; i++) {
+            String file = files[i];
+            int idx = file.lastIndexOf('/');
+            String name = file.substring(idx+1);
+            suite.addTest(new StreamSourceToOMResultTestCase(omMetaFactory, transformerFactory,
+                    name, file));
+        }
+        return suite;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml Mon Apr 13 15:12:21 2009
@@ -70,6 +70,12 @@
             <version>${version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>xalan</groupId>
+            <artifactId>xalan</artifactId>
+            <version>2.7.1</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <resources>

Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java?rev=764500&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java Mon Apr 13 15:12:21 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.dom;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Node;
+
+public class CDATASectionImpl extends TextNodeImpl implements CDATASection {
+    public CDATASectionImpl(String text, OMFactory factory) {
+        super(text, factory);
+    }
+
+    public CDATASectionImpl(DocumentImpl ownerDocument, String text, OMDOMFactory factory) {
+        super(ownerDocument, text, factory);
+    }
+
+    public int getType() throws OMException {
+        return OMNode.CDATA_SECTION_NODE;
+    }
+
+    public void setType(int nodeType) throws OMException {
+        if (nodeType != OMNode.CDATA_SECTION_NODE) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    public Node cloneNode(boolean deep) {
+        CDATASectionImpl textImpl = new CDATASectionImpl(this.textValue.toString(), this.factory);
+        textImpl.setOwnerDocument(this.ownerNode);
+        return textImpl;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java Mon Apr 13 15:12:21 2009
@@ -19,300 +19,81 @@
 
 package org.apache.axiom.om.impl.dom;
 
-import org.apache.axiom.attachments.utils.DataHandlerUtils;
-import org.apache.axiom.om.OMAttribute;
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
-import org.apache.axiom.om.impl.builder.XOPBuilder;
-import org.apache.axiom.om.util.TextHelper;
-import org.apache.axiom.om.util.UUIDGenerator;
-import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.IOException;
-import java.io.InputStream;
 
-public class TextImpl extends CharacterImpl implements Text, OMText {
+public class TextImpl extends TextNodeImpl {
     private boolean isWhitespace;
 
-    private String mimeType;
-
-    private boolean optimize;
-
-    private boolean isBinary;
-
-    private String contentID = null;
-
-    protected OMNamespace textNS = null;
-
-    protected char[] charArray;
-
-    /**
-     * Field dataHandler contains the DataHandler. Declaring as Object to remove the dependency on
-     * Javax.activation.DataHandler
-     */
-    private Object dataHandlerObject = null;
-
-    /** Field nameSpace is used when serializing Binary stuff as MTOM optimized. */
-    protected OMNamespace ns = null;
-
-    /** Field localName is used when serializing Binary stuff as MTOM optimized. */
-    protected String localName = "Include";
-
-    /** Field attribute is used when serializing Binary stuff as MTOM optimized. */
-    protected OMAttribute attribute;
-
-    /** Field nameSpace used when serializing Binary stuff as MTOM optimized. */
-    public static final OMNamespace XOP_NS = new OMNamespaceImpl(
-            "http://www.w3.org/2004/08/xop/include", "xop");
-
-    /**
-     * Creates a text node with the given text required by the OMDOMFactory. The owner document
-     * should be set properly when appending this to a DOM tree.
-     *
-     * @param text
-     */
-    public TextImpl(String text, OMFactory factory) {
-        super(factory);
-        this.textValue = (text != null) ? new StringBuffer(text)
-                : new StringBuffer("");
-        this.done = true;
-        this.ns = XOP_NS;
-    }
-
-    /**
-     * @param contentID
-     * @param parent
-     * @param builder   Used when the builder is encountered with a XOP:Include tag Stores a
-     *                  reference to the builder and the content-id. Supports deffered parsing of
-     *                  MIME messages
-     */
-    public TextImpl(String contentID, OMContainer parent,
-                    OMXMLParserWrapper builder, OMFactory factory) {
-        super((DocumentImpl) ((ParentNode) parent).getOwnerDocument(), factory);
-        this.contentID = contentID;
-        this.optimize = true;
-        this.isBinary = true;
-        this.done = true;
-        this.builder = builder;
-        this.ns = XOP_NS;
-    }
-    
-    /**
-     * Construct TextImpl that is a copy of the source OMTextImpl
-     * @param parent
-     * @param source TextImpl
-     * @param factory
-     */
-    public TextImpl(OMContainer parent, TextImpl source, OMFactory factory) {
-        super((DocumentImpl) ((ParentNode) parent).getOwnerDocument(), factory);
-        this.done = true;
-        
-        // Copy the value of the text
-        if (source.textValue != null) {
-            this.textValue = new StringBuffer();
-            this.textValue.append(source.textValue.toString());
-        }
-        
-        // Clone the charArray (if it exists)
-        if (source.charArray != null) {
-            this.charArray = new char[source.charArray.length];
-            for (int i=0; i<source.charArray.length; i++) {
-                this.charArray[i] = source.charArray[i];
-            }
-        }
-        
-        
-        // Turn off textNS...the namespace will need to be recalculated
-        // in the new tree's context.
-        this.textNS = null;
-        
-        // Copy the optimized related settings.
-        this.optimize = source.optimize;
-        this.mimeType = source.mimeType;
-        this.isBinary = source.isBinary;
-        
-        // TODO
-        // Do we need a deep copy of the data-handler 
-        this.contentID = source.contentID;
-        this.dataHandlerObject = source.dataHandlerObject;
-        
-        this.localName = source.localName;
-        if (source.ns != null) {
-            this.ns = new OMNamespaceImpl(source.ns.getNamespaceURI(), 
-                                          source.ns.getPrefix());
-        }
-        if (source.attribute != null) {
-            this.attribute = factory.createOMAttribute(source.attribute.getLocalName(),
-                                                       source.attribute.getNamespace(),
-                                                       source.attribute.getAttributeValue());
-        }
+    public TextImpl(DocumentImpl ownerNode, char[] value, OMFactory factory) {
+        super(ownerNode, value, factory);
     }
 
-    public TextImpl(String text, String mimeType, boolean optimize,
-                    OMFactory factory) {
-        this(text, mimeType, optimize, true, factory);
-    }
-
-    public TextImpl(String text, String mimeType, boolean optimize,
-                    boolean isBinary, OMFactory factory) {
-        this(text, factory);
-        this.mimeType = mimeType;
-        this.optimize = optimize;
-        this.isBinary = isBinary;
-    }
-
-    /**
-     * @param dataHandler
-     * @param optimize    To send binary content. Created progrmatically.
-     */
-    public TextImpl(DocumentImpl ownerNode, Object dataHandler, boolean optimize,
-                    OMFactory factory) {
-        super(ownerNode, factory);
-        this.dataHandlerObject = dataHandler;
-        this.isBinary = true;
-        this.optimize = optimize;
-        done = true;
-        this.ns = XOP_NS;
+    public TextImpl(DocumentImpl ownerNode, Object dataHandler, boolean optimize, OMFactory factory) {
+        super(ownerNode, dataHandler, optimize, factory);
     }
 
-    /** @param ownerNode  */
     public TextImpl(DocumentImpl ownerNode, OMFactory factory) {
         super(ownerNode, factory);
-        this.done = true;
-        this.ns = XOP_NS;
     }
 
-    /**
-     * @param ownerNode
-     * @param value
-     */
     public TextImpl(DocumentImpl ownerNode, String value, OMFactory factory) {
         super(ownerNode, value, factory);
-        this.done = true;
-        this.ns = XOP_NS;
     }
 
-
-    public TextImpl(DocumentImpl ownerNode, char[] value, OMFactory factory) {
-        super(ownerNode, factory);
-        this.charArray = value;
-        this.done = true;
-        this.ns = XOP_NS;
-    }
-
-    /**
-     * @param ownerNode
-     * @param value
-     */
-    public TextImpl(DocumentImpl ownerNode, String value, String mimeType,
-                    boolean optimize, OMFactory factory) {
-        this(ownerNode, value, factory);
-        this.mimeType = mimeType;
-        this.optimize = optimize;
-        this.isBinary = true;
-        done = true;
+    public TextImpl(DocumentImpl ownerNode, String value, int nodeType, OMFactory factory) {
+        super(ownerNode, value, factory);
+        isWhitespace = nodeType == SPACE_NODE;
     }
 
-    public TextImpl(OMContainer parent, QName text, OMFactory factory) {
-        this(parent, text, OMNode.TEXT_NODE, factory);
-
+    public TextImpl(DocumentImpl ownerNode, String value, String mimeType, boolean optimize,
+            OMFactory factory) {
+        super(ownerNode, value, mimeType, optimize, factory);
     }
 
-    public TextImpl(OMContainer parent, QName text, int nodeType,
-                    OMFactory factory) {
-        this(((ElementImpl) parent).ownerNode, factory);
-        if (text != null) {
-            this.textNS =
-                    ((ElementImpl) parent).findNamespace(text.getNamespaceURI(), text.getPrefix());
-        } else {
-
-        }
-        this.textValue = new StringBuffer((text == null) ? "" : text.getLocalPart());
-        this.done = true;
+    public TextImpl(OMContainer parent, QName text, int nodeType, OMFactory factory) {
+        super(parent, text, nodeType, factory);
     }
 
-    /**
-     * Breaks this node into two nodes at the specified offset, keeping both in the tree as
-     * siblings. After being split, this node will contain all the content up to the offset point. A
-     * new node of the same type, which contains all the content at and after the offset point, is
-     * returned. If the original node had a parent node, the new node is inserted as the next
-     * sibling of the original node. When the offset is equal to the length of this node, the new
-     * node has no data.
-     */
-    public Text splitText(int offset) throws DOMException {
-        if (this.isReadonly()) {
-            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
-                                   DOMMessageFormatter.formatMessage(
-                                           DOMMessageFormatter.DOM_DOMAIN,
-                                           "NO_MODIFICATION_ALLOWED_ERR", null));
-        }
-        if (offset < 0 || offset > this.textValue.length()) {
-            throw new DOMException(DOMException.INDEX_SIZE_ERR,
-                                   DOMMessageFormatter.formatMessage(
-                                           DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR",
-                                           null));
-        }
-        String newValue = this.textValue.substring(offset);
-        this.deleteData(offset, this.textValue.length());
-
-        TextImpl newText = (TextImpl) this.getOwnerDocument().createTextNode(
-                newValue);
-
-        if (this.parentNode != null) {
-            newText.setParent(this.parentNode);
-        }
+    public TextImpl(OMContainer parent, QName text, OMFactory factory) {
+        super(parent, text, factory);
+    }
 
-        this.insertSiblingAfter(newText);
+    public TextImpl(OMContainer parent, TextNodeImpl source, OMFactory factory) {
+        super(parent, source, factory);
+    }
 
-        return newText;
+    public TextImpl(String contentID, OMContainer parent, OMXMLParserWrapper builder,
+            OMFactory factory) {
+        super(contentID, parent, builder, factory);
     }
 
-    // /
-    // /org.w3c.dom.Node methods
-    // /
-    public String getNodeName() {
-        return "#text";
+    public TextImpl(String text, OMFactory factory) {
+        super(text, factory);
     }
 
-    public short getNodeType() {
-        return Node.TEXT_NODE;
+    public TextImpl(String text, String mimeType, boolean optimize, boolean isBinary,
+            OMFactory factory) {
+        super(text, mimeType, optimize, isBinary, factory);
     }
 
-    // /
-    // /OMNode methods
-    // /
+    public TextImpl(String text, String mimeType, boolean optimize, OMFactory factory) {
+        super(text, mimeType, optimize, factory);
+    }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.axiom.om.OMNode#getType()
-     */
     public int getType() throws OMException {
         return isWhitespace ? OMNode.SPACE_NODE : OMNode.TEXT_NODE;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.axiom.om.OMNode#setType(int)
-     */
     public void setType(int nodeType) throws OMException {
         switch (nodeType) {
             case OMNode.TEXT_NODE:
-            case OMNode.CDATA_SECTION_NODE: // TODO: this is not entirely correct
                 isWhitespace = false;
                 break;
             case OMNode.SPACE_NODE:
@@ -323,323 +104,9 @@
         }
     }
 
-    public void internalSerialize(XMLStreamWriter writer) throws XMLStreamException {
-        internalSerializeLocal(writer);
-    }
-
-    public void internalSerializeAndConsume(XMLStreamWriter writer)
-            throws XMLStreamException {
-        internalSerializeLocal(writer);
-    }
-
-    public boolean isOptimized() {
-        return this.optimize;
-    }
-
-    public void setOptimize(boolean value) {
-        this.optimize = value;
-        if (value) {
-            isBinary = true;
-        }
-    }
-
-    public void discard() throws OMException {
-        if (done) {
-            this.detach();
-        }
-    }
-
-    /**
-     * Writes the relevant output.
-     *
-     * @param writer
-     * @throws XMLStreamException
-     */
-    private void writeOutput(XMLStreamWriter writer) throws XMLStreamException {
-        int type = getType();
-        if (type == OMNode.TEXT_NODE || type == SPACE_NODE) {
-            writer.writeCharacters(this.getText());
-        } else if (type == OMNode.CDATA_SECTION_NODE) {
-            writer.writeCData(this.getText());
-        } else if (type == OMNode.ENTITY_REFERENCE_NODE) {
-            writer.writeEntityRef(this.getText());
-        }
-    }
-
-    public String getText() {
-        if (this.textNS != null) {
-            return getTextString();
-        } else if (this.charArray != null || this.textValue != null) {
-            return getTextFromProperPlace();
-        } else {
-            try {
-                return TextHelper.toString(getInputStream());
-            } catch (Exception e) {
-                throw new OMException(e);
-            }
-        }
-    }
-
-    public String getData() throws DOMException {
-        return this.getText();
-    }
-    
-    public char[] getTextCharacters() {
-        return charArray != null ? charArray : this.textValue.toString()
-                .toCharArray();
-    }
-
-    public boolean isCharacters() {
-        return charArray != null;
-    }
-
-    private String getTextFromProperPlace() {
-        return charArray != null ? new String(charArray) : textValue.toString();
-    }
-
-    private String getTextString() {
-        if (textNS != null) {
-            String prefix = textNS.getPrefix();
-            if (prefix == null || "".equals(prefix)) {
-                return getTextFromProperPlace();
-            } else {
-                return prefix + ":" + getTextFromProperPlace();
-            }
-        }
-
-        return null;
-    }
-
-    public QName getTextAsQName() {
-        if (textNS != null) {
-            String prefix = textNS.getPrefix();
-            String name = textNS.getNamespaceURI();
-            if (prefix == null || "".equals(prefix)) {
-                return new QName(name, getTextFromProperPlace());
-            } else {
-                return new QName(textNS.getNamespaceURI(), getTextFromProperPlace(), prefix);
-            }
-        } else if (this.textValue != null || charArray != null) {
-            return new QName(getTextFromProperPlace());
-        } else {
-            try {
-                return new QName(TextHelper.toString(getInputStream()));
-            } catch (Exception e) {
-                throw new OMException(e);
-            }
-        }
-    }
-
-    public String getNodeValue() throws DOMException {
-        return this.getText();
-    }
-
-    public String getContentID() {
-        if (contentID == null) {
-            contentID = UUIDGenerator.getUUID() + "@apache.org";
-        }
-        return this.contentID;
-    }
-
-    public Object getDataHandler() {
-        /*
-         * this should return a DataHandler containing the binary data
-         * reperesented by the Base64 strings stored in OMText
-         */
-        if ((textValue != null || charArray != null || textNS != null) & isBinary) {
-            String text = textNS == null ? getTextFromProperPlace() : getTextString();
-            return DataHandlerUtils
-                    .getDataHandlerFromText(text, mimeType);
-        } else {
-
-            if (dataHandlerObject == null) {
-                if (contentID == null) {
-                    throw new RuntimeException("ContentID is null");
-                }
-                dataHandlerObject = ((XOPBuilder) builder)
-                        .getDataHandler(contentID);
-            }
-            return dataHandlerObject;
-        }
-    }
-
-    public java.io.InputStream getInputStream() throws OMException {
-        if (isBinary) {
-            if (dataHandlerObject == null) {
-                getDataHandler();
-            }
-            InputStream inStream;
-            javax.activation.DataHandler dataHandler =
-                    (javax.activation.DataHandler) dataHandlerObject;
-            try {
-                inStream = dataHandler.getDataSource().getInputStream();
-            } catch (IOException e) {
-                throw new OMException(
-                        "Cannot get InputStream from DataHandler." + e);
-            }
-            return inStream;
-        } else {
-            throw new OMException("Unsupported Operation");
-        }
-    }
-
-    private void internalSerializeLocal(XMLStreamWriter writer2)
-            throws XMLStreamException {
-        MTOMXMLStreamWriter writer = (MTOMXMLStreamWriter) writer2;
-        if (!this.isBinary) {
-            writeOutput(writer);
-        } else {
-            if (writer.isOptimized()) {
-                if (contentID == null) {
-                    contentID = writer.getNextContentId();
-                }
-                // send binary as MTOM optimised
-                this.attribute = new AttrImpl(this.ownerNode, "href",
-                                              new NamespaceImpl("", ""),
-                                              "cid:" + getContentID(),
-                                              this.factory);
-                this.serializeStartpart(writer);
-                writer.writeOptimized(this);
-                writer.writeEndElement();
-            } else {
-                writer.writeCharacters(this.getText());
-            }
-        }
-    }
-
-    /*
-     * Methods to copy from OMSerialize utils.
-     */
-    private void serializeStartpart(XMLStreamWriter writer)
-            throws XMLStreamException {
-        String nameSpaceName = XOP_NS.getNamespaceURI();
-        String writer_prefix = writer.getPrefix(nameSpaceName);
-        String prefix = XOP_NS.getPrefix();
-        if (writer_prefix != null) {
-            writer.writeStartElement(nameSpaceName, this
-                    .getLocalName());
-        } else {
-            writer.writeStartElement(prefix, this.getLocalName(),
-                                     nameSpaceName);
-            writer.setPrefix(prefix, nameSpaceName);
-        }
-        // add the elements attribute "href"
-        serializeAttribute(this.attribute, writer);
-        // add the namespace
-        serializeNamespace(XOP_NS, writer);
-    }
-
-    /**
-     * Method serializeAttribute.
-     *
-     * @param attr
-     * @param writer
-     * @throws XMLStreamException
-     */
-    static void serializeAttribute(OMAttribute attr, XMLStreamWriter writer)
-            throws XMLStreamException {
-        // first check whether the attribute is associated with a namespace
-        OMNamespace ns = attr.getNamespace();
-        String prefix;
-        String namespaceName;
-        if (ns != null) {
-            // add the prefix if it's availble
-            prefix = ns.getPrefix();
-            namespaceName = ns.getNamespaceURI();
-            if (prefix != null) {
-                writer.writeAttribute(prefix, namespaceName, attr
-                        .getLocalName(), attr.getAttributeValue());
-            } else {
-                writer.writeAttribute(namespaceName, attr.getLocalName(), attr
-                        .getAttributeValue());
-            }
-        } else {
-            writer
-                    .writeAttribute(attr.getLocalName(), attr
-                            .getAttributeValue());
-        }
-    }
-
-    /**
-     * Method serializeNamespace.
-     *
-     * @param namespace
-     * @param writer
-     * @throws XMLStreamException
-     */
-    static void serializeNamespace(OMNamespace namespace, XMLStreamWriter writer)
-            throws XMLStreamException {
-        if (namespace != null) {
-            String uri = namespace.getNamespaceURI();
-            String ns_prefix = namespace.getPrefix();
-            writer.writeNamespace(ns_prefix, namespace.getNamespaceURI());
-            writer.setPrefix(ns_prefix, uri);
-        }
-    }
-
     public Node cloneNode(boolean deep) {
         TextImpl textImpl = new TextImpl(this.textValue.toString(), this.factory);
         textImpl.setOwnerDocument(this.ownerNode);
         return textImpl;
     }
-
-    public String getLocalName() {
-        return this.localName;
-    }
-
-    /*
-    * DOM-Level 3 methods
-    */
-
-
-    public String getWholeText() {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
-    }
-
-    public boolean isElementContentWhitespace() {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
-    }
-
-    public Text replaceWholeText(String arg0) throws DOMException {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
-    }
-
-    public String toString() {
-        return (this.textValue != null) ? textValue.toString() : "";
-    }
-
-    /* (non-Javadoc)
-      * @see org.apache.axiom.om.OMNode#buildAll()
-      */
-    public void buildWithAttachments() {
-        this.build();
-        if (isOptimized()) {
-            this.getDataHandler();
-        }
-    }
-
-    public boolean isBinary() {
-        return isBinary;
-    }
-
-    /**
-     * Receiving binary can happen as either MTOM attachments or as Base64 Text In the case of Base64
-     * user has to explicitly specify that the content is binary, before calling getDataHandler(),
-     * getInputStream()....
-     */
-    public void setBinary(boolean value) {
-        this.isBinary = value;
-
-    }
-
-    public OMNamespace getNamespace() {
-        return textNS;
-    }
-    
-    public void setContentID(String cid) {
-        this.contentID = cid;
-    }
 }

Copied: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java (from r764380, webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java&r1=764380&r2=764500&rev=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java Mon Apr 13 15:12:21 2009
@@ -22,7 +22,6 @@
 import org.apache.axiom.attachments.utils.DataHandlerUtils;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
@@ -44,9 +43,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-public class TextImpl extends CharacterImpl implements Text, OMText {
-    private boolean isWhitespace;
-
+public abstract class TextNodeImpl extends CharacterImpl implements Text, OMText {
     private String mimeType;
 
     private boolean optimize;
@@ -84,7 +81,7 @@
      *
      * @param text
      */
-    public TextImpl(String text, OMFactory factory) {
+    public TextNodeImpl(String text, OMFactory factory) {
         super(factory);
         this.textValue = (text != null) ? new StringBuffer(text)
                 : new StringBuffer("");
@@ -99,7 +96,7 @@
      *                  reference to the builder and the content-id. Supports deffered parsing of
      *                  MIME messages
      */
-    public TextImpl(String contentID, OMContainer parent,
+    public TextNodeImpl(String contentID, OMContainer parent,
                     OMXMLParserWrapper builder, OMFactory factory) {
         super((DocumentImpl) ((ParentNode) parent).getOwnerDocument(), factory);
         this.contentID = contentID;
@@ -116,7 +113,7 @@
      * @param source TextImpl
      * @param factory
      */
-    public TextImpl(OMContainer parent, TextImpl source, OMFactory factory) {
+    public TextNodeImpl(OMContainer parent, TextNodeImpl source, OMFactory factory) {
         super((DocumentImpl) ((ParentNode) parent).getOwnerDocument(), factory);
         this.done = true;
         
@@ -161,12 +158,12 @@
         }
     }
 
-    public TextImpl(String text, String mimeType, boolean optimize,
+    public TextNodeImpl(String text, String mimeType, boolean optimize,
                     OMFactory factory) {
         this(text, mimeType, optimize, true, factory);
     }
 
-    public TextImpl(String text, String mimeType, boolean optimize,
+    public TextNodeImpl(String text, String mimeType, boolean optimize,
                     boolean isBinary, OMFactory factory) {
         this(text, factory);
         this.mimeType = mimeType;
@@ -178,7 +175,7 @@
      * @param dataHandler
      * @param optimize    To send binary content. Created progrmatically.
      */
-    public TextImpl(DocumentImpl ownerNode, Object dataHandler, boolean optimize,
+    public TextNodeImpl(DocumentImpl ownerNode, Object dataHandler, boolean optimize,
                     OMFactory factory) {
         super(ownerNode, factory);
         this.dataHandlerObject = dataHandler;
@@ -189,7 +186,7 @@
     }
 
     /** @param ownerNode  */
-    public TextImpl(DocumentImpl ownerNode, OMFactory factory) {
+    public TextNodeImpl(DocumentImpl ownerNode, OMFactory factory) {
         super(ownerNode, factory);
         this.done = true;
         this.ns = XOP_NS;
@@ -199,14 +196,14 @@
      * @param ownerNode
      * @param value
      */
-    public TextImpl(DocumentImpl ownerNode, String value, OMFactory factory) {
+    public TextNodeImpl(DocumentImpl ownerNode, String value, OMFactory factory) {
         super(ownerNode, value, factory);
         this.done = true;
         this.ns = XOP_NS;
     }
 
 
-    public TextImpl(DocumentImpl ownerNode, char[] value, OMFactory factory) {
+    public TextNodeImpl(DocumentImpl ownerNode, char[] value, OMFactory factory) {
         super(ownerNode, factory);
         this.charArray = value;
         this.done = true;
@@ -217,7 +214,7 @@
      * @param ownerNode
      * @param value
      */
-    public TextImpl(DocumentImpl ownerNode, String value, String mimeType,
+    public TextNodeImpl(DocumentImpl ownerNode, String value, String mimeType,
                     boolean optimize, OMFactory factory) {
         this(ownerNode, value, factory);
         this.mimeType = mimeType;
@@ -226,12 +223,12 @@
         done = true;
     }
 
-    public TextImpl(OMContainer parent, QName text, OMFactory factory) {
+    public TextNodeImpl(OMContainer parent, QName text, OMFactory factory) {
         this(parent, text, OMNode.TEXT_NODE, factory);
 
     }
 
-    public TextImpl(OMContainer parent, QName text, int nodeType,
+    public TextNodeImpl(OMContainer parent, QName text, int nodeType,
                     OMFactory factory) {
         this(((ElementImpl) parent).ownerNode, factory);
         if (text != null) {
@@ -295,34 +292,6 @@
     // /OMNode methods
     // /
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.axiom.om.OMNode#getType()
-     */
-    public int getType() throws OMException {
-        return isWhitespace ? OMNode.SPACE_NODE : OMNode.TEXT_NODE;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.axiom.om.OMNode#setType(int)
-     */
-    public void setType(int nodeType) throws OMException {
-        switch (nodeType) {
-            case OMNode.TEXT_NODE:
-            case OMNode.CDATA_SECTION_NODE: // TODO: this is not entirely correct
-                isWhitespace = false;
-                break;
-            case OMNode.SPACE_NODE:
-                isWhitespace = true;
-                break;
-            default:
-                throw new UnsupportedOperationException();
-        }
-    }
-
     public void internalSerialize(XMLStreamWriter writer) throws XMLStreamException {
         internalSerializeLocal(writer);
     }
@@ -577,12 +546,6 @@
         }
     }
 
-    public Node cloneNode(boolean deep) {
-        TextImpl textImpl = new TextImpl(this.textValue.toString(), this.factory);
-        textImpl.setOwnerDocument(this.ownerNode);
-        return textImpl;
-    }
-
     public String getLocalName() {
         return this.localName;
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java Mon Apr 13 15:12:21 2009
@@ -37,6 +37,7 @@
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.dom.AttrImpl;
+import org.apache.axiom.om.impl.dom.CDATASectionImpl;
 import org.apache.axiom.om.impl.dom.CommentImpl;
 import org.apache.axiom.om.impl.dom.DocumentFragmentImpl;
 import org.apache.axiom.om.impl.dom.DocumentImpl;
@@ -47,6 +48,7 @@
 import org.apache.axiom.om.impl.dom.ParentNode;
 import org.apache.axiom.om.impl.dom.ProcessingInstructionImpl;
 import org.apache.axiom.om.impl.dom.TextImpl;
+import org.apache.axiom.om.impl.dom.TextNodeImpl;
 import org.w3c.dom.Node;
 
 import javax.xml.namespace.QName;
@@ -241,14 +243,7 @@
      * @see org.apache.axiom.om.OMFactory#createOMText( org.apache.axiom.om.OMElement,String)
      */
     public OMText createOMText(OMContainer parent, String text) {
-        if (parent instanceof DocumentImpl) {
-            throw new OMHierarchyException(
-                    "DOM doesn't support text nodes as children of a document");
-        }
-        TextImpl txt = new TextImpl((DocumentImpl)((ElementImpl)parent).getOwnerDocument(),
-                text, this);
-        parent.addChild(txt);
-        return txt;
+        return createOMText(parent, text, OMNode.TEXT_NODE);
     }
 
     public OMText createOMText(OMContainer parent, QName text) {
@@ -260,9 +255,19 @@
     }
 
     public OMText createOMText(OMContainer parent, String text, int type) {
-        OMText textNode = createOMText(parent, text);
-        ((OMNodeEx) textNode).setType(type);
-        return textNode;
+        if (parent instanceof DocumentImpl) {
+            throw new OMHierarchyException(
+                    "DOM doesn't support text nodes as children of a document");
+        }
+        DocumentImpl ownerDocument = (DocumentImpl)((ElementImpl)parent).getOwnerDocument(); 
+        TextNodeImpl txt;
+        if (type == OMNode.CDATA_SECTION_NODE) {
+            txt = new CDATASectionImpl(ownerDocument, text, this);
+        } else {
+            txt = new TextImpl(ownerDocument, text, type, this);
+        }
+        parent.addChild(txt);
+        return txt;
     }
     
     

Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java?rev=764500&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java Mon Apr 13 15:12:21 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.jaxp;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
+import org.apache.xalan.processor.TransformerFactoryImpl;
+
+public class OMSourceToStreamResultTest extends TestCase {
+    public static TestSuite suite() throws Exception {
+        return OMSourceToStreamResultTestCase.suite(new OMDOMMetaFactory(),
+                new TransformerFactoryImpl());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java?rev=764500&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java Mon Apr 13 15:12:21 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.jaxp;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
+import org.apache.xalan.processor.TransformerFactoryImpl;
+
+public class StreamSourceToOMResultTest extends TestCase {
+    public static TestSuite suite() throws Exception {
+        return StreamSourceToOMResultTestCase.suite(new OMDOMMetaFactory(),
+                new TransformerFactoryImpl());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml Mon Apr 13 15:12:21 2009
@@ -70,6 +70,12 @@
             <version>${version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>xalan</groupId>
+            <artifactId>xalan</artifactId>
+            <version>2.7.1</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <resources>

Added: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java?rev=764500&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java Mon Apr 13 15:12:21 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.jaxp;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory;
+import org.apache.xalan.processor.TransformerFactoryImpl;
+
+public class OMSourceToStreamResultTest extends TestCase {
+    public static TestSuite suite() throws Exception {
+        return OMSourceToStreamResultTestCase.suite(new OMLinkedListMetaFactory(),
+                new TransformerFactoryImpl());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/OMSourceToStreamResultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java?rev=764500&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java Mon Apr 13 15:12:21 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.jaxp;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory;
+import org.apache.xalan.processor.TransformerFactoryImpl;
+
+public class StreamSourceToOMResultTest extends TestCase {
+    public static TestSuite suite() throws Exception {
+        return StreamSourceToOMResultTestCase.suite(new OMLinkedListMetaFactory(),
+                new TransformerFactoryImpl());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/SAXOMBuilderSAXParserTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/SAXOMBuilderSAXParserTest.java?rev=764500&r1=764499&r2=764500&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/SAXOMBuilderSAXParserTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/SAXOMBuilderSAXParserTest.java Mon Apr 13 15:12:21 2009
@@ -23,14 +23,11 @@
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 
-import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.SAXParserFactory;
 
 import junit.framework.TestSuite;
 
 import org.apache.axiom.om.AbstractTestCase;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
@@ -44,15 +41,6 @@
         this.file = file;
     }
 
-    private Document toDocument(InputStream in) throws Exception {
-        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
-        DocumentType docType = doc.getDoctype();
-        if (docType != null) {
-            doc.removeChild(docType);
-        }
-        return doc;
-    }
-    
     @Override
     protected void runTest() throws Throwable {
         factory.setNamespaceAware(true);
@@ -71,8 +59,8 @@
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             builder.getDocument().serialize(baos);
             assertXMLIdentical(compareXML(
-                    toDocument(in),
-                    toDocument(new ByteArrayInputStream(baos.toByteArray()))), true);
+                    toDocumentWithoutDTD(in),
+                    toDocumentWithoutDTD(new ByteArrayInputStream(baos.toByteArray()))), true);
         } finally {
             in.close();
         }