Hi,

I made some changes to capture the Unknown element or attribute into an extension:

qname: The QName of the element/attribute
value: The XML string of the element/attribute value

This way we don't have to hack the XMLStreamReader to take snapshots of the NamespaceContext. As we pull events out of the stream reader, we write them to a stream writer that is backed by a StringWriter. At the end of the element, we get an XML string for the element. It can be then used to create XMLStreamReader or DOM Document. The new approach should be more simpler and efficient in memory and execution.

Thanks,
Raymond
--------------------------------------------------
From: <[email protected]>
Sent: Monday, August 03, 2009 8:01 PM
To: <[email protected]>
Subject: svn commit: r800664 - in /tuscany/java/sca/modules/contribution/src/main: java/org/apache/tuscany/sca/contribution/processor/ java/org/apache/tuscany/sca/contribution/processor/xml/ resources/META-INF/services/

Author: rfeng
Date: Tue Aug  4 03:01:18 2009
New Revision: 800664

URL: http://svn.apache.org/viewvc?rev=800664&view=rev
Log:
Use the xml string to keep the unknown elements (reduce complexity and memory usage over an in memory stream reader)

Added:

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLStreamSerializer.java (with props)
Removed:

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyNamespaceContext.java

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/TuscanyXMLStreamReader.java

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLDocumentStreamReader.java

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLEventsStreamReader.java

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLFragmentStreamReader.java
Modified:

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java

tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java

tuscany/java/sca/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java?rev=800664&r1=800663&r2=800664&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java (original) +++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java Tue Aug 4 03:01:18 2009
@@ -50,7 +50,7 @@
public class ExtensibleStAXArtifactProcessor implements StAXArtifactProcessor<Object> { private static final Logger logger = Logger.getLogger(ExtensibleStAXArtifactProcessor.class.getName());

- private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS, "anyElement"); + private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS, "any");

    private XMLInputFactory inputFactory;
    private XMLOutputFactory outputFactory;

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java?rev=800664&r1=800663&r2=800664&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java (original) +++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java Tue Aug 4 03:01:18 2009
@@ -27,6 +27,7 @@
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.StreamReaderDelegate;
import javax.xml.validation.Schema;
import javax.xml.validation.ValidatorHandler;

@@ -46,11 +47,10 @@
 *
 * @version $Rev$ $Date$
 */
-class ValidatingXMLStreamReader extends TuscanyXMLStreamReader implements XMLStreamReader { +class ValidatingXMLStreamReader extends StreamReaderDelegate implements XMLStreamReader {

private static final Logger logger = Logger.getLogger(ValidatingXMLStreamReader.class.getName());

-    private int level;
    private ValidatorHandler handler;
    private final Monitor monitor;

@@ -158,11 +158,9 @@
        try {
            switch (event) {
                case XMLStreamConstants.START_DOCUMENT:
-                    level++;
                    handler.startDocument();
                    break;
                case XMLStreamConstants.START_ELEMENT:
-                    level++;
                    handleStartElement();
                    break;
                case XMLStreamConstants.PROCESSING_INSTRUCTION:
@@ -176,7 +174,6 @@
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    handleEndElement();
-                    level--;
                    break;
                case XMLStreamConstants.END_DOCUMENT:
                    handler.endDocument();
@@ -201,13 +198,10 @@
            try {
                switch (event) {
                    case XMLStreamConstants.START_DOCUMENT:
-                        level++;
                        handler.startDocument();
                        break;
                    case XMLStreamConstants.START_ELEMENT:
-                        level++;
                        handleStartElement();
-                        pushContext();
                        return event;
                    case XMLStreamConstants.PROCESSING_INSTRUCTION:
handler.processingInstruction(super.getPITarget(), super.getPIData());
@@ -220,8 +214,6 @@
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        handleEndElement();
-                        level--;
-                        popContext();
                        return event;
                    case XMLStreamConstants.END_DOCUMENT:
                        handler.endDocument();

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java?rev=800664&r1=800663&r2=800664&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java (original) +++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java Tue Aug 4 03:01:18 2009
@@ -74,7 +74,7 @@
// are just the string representation fo the attribute
    }

- public void resolve(Extension arg0, ModelResolver arg1) throws ContributionResolveException { + public void resolve(Extension model, ModelResolver modelResolver) throws ContributionResolveException {

    }
}

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java?rev=800664&r1=800663&r2=800664&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java (original) +++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java Tue Aug 4 03:01:18 2009
@@ -18,25 +18,18 @@
 */
package org.apache.tuscany.sca.contribution.processor.xml;

-import static javax.xml.stream.XMLStreamConstants.CDATA;
-import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
-import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.io.StringReader;
+import java.io.StringWriter;

-import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import javax.xml.stream.events.XMLEvent;

+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Extension;
import org.apache.tuscany.sca.contribution.Constants;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
@@ -45,16 +38,21 @@
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;

-public class AnyElementProcessor implements StAXArtifactProcessor<Object> { - private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS, "anyElement"); +public class AnyElementProcessor implements StAXArtifactProcessor<Extension> { + private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS, "any");

+    private AssemblyFactory assemblyFactory;
    private XMLInputFactory xmlInputFactory;
+    private XMLOutputFactory xmlOutputFactory;
+
    @SuppressWarnings("unused")
    private Monitor monitor;


public AnyElementProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { + assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); xmlInputFactory = modelFactories.getFactory(XMLInputFactory.class); + xmlOutputFactory = modelFactories.getFactory(XMLOutputFactory.class);
        this.monitor = monitor;
    }

@@ -62,8 +60,8 @@
        return ANY_ELEMENT;
    }

-    public Class<Object> getModelType() {
-        return Object.class;
+    public Class<Extension> getModelType() {
+        return Extension.class;
    }

    /**
@@ -74,43 +72,19 @@
     * @return
     * @throws XMLStreamException
     */
-    @SuppressWarnings("unchecked")
- public Object read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
-
-        // Custom variables
-        String currentElement = null;
-        List eventsList = new ArrayList();
-
- Map<String, NamespaceContext> eventContext = new HashMap<String, NamespaceContext>();
-
-        try {
-            // Cast the block of unknown elements into document
- XMLDocumentStreamReader docReader = new XMLDocumentStreamReader(reader);
-
- XMLEventReader xmlEventReader = xmlInputFactory.createXMLEventReader(docReader);
-
-            while (xmlEventReader.hasNext()) {
-                XMLEvent event = xmlEventReader.nextEvent();
-
- // Populate the eventContext map with the current element's name
-                // and corresponding NamesapceContext
- if (currentElement != null && !(eventContext.containsKey(currentElement))) { - eventContext.put(currentElement, reader.getNamespaceContext());
-                }
-
-                // Populate the list with the XMLEvents
-                eventsList.add(event);
-                if (event.isStartElement()) {
-                    currentElement = reader.getName().getLocalPart();
-                }
-                if (event.isEndDocument()) {
- return new XMLEventsStreamReader(eventsList, eventContext);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
+ public Extension read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        QName name = reader.getName();
+        XMLStreamSerializer serializer = new XMLStreamSerializer();
+        StringWriter sw = new StringWriter();
+ XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(sw);
+        serializer.serialize(reader, writer);
+        writer.flush();
+
+        Extension ext = assemblyFactory.createExtension();
+        ext.setQName(name);
+        ext.setValue(sw.toString());
+
+        return ext;
    }

    /**
@@ -119,43 +93,19 @@
     * @param model
     * @param writer
     */
- public void write(Object model, XMLStreamWriter writer) throws XMLStreamException {
-        if (!(model instanceof XMLStreamReader)) {
+ public void write(Extension model, XMLStreamWriter writer) throws XMLStreamException {
+        Object value = model.getValue();
+        if (!(value instanceof String)) {
            return;
        }
-        XMLStreamReader reader = (XMLStreamReader)model;
-
-        int event = reader.getEventType();
-        while (reader.hasNext()) {
-            switch (event) {
-                case START_ELEMENT:
-
- writer.writeStartElement(reader.getPrefix(), reader.getLocalName(), reader.getNamespaceURI()); - for (int i = 1; i <= reader.getAttributeCount(); i++) { - writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader - .getAttributeLocalName(i), reader.getAttributeValue(i));
-                    }
-                    break;
-
-                case CHARACTERS:
-                    writer.writeCharacters(reader.getText());
-                    break;
-
-                case CDATA:
-                    writer.writeCData(reader.getText());
-                    break;
-
-                case END_ELEMENT:
-                    writer.writeEndElement();
-                    break;
-            }
-            if (reader.hasNext()) {
-                event = reader.next();
-            }
-        }
+        String xml = (String) value;
+ XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(new StringReader(xml));
+        // Position the reader to the root element
+        reader.nextTag();
+        XMLStreamSerializer serializer = new XMLStreamSerializer();
+        serializer.serialize(reader, writer);
    }

- public void resolve(Object model, ModelResolver resolver) throws ContributionResolveException {
-
+ public void resolve(Extension model, ModelResolver resolver) throws ContributionResolveException {
    }
}

Added: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLStreamSerializer.java URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLStreamSerializer.java?rev=800664&view=auto
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLStreamSerializer.java (added) +++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLStreamSerializer.java Tue Aug 4 03:01:18 2009
@@ -0,0 +1,287 @@
+/*
+ * 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.tuscany.sca.contribution.processor.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * The XMLStreamSerializer pulls events from the XMLStreamReader and dumps into the XMLStreamWriter
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLStreamSerializer implements XMLStreamConstants {
+    public static final String NAMESPACE_PREFIX = "ns";
+    private static int namespaceSuffix;
+
+    /*
+ * The behavior of the Serializer is such that it returns when it encounters the starting element for the second + * time. The depth variable tracks the depth of the Serializer and tells it when to return. Note that it is assumed
+     * that this Serialization starts on an Element.
+     */
+
+    /**
+     * Field depth
+     */
+    private int depth;
+
+    /**
+ * Generates a unique namespace prefix that is not in the scope of the NamespaceContext
+     *
+     * @param nsCtxt
+     * @return string
+     */
+    private String generateUniquePrefix(NamespaceContext nsCtxt) {
+        String prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+        // null should be returned if the prefix is not bound!
+        while (nsCtxt.getNamespaceURI(prefix) != null) {
+            prefix = NAMESPACE_PREFIX + namespaceSuffix++;
+        }
+
+        return prefix;
+    }
+
+    /**
+     * Method serialize.
+     *
+     * @param node
+     * @param writer
+     * @throws XMLStreamException
+     */
+ public void serialize(XMLStreamReader node, XMLStreamWriter writer) throws XMLStreamException {
+        serializeNode(node, writer);
+    }
+
+    /**
+     * @param reader
+     * @param writer
+     * @throws XMLStreamException
+     */
+ protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        int count = reader.getAttributeCount();
+        String prefix;
+        String namespaceName;
+        String writerPrefix;
+        for (int i = 0; i < count; i++) {
+            prefix = reader.getAttributePrefix(i);
+            namespaceName = reader.getAttributeNamespace(i);
+            /*
+ * Due to parser implementations returning null as the namespace URI (for the empty namespace) we need to + * make sure that we deal with a namespace name that is not null. The best way to work around this issue is
+             * to set the namespace URI to "" if it is null
+             */
+            if (namespaceName == null) {
+                namespaceName = "";
+            }
+
+            writerPrefix = writer.getPrefix(namespaceName);
+
+            if (!"".equals(namespaceName)) {
+                // prefix has already being declared but this particular
+                // attrib has a
+                // no prefix attached. So use the prefix provided by the
+                // writer
+ if (writerPrefix != null && (prefix == null || prefix.equals(""))) { + writer.writeAttribute(writerPrefix, namespaceName, reader.getAttributeLocalName(i), reader
+                        .getAttributeValue(i));
+
+                    // writer prefix is available but different from the
+                    // current
+ // prefix of the attrib. We should be declaring the new
+                    // prefix
+                    // as a namespace declaration
+ } else if (prefix != null && !"".equals(prefix) && !prefix.equals(writerPrefix)) {
+                    writer.writeNamespace(prefix, namespaceName);
+ writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader
+                        .getAttributeValue(i));
+
+ // prefix is null (or empty), but the namespace name is
+                    // valid! it has not
+ // being written previously also. So we need to generate
+                    // a prefix
+                    // here
+                } else if (prefix == null || prefix.equals("")) {
+ prefix = generateUniquePrefix(writer.getNamespaceContext());
+                    writer.writeNamespace(prefix, namespaceName);
+ writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader
+                        .getAttributeValue(i));
+                } else {
+ writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader
+                        .getAttributeValue(i));
+                }
+            } else {
+                // empty namespace is equal to no namespace!
+ writer.writeAttribute(reader.getAttributeLocalName(i), reader.getAttributeValue(i));
+            }
+
+        }
+    }
+
+    /**
+     * Method serializeCData.
+     *
+     * @param reader
+     * @param writer
+     * @throws XMLStreamException
+     */
+ protected void serializeCData(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCData(reader.getText());
+    }
+
+    /**
+     * Method serializeComment.
+     *
+     * @param reader
+     * @param writer
+     * @throws XMLStreamException
+     */
+ protected void serializeComment(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeComment(reader.getText());
+    }
+
+    /**
+     * @param reader
+     * @param writer
+     * @throws XMLStreamException
+     */
+ protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        String prefix = reader.getPrefix();
+        String nameSpaceName = reader.getNamespaceURI();
+        if (nameSpaceName != null) {
+            String writerPrefix = writer.getPrefix(nameSpaceName);
+            if (writerPrefix != null) {
+ writer.writeStartElement(nameSpaceName, reader.getLocalName());
+            } else {
+                if (prefix != null) {
+ writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName);
+                    writer.writeNamespace(prefix, nameSpaceName);
+                    // writer.setPrefix(prefix, nameSpaceName);
+                } else {
+ // [rfeng] We need to set default NS 1st before calling writeStateElement
+                    writer.setDefaultNamespace(nameSpaceName);
+ writer.writeStartElement(nameSpaceName, reader.getLocalName());
+                    writer.writeDefaultNamespace(nameSpaceName);
+                }
+            }
+        } else {
+            writer.writeStartElement(reader.getLocalName());
+        }
+
+        // add the namespaces
+        int count = reader.getNamespaceCount();
+        String namespacePrefix;
+        for (int i = 0; i < count; i++) {
+            namespacePrefix = reader.getNamespacePrefix(i);
+ // [rfeng] The following is commented out to allow to default ns + // if (namespacePrefix != null && namespacePrefix.length() == 0) {
+            // continue;
+            // }
+
+ serializeNamespace(namespacePrefix, reader.getNamespaceURI(i), writer);
+        }
+
+        // add attributes
+        serializeAttributes(reader, writer);
+
+    }
+
+    /**
+     * Method serializeEndElement.
+     *
+     * @param writer
+     * @throws XMLStreamException
+     */
+ protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeEndElement();
+    }
+
+    /**
+     * Method serializeNamespace.
+     *
+     * @param prefix
+     * @param uri
+     * @param writer
+     * @throws XMLStreamException
+     */
+ private void serializeNamespace(String prefix, String uri, XMLStreamWriter writer) throws XMLStreamException {
+        String prefix1 = writer.getPrefix(uri);
+        if (prefix1 == null) {
+            writer.writeNamespace(prefix, uri);
+            // writer.setPrefix(prefix, uri);
+        }
+    }
+
+    /**
+     * Method serializeNode.
+     *
+     * @param reader
+     * @param writer
+     * @throws XMLStreamException
+     */
+ protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        while (true) {
+            int event = reader.getEventType();
+            if (event == START_ELEMENT) {
+                serializeElement(reader, writer);
+                depth++;
+            } else if (event == ATTRIBUTE) {
+                serializeAttributes(reader, writer);
+            } else if (event == CHARACTERS) {
+                serializeText(reader, writer);
+            } else if (event == COMMENT) {
+                serializeComment(reader, writer);
+            } else if (event == CDATA) {
+                serializeCData(reader, writer);
+            } else if (event == END_ELEMENT) {
+                serializeEndElement(writer);
+                depth--;
+            } else if (event == START_DOCUMENT) {
+                depth++; // if a start document is found then increment
+                writer.writeStartDocument();
+                // the depth
+            } else if (event == END_DOCUMENT) {
+                if (depth != 0) {
+                    depth--; // for the end document - reduce the depth
+                }
+                writer.writeEndDocument();
+            }
+            if (depth == 0) {
+                break;
+            }
+            if (reader.hasNext()) {
+                reader.next();
+            } else {
+                break;
+            }
+        }
+    }
+
+    /**
+     * @param reader
+     * @param writer
+     * @throws XMLStreamException
+     */
+ protected void serializeText(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCharacters(reader.getText());
+    }
+}

Propchange: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLStreamSerializer.java
------------------------------------------------------------------------------
   svn:eol-style = native

Propchange: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/XMLStreamSerializer.java
------------------------------------------------------------------------------
   svn:keywords = Rev Date

Modified: tuscany/java/sca/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=800664&r1=800663&r2=800664&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original) +++ tuscany/java/sca/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Tue Aug 4 03:01:18 2009
@@ -17,7 +17,7 @@

# Implementation class for the artifact processor extension
org.apache.tuscany.sca.contribution.xml.ContributionMetadataProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#contribution,model=org.apache.tuscany.sca.contribution.ContributionMetadata
-org.apache.tuscany.sca.contribution.processor.xml.AnyElementProcessor;qname=http://www.w3.org/2001/XMLSchema#anyElement,model=java.lang.Object
+org.apache.tuscany.sca.contribution.processor.xml.AnyElementProcessor;qname=http://www.w3.org/2001/XMLSchema#any,model=org.apache.tuscany.sca.assembly.Extension
org.apache.tuscany.sca.contribution.namespace.impl.NamespaceImportProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#import,model=org.apache.tuscany.sca.contribution.namespace.NamespaceImport
org.apache.tuscany.sca.contribution.namespace.impl.NamespaceExportProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#export,model=org.apache.tuscany.sca.contribution.namespace.NamespaceExport
org.apache.tuscany.sca.contribution.java.impl.JavaImportProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#import.java,model=org.apache.tuscany.sca.contribution.java.JavaImport


Reply via email to