Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:woodstox-3.2.4 and 3.9.0 with xerces-2.8.1 or oracle xml v2 parser
-
Number of attachments :
Description
Everything works fine when using sjsxp 1.0.1 parser, but with woodstox...
Marshalling to DOM Node directly works:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document nsDom = builder.newDocument();
marshaller.marshal(csJaxb, nsDom);
Marshalling through writer fail in both xerces and oracle parser:
DOMResult result = new DOMResult(nsDom);
XMLEventWriter writer = XMLOutputFactory.newInstance().createXMLEventWriter(result);
// XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(result);
marshaller.marshal(csJaxb, writer);
I'm using EventWriter version because we do xml schema validation and another EventWriter is chained to track XPath of validation errors.
xerces stack trace:
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
at org.apache.xerces.dom.CoreDocumentImpl.checkDOMNSErr(Unknown Source)
at org.apache.xerces.dom.AttrNSImpl.setName(Unknown Source)
at org.apache.xerces.dom.AttrNSImpl.<init>(Unknown Source)
at org.apache.xerces.dom.CoreDocumentImpl.createAttributeNS(Unknown Source)
at org.apache.xerces.dom.ElementImpl.setAttributeNS(Unknown Source)
at com.ctc.wstx.dom.DOMWrappingWriter.outputAttribute(DOMWrappingWriter.java:537)
at com.ctc.wstx.dom.DOMWrappingWriter.writeNamespace(DOMWrappingWriter.java:300)
at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.beginStartTag(XMLStreamWriterOutput.java:124)
at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.beginStartTag(XmlOutputAbstractImpl.java:98)
at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.startElement(NamespaceContextImpl.java:483)
at com.sun.xml.bind.v2.runtime.XMLSerializer.endNamespaceDecls(XMLSerializer.java:283)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:586)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:312)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:175)
oracle stack trace
oracle.xml.parser.v2.XMLDOMException: invalid namespace http://www.europa.eu/schengen/sis/xsd/v1/csmessages for prefix xmlns
at oracle.xml.parser.v2.XMLElement.setAttributeNS(XMLElement.java:1015)
at com.ctc.wstx.dom.DOMWrappingWriter.outputAttribute(DOMWrappingWriter.java:537)
at com.ctc.wstx.dom.DOMWrappingWriter.writeNamespace(DOMWrappingWriter.java:300)
at com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.beginStartTag(XMLStreamWriterOutput.java:124)
at com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.beginStartTag(XmlOutputAbstractImpl.java:98)
at com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.startElement(NamespaceContextImpl.java:483)
at com.sun.xml.bind.v2.runtime.XMLSerializer.endNamespaceDecls(XMLSerializer.java:283)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:586)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:312)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:175)
Quick question: would it be possible to try and see what xml would straight xml event writer (to a file) produce, with otherwise similar setup. That is, instead of DOMResult, use a stream result?
It is bit difficult to troubleshoot this problem without knowing more about call sequences, but perhaps same problem would occur with non-repairing stream writer too.
One work-around you could also try is to set repairing mode on in the output factory, to see if that would resolve the problem.