Author: veithen
Date: Sun Feb  3 10:40:10 2013
New Revision: 1441888

URL: http://svn.apache.org/viewvc?rev=1441888&view=rev
Log:
Started to implement new SAX serialization code.

Added:
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXOutputException.java
   (with props)
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/XMLReaderImpl.java
   (with props)
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXOutputException.java
   (with props)
Modified:
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IContainer.java
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
    
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
    
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java

Modified: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IContainer.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IContainer.java?rev=1441888&r1=1441887&r2=1441888&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IContainer.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IContainer.java
 Sun Feb  3 10:40:10 2013
@@ -22,7 +22,7 @@ import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.impl.OMContainerEx;
 
-public interface IContainer extends OMContainerEx, IParentNode {
+public interface IContainer extends OMContainerEx, IParentNode, ISerializable {
     /**
      * Check if the node can be added as a child of this container.
      * 

Modified: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java?rev=1441888&r1=1441887&r2=1441888&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
 Sun Feb  3 10:40:10 2013
@@ -18,7 +18,12 @@
  */
 package org.apache.axiom.om.impl.common.serializer.push;
 
-public class OutputException extends Exception {
+/**
+ * Wraps an exception thrown by the underlying API (StAX, SAX, etc.) while 
writing data. This class
+ * is abstract so that the type of the wrapped exception can be effectively 
restricted by defining
+ * an appropriate subclass.
+ */
+public abstract class OutputException extends Exception {
     private static final long serialVersionUID = 7173617216602466028L;
 
     public OutputException(Throwable cause) {

Modified: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java?rev=1441888&r1=1441887&r2=1441888&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java
 Sun Feb  3 10:40:10 2013
@@ -70,9 +70,9 @@ public abstract class Serializer {
     public final void serializeStartpart(OMElement element) throws 
OutputException {
         OMNamespace ns = element.getNamespace();
         if (ns == null) {
-            beginStartElement("", "", element.getLocalName());
+            internalBeginStartElement("", "", element.getLocalName());
         } else {
-            beginStartElement(ns.getPrefix(), ns.getNamespaceURI(), 
element.getLocalName());
+            internalBeginStartElement(ns.getPrefix(), ns.getNamespaceURI(), 
element.getLocalName());
         }
         for (Iterator it = element.getAllDeclaredNamespaces(); it.hasNext(); ) 
{
             ns = (OMNamespace)it.next();
@@ -87,7 +87,7 @@ public abstract class Serializer {
                 processAttribute(ns.getPrefix(), ns.getNamespaceURI(), 
attr.getLocalName(), attr.getAttributeValue());
             }
         }
-        finishStartElement();
+        internalFinishStartElement();
     }
     
     private void copyEvent(XMLStreamReader reader, DataHandlerReader 
dataHandlerReader) throws OutputException {
@@ -107,7 +107,7 @@ public abstract class Serializer {
                     writeDTD(dtdReader.getRootName(), dtdReader.getPublicId(), 
dtdReader.getSystemId(), reader.getText());
                     break;
                 case XMLStreamReader.START_ELEMENT:
-                    beginStartElement(normalize(reader.getPrefix()), 
normalize(reader.getNamespaceURI()), reader.getLocalName());
+                    internalBeginStartElement(normalize(reader.getPrefix()), 
normalize(reader.getNamespaceURI()), reader.getLocalName());
                     for (int i=0, count=reader.getNamespaceCount(); i<count; 
i++) {
                         
generateSetPrefix(normalize(reader.getNamespacePrefix(i)), 
normalize(reader.getNamespaceURI(i)), false);
                     }
@@ -118,7 +118,7 @@ public abstract class Serializer {
                                 reader.getAttributeLocalName(i),
                                 reader.getAttributeValue(i));
                     }
-                    finishStartElement();
+                    internalFinishStartElement();
                     break;
                 case XMLStreamReader.END_ELEMENT:
                     writeEndElement();
@@ -160,8 +160,8 @@ public abstract class Serializer {
         return s == null ? "" : s;
     }
     
-    private void beginStartElement(String prefix, String namespaceURI, String 
localName) throws OutputException {
-        writeStartElement(prefix, namespaceURI, localName);
+    private void internalBeginStartElement(String prefix, String namespaceURI, 
String localName) throws OutputException {
+        beginStartElement(prefix, namespaceURI, localName);
         generateSetPrefix(prefix, namespaceURI, false);
     }
     
@@ -180,12 +180,13 @@ public abstract class Serializer {
         writeAttribute(prefix, namespaceURI, localName, value);
     }
     
-    private void finishStartElement() throws OutputException {
+    private void internalFinishStartElement() throws OutputException {
         for (int i = 0; i < writePrefixList.size(); i++) {
             writeNamespace((String)writePrefixList.get(i), 
(String)writeNSList.get(i));
         }
         writePrefixList.clear();
         writeNSList.clear();
+        finishStartElement();
     }
     
     /**
@@ -331,12 +332,28 @@ public abstract class Serializer {
     
     public abstract void writeDTD(String rootName, String publicId, String 
systemId, String internalSubset) throws OutputException;
     
-    protected abstract void writeStartElement(String prefix, String 
namespaceURI, String localName) throws OutputException;
+    /**
+     * Prepare to write an element start tag. A call to this method will be 
followed by zero or more
+     * calls to {@link #writeNamespace(String, String)} and
+     * {@link #writeAttribute(String, String, String, String)} and a single 
call to
+     * {@link #finishStartElement()}.
+     * 
+     * @param prefix
+     *            the prefix of the element; never <code>null</code>
+     * @param namespaceURI
+     *            the namespace URI of the element; never <code>null</code>
+     * @param localName
+     *            the local name of the element; never <code>null</code>
+     * @throws OutputException
+     */
+    protected abstract void beginStartElement(String prefix, String 
namespaceURI, String localName) throws OutputException;
     
     protected abstract void writeNamespace(String prefix, String namespaceURI) 
throws OutputException;
     
     protected abstract void writeAttribute(String prefix, String namespaceURI, 
String localName, String value) throws OutputException;
     
+    protected abstract void finishStartElement() throws OutputException;
+    
     public abstract void writeEndElement() throws OutputException;
     
     public abstract void writeText(int type, String data) throws 
OutputException;

Added: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXOutputException.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXOutputException.java?rev=1441888&view=auto
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXOutputException.java
 (added)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXOutputException.java
 Sun Feb  3 10:40:10 2013
@@ -0,0 +1,34 @@
+/*
+ * 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.common.serializer.push.sax;
+
+import org.apache.axiom.om.impl.common.serializer.push.OutputException;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Wraps a {@link SAXException} thrown by a {@link ContentHandler}.
+ */
+public class SAXOutputException extends OutputException {
+    private static final long serialVersionUID = -4299745257772383270L;
+
+    public SAXOutputException(SAXException cause) {
+        super(cause);
+    }
+}

Propchange: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXOutputException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java?rev=1441888&r1=1441887&r2=1441888&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
 Sun Feb  3 10:40:10 2013
@@ -26,13 +26,20 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
+import org.apache.axiom.util.namespace.ScopedNamespaceContext;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
 
 public class SAXSerializer extends Serializer {
     private final ContentHandler contentHandler;
     private final LexicalHandler lexicalHandler;
+    private final ScopedNamespaceContext nsContext = new 
ScopedNamespaceContext();
+    private String elementURI;
+    private String elementLocalName;
+    private String elementQName;
+    private final AttributesImpl attributes = new AttributesImpl();
     
     public SAXSerializer(OMSerializable contextNode, ContentHandler 
contentHandler, LexicalHandler lexicalHandler) {
         super(contextNode);
@@ -41,51 +48,66 @@ public class SAXSerializer extends Seria
     }
 
     protected boolean isAssociated(String prefix, String namespace) throws 
OutputException {
-        // TODO Auto-generated method stub
-        return false;
+        return nsContext.getNamespaceURI(prefix).equals(namespace);
     }
 
     protected void setPrefix(String prefix, String namespaceURI) throws 
OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     public void writeStartDocument(String version) throws OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     public void writeStartDocument(String encoding, String version) throws 
OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     public void writeDTD(String rootName, String publicId, String systemId, 
String internalSubset)
             throws OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
-    protected void writeStartElement(String prefix, String namespaceURI, 
String localName)
-            throws OutputException {
-        // TODO Auto-generated method stub
-        
+    protected void beginStartElement(String prefix, String namespaceURI, 
String localName) throws OutputException {
+        elementURI = namespaceURI;
+        elementLocalName = localName;
+        if (prefix.length() == 0) {
+            elementQName = localName;
+        } else {
+            elementQName = prefix + ":" + localName;
+        }
     }
 
     protected void writeNamespace(String prefix, String namespaceURI) throws 
OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     protected void writeAttribute(String prefix, String namespaceURI, String 
localName, String value)
             throws OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
+    }
+
+    protected void finishStartElement() throws OutputException {
+        try {
+            contentHandler.startElement(elementURI, elementLocalName, 
elementQName, attributes);
+        } catch (SAXException ex) {
+            throw new SAXOutputException(ex);
+        }
+        elementURI = null;
+        elementLocalName = null;
+        elementQName = null;
+        attributes.clear();
     }
 
     public void writeEndElement() throws OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     public void writeText(int type, String data) throws OutputException {
@@ -108,7 +130,7 @@ public class SAXSerializer extends Seria
                     contentHandler.ignorableWhitespace(ch, 0, ch.length);
             }
         } catch (SAXException ex) {
-            throw new OutputException(ex);
+            throw new SAXOutputException(ex);
         }
     }
 
@@ -118,7 +140,7 @@ public class SAXSerializer extends Seria
             try {
                 lexicalHandler.comment(ch, 0, ch.length);
             } catch (SAXException ex) {
-                throw new OutputException(ex);
+                throw new SAXOutputException(ex);
             }
         }
     }
@@ -127,29 +149,29 @@ public class SAXSerializer extends Seria
         try {
             contentHandler.processingInstruction(target, data);
         } catch (SAXException ex) {
-            throw new OutputException(ex);
+            throw new SAXOutputException(ex);
         }
     }
 
     public void writeEntityRef(String name) throws OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     public void writeDataHandler(DataHandler dataHandler, String contentID, 
boolean optimize)
             throws OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     public void writeDataHandler(DataHandlerProvider dataHandlerProvider, 
String contentID,
             boolean optimize) throws OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 
     protected void serializePushOMDataSource(OMDataSource dataSource) throws 
OutputException {
-        // TODO Auto-generated method stub
-        
+        // TODO
+        throw new UnsupportedOperationException();
     }
 }

Added: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/XMLReaderImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/XMLReaderImpl.java?rev=1441888&view=auto
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/XMLReaderImpl.java
 (added)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/XMLReaderImpl.java
 Sun Feb  3 10:40:10 2013
@@ -0,0 +1,55 @@
+/*
+ * 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.common.serializer.push.sax;
+
+import java.io.IOException;
+
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.common.IContainer;
+import org.apache.axiom.om.impl.common.serializer.push.OutputException;
+import org.apache.axiom.util.sax.AbstractXMLReader;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class XMLReaderImpl extends AbstractXMLReader {
+    private final IContainer root;
+    private final boolean cache;
+
+    public XMLReaderImpl(IContainer root, boolean cache) {
+        this.root = root;
+        this.cache = cache;
+    }
+
+    public void parse(InputSource input) throws IOException, SAXException {
+        parse();
+    }
+
+    public void parse(String systemId) throws IOException, SAXException {
+        parse();
+    }
+    
+    private void parse() throws SAXException {
+        try {
+            root.internalSerialize(new SAXSerializer(root, contentHandler, 
lexicalHandler),
+                    new OMOutputFormat(), cache);
+        } catch (OutputException ex) {
+            throw (SAXException)ex.getCause();
+        }
+    }
+}

Propchange: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/XMLReaderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXOutputException.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXOutputException.java?rev=1441888&view=auto
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXOutputException.java
 (added)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXOutputException.java
 Sun Feb  3 10:40:10 2013
@@ -0,0 +1,35 @@
+/*
+ * 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.common.serializer.push.stax;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.impl.common.serializer.push.OutputException;
+
+/**
+ * Wraps an {@link XMLStreamException} thrown by {@link XMLStreamWriter}.
+ */
+public class StAXOutputException extends OutputException {
+    private static final long serialVersionUID = -8641924272865997771L;
+
+    public StAXOutputException(XMLStreamException cause) {
+        super(cause);
+    }
+}

Propchange: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXOutputException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java?rev=1441888&r1=1441887&r2=1441888&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
 Sun Feb  3 10:40:10 2013
@@ -56,7 +56,7 @@ public class StAXSerializer extends Seri
             // We cannot really differentiate between exceptions thrown by the 
XMLStreamWriter
             // and exceptions thrown by the data source itself. We wrap all 
XMLStreamExceptions
             // as OutputExceptions.
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -64,7 +64,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeStartDocument(version);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -72,7 +72,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeStartDocument(encoding, version);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -80,15 +80,15 @@ public class StAXSerializer extends Seri
         try {
             XMLStreamWriterUtils.writeDTD(writer, rootName, publicId, 
systemId, internalSubset);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
-    protected void writeStartElement(String prefix, String namespaceURI, 
String localName) throws OutputException {
+    protected void beginStartElement(String prefix, String namespaceURI, 
String localName) throws OutputException {
         try {
             writer.writeStartElement(prefix, localName, namespaceURI);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -100,7 +100,7 @@ public class StAXSerializer extends Seri
                 writer.writeDefaultNamespace(namespaceURI);
             }
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -108,10 +108,14 @@ public class StAXSerializer extends Seri
         try {
             writer.writeAttribute(prefix, namespaceURI, localName, value);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
+    protected void finishStartElement() throws OutputException {
+        // Nothing to do here
+    }
+
     protected void setPrefix(String prefix, String namespaceURI) throws 
OutputException {
         try {
             if (prefix.length() == 0) {
@@ -120,7 +124,7 @@ public class StAXSerializer extends Seri
                 writer.setPrefix(prefix, namespaceURI);
             }
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -201,7 +205,7 @@ public class StAXSerializer extends Seri
                 return true;
             }
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -209,7 +213,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeEndElement();
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -221,7 +225,7 @@ public class StAXSerializer extends Seri
                 writer.writeCharacters(data);
             }
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -229,7 +233,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeComment(data);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -237,7 +241,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeProcessingInstruction(target, data);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -245,7 +249,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeEntityRef(name);
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -253,10 +257,9 @@ public class StAXSerializer extends Seri
         try {
             dataHandlerWriter.writeDataHandler(dataHandler, contentID, 
optimize);
         } catch (IOException ex) {
-            // An OutputException thrown by StAXSerializer must always wrap an 
XMLStreamException!
-            throw new OutputException(new XMLStreamException("Error while 
reading data handler", ex));
+            throw new StAXOutputException(new XMLStreamException("Error while 
reading data handler", ex));
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 
@@ -264,10 +267,9 @@ public class StAXSerializer extends Seri
         try {
             dataHandlerWriter.writeDataHandler(dataHandlerProvider, contentID, 
optimize);
         } catch (IOException ex) {
-            // An OutputException thrown by StAXSerializer must always wrap an 
XMLStreamException!
-            throw new OutputException(new XMLStreamException("Error while 
reading data handler", ex));
+            throw new StAXOutputException(new XMLStreamException("Error while 
reading data handler", ex));
         } catch (XMLStreamException ex) {
-            throw new OutputException(ex);
+            throw new StAXOutputException(ex);
         }
     }
 }

Modified: 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1441888&r1=1441887&r2=1441888&view=diff
==============================================================================
--- 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 (original)
+++ 
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 Sun Feb  3 10:40:10 2013
@@ -46,6 +46,7 @@ import org.apache.axiom.om.impl.common.O
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
+import org.apache.axiom.om.impl.common.serializer.push.sax.XMLReaderImpl;
 import org.apache.axiom.om.impl.jaxp.OMSource;
 import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
 import org.apache.axiom.om.impl.util.EmptyIterator;
@@ -53,6 +54,7 @@ import org.apache.axiom.om.impl.util.OMS
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
 
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
@@ -1015,6 +1017,7 @@ public class OMElementImpl extends OMNod
     }
 
     public SAXSource getSAXSource(boolean cache) {
+//        return new SAXSource(new XMLReaderImpl(this, cache), new 
InputSource());
         return new OMSource(this);
     }
     


Reply via email to