diff --git a/org.springframework.core/src/main/java/org/springframework/util/xml/StaxResult.java b/org.springframework.core/src/main/java/org/springframework/util/xml/StaxResult.java
new file mode 100644
index 00000000000..b9a5e617530
--- /dev/null
+++ b/org.springframework.core/src/main/java/org/springframework/util/xml/StaxResult.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.util.xml;
+
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.sax.SAXResult;
+
+import org.xml.sax.ContentHandler;
+
+/**
+ * Implementation of the Result tagging interface for StAX writers. Can be constructed with a
+ * XMLEventConsumer or a XMLStreamWriter.
+ *
+ *
This class is necessary because there is no implementation of Source for StaxReaders in JAXP 1.3.
+ * There is a StAXResult in JAXP 1.4 (JDK 1.6), but this class is kept around for back-ward compatibility
+ * reasons.
+ *
+ *
Even though StaxResult extends from SAXResult, calling the methods of
+ * SAXResult is not supported. In general, the only supported operation on this class is
+ * to use the ContentHandler obtained via {@link #getHandler()} to parse an input source using an
+ * XMLReader. Calling {@link #setHandler(org.xml.sax.ContentHandler)} will result in
+ * UnsupportedOperationExceptions.
+ *
+ * @author Arjen Poutsma
+ * @see XMLEventWriter
+ * @see XMLStreamWriter
+ * @see javax.xml.transform.Transformer
+ * @since 3.0
+ */
+public class StaxResult extends SAXResult {
+
+ private XMLEventWriter eventWriter;
+
+ private XMLStreamWriter streamWriter;
+
+ /**
+ * Constructs a new instance of the StaxResult with the specified XMLStreamWriter.
+ *
+ * @param streamWriter the XMLStreamWriter to write to
+ */
+ public StaxResult(XMLStreamWriter streamWriter) {
+ super.setHandler(new StaxStreamContentHandler(streamWriter));
+ this.streamWriter = streamWriter;
+ }
+
+ /**
+ * Constructs a new instance of the StaxResult with the specified XMLEventWriter.
+ *
+ * @param eventWriter the XMLEventWriter to write to
+ */
+ public StaxResult(XMLEventWriter eventWriter) {
+ super.setHandler(new StaxEventContentHandler(eventWriter));
+ this.eventWriter = eventWriter;
+ }
+
+ /**
+ * Constructs a new instance of the StaxResult with the specified XMLEventWriter and
+ * XMLEventFactory.
+ *
+ * @param eventWriter the XMLEventWriter to write to
+ * @param eventFactory the XMLEventFactory to use for creating events
+ */
+ public StaxResult(XMLEventWriter eventWriter, XMLEventFactory eventFactory) {
+ super.setHandler(new StaxEventContentHandler(eventWriter, eventFactory));
+ this.eventWriter = eventWriter;
+ }
+
+ /**
+ * Returns the XMLEventWriter used by this StaxResult. If this StaxResult was
+ * created with an XMLStreamWriter, the result will be null.
+ *
+ * @return the StAX event writer used by this result
+ * @see #StaxResult(javax.xml.stream.XMLEventWriter)
+ */
+ public XMLEventWriter getXMLEventWriter() {
+ return eventWriter;
+ }
+
+ /**
+ * Returns the XMLStreamWriter used by this StaxResult. If this StaxResult
+ * was created with an XMLEventConsumer, the result will be null.
+ *
+ * @return the StAX stream writer used by this result
+ * @see #StaxResult(javax.xml.stream.XMLStreamWriter)
+ */
+ public XMLStreamWriter getXMLStreamWriter() {
+ return streamWriter;
+ }
+
+ /**
+ * Throws a UnsupportedOperationException.
+ *
+ * @throws UnsupportedOperationException always
+ */
+ @Override
+ public void setHandler(ContentHandler handler) {
+ throw new UnsupportedOperationException("setHandler is not supported");
+ }
+}
diff --git a/org.springframework.core/src/test/java/org/springframework/util/xml/StaxResultTests.java b/org.springframework.core/src/test/java/org/springframework/util/xml/StaxResultTests.java
new file mode 100644
index 00000000000..ecd6a26ea88
--- /dev/null
+++ b/org.springframework.core/src/test/java/org/springframework/util/xml/StaxResultTests.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.util.xml;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import org.junit.Before;
+import org.junit.Test;
+
+public class StaxResultTests {
+
+ private static final String XML = "