diff --git a/kie-dmn-backend/pom.xml b/kie-dmn-backend/pom.xml
index cca3edf..660292a 100644
--- a/kie-dmn-backend/pom.xml
+++ b/kie-dmn-backend/pom.xml
@@ -42,16 +42,6 @@
xmlunit-core
test
-
- net.java.dev.stax-utils
- stax-utils
-
-
- com.bea.xml
- jsr173-ri
-
-
-
org.slf4j
diff --git a/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxReader.java b/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxReader.java
index 8405713..e1e299f 100644
--- a/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxReader.java
+++ b/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxReader.java
@@ -12,9 +12,9 @@
public class CustomStaxReader extends StaxReader {
-
/**
- * ATTENTION use read-only methods do not mutate
+ * ATTENTION this is intercepted during XStream StaxDriver creation as there is no proper API to inherit.
+ * Do not mutate reference - mutating this reference would not sort any effect on the actual underlying StaxReader
*/
private XMLStreamReader in;
diff --git a/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxWriter.java b/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxWriter.java
index fcda02b..6bc097d 100644
--- a/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxWriter.java
+++ b/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/CustomStaxWriter.java
@@ -3,6 +3,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+import com.thoughtworks.xstream.io.StreamException;
import com.thoughtworks.xstream.io.naming.NameCoder;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxWriter;
@@ -10,10 +11,16 @@
public class CustomStaxWriter extends StaxWriter {
/**
- * ATTENTION use read-only methods do not mutate
+ * ATTENTION this is intercepted during XStream StaxDriver creation as there is no proper API to inherit.
+ * Do not mutate reference - mutating this reference would not sort any effect on the actual underlying StaxWriter
*/
private XMLStreamWriter out;
-
+ private int tagDepth = 0;
+ private static enum Op {
+ START_NODE, END_NODE, VALUE;
+ }
+ private Op lastOp = null;
+
public CustomStaxWriter(QNameMap qnameMap, XMLStreamWriter out, boolean writeStartEndDocument, boolean repairingNamespace, NameCoder nameCoder) throws XMLStreamException {
super(qnameMap, out, writeStartEndDocument, repairingNamespace, nameCoder);
this.out = out;
@@ -26,4 +33,50 @@ public void writeNamespace(String prefix, String uri) throws XMLStreamException
public void setDefaultNamespace(String uri) throws XMLStreamException {
out.setDefaultNamespace(uri);
}
+
+ @Override
+ public void endNode() {
+ if ( this.lastOp == Op.END_NODE ) {
+ try {
+ out.writeCharacters( System.lineSeparator() );
+ for ( int i = 0; i < (tagDepth-1); i++ ) { out.writeCharacters(" "); }
+ } catch (XMLStreamException e) {
+ throw new StreamException(e);
+ }
+ }
+ super.endNode();
+ --this.tagDepth;
+
+ this.lastOp = Op.END_NODE;
+
+ if ( this.tagDepth == 0 ) {
+ // closed last element before EOF
+ try {
+ out.writeCharacters( System.lineSeparator() );
+ } catch (XMLStreamException e) {
+ throw new StreamException(e);
+ }
+ }
+ }
+
+ @Override
+ public void startNode(String arg0) {
+ try {
+ out.writeCharacters( System.lineSeparator() );
+ for ( int i = 0; i < tagDepth; i++ ) { out.writeCharacters(" "); }
+ } catch (XMLStreamException e) {
+ throw new StreamException(e);
+ }
+ super.startNode(arg0);
+ ++this.tagDepth;
+
+ this.lastOp = Op.START_NODE;
+ }
+
+ @Override
+ public void setValue(String text) {
+ super.setValue(text);
+
+ this.lastOp = Op.VALUE;
+ }
}
diff --git a/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java b/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java
index 4ccbf90..d3fe588 100644
--- a/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java
+++ b/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java
@@ -20,11 +20,8 @@
import com.thoughtworks.xstream.io.xml.AbstractPullReader;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxDriver;
-import com.thoughtworks.xstream.io.xml.StaxReader;
import com.thoughtworks.xstream.io.xml.StaxWriter;
-import javanet.staxutils.StaxUtilsXMLOutputFactory;
-
import org.kie.dmn.feel.model.v1_1.Artifact;
import org.kie.dmn.feel.model.v1_1.Association;
import org.kie.dmn.feel.model.v1_1.AuthorityRequirement;
@@ -71,7 +68,6 @@
import java.io.*;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
@@ -95,18 +91,6 @@ public class XStreamMarshaller
// qmap.registerMapping(new javax.xml.namespace.QName("http://www.omg.org/spec/FEEL/20140401", "feel", "feel"), "dddecision"); // FIXME still not sure how to output non-used ns like 'feel:'
staxDriver = new StaxDriver() {
-
- private XMLOutputFactory outputFactory = null;
-
- public XMLOutputFactory getOutputFactory() {
- if (outputFactory == null) {
- XMLOutputFactory factory = new StaxUtilsXMLOutputFactory(super.getOutputFactory());
- factory.setProperty(StaxUtilsXMLOutputFactory.INDENTING, Boolean.TRUE);
- outputFactory = factory;
- }
- return outputFactory;
- }
-
public AbstractPullReader createStaxReader(XMLStreamReader in) {
return new CustomStaxReader(getQnameMap(), in);
}