From e8eeb99ac894dde7896d080c0bcb18335e49ee78 Mon Sep 17 00:00:00 2001 From: qxo Date: Wed, 29 Nov 2017 17:44:05 +0800 Subject: [PATCH] Repect StaxDriver in XStreamMarshaller::marshalXmlStreamWriter This commit makes sure that namespaces configured via the streamDriver property are respected. --- .../springframework/oxm/xstream/XStreamMarshaller.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java index ccb10d27c17..9ab9c9a5be3 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java @@ -696,7 +696,13 @@ public class XStreamMarshaller extends AbstractMarshaller implements BeanClassLo @Override protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException { try { - doMarshal(graph, new StaxWriter(new QNameMap(), streamWriter, this.nameCoder), null); + final StaxWriter writer; + if( streamDriver instanceof StaxDriver){ + writer = ((StaxDriver)streamDriver).createStaxWriter(streamWriter); + }else{ + writer = new StaxWriter( new QNameMap(),streamWriter, this.nameCoder); + } + doMarshal(graph,writer, null); } catch (XMLStreamException ex) { throw convertXStreamException(ex, true);