While create request XML default "ns2" prefix added with name space declaration.
I am getting request XML as below format.
<ns2:ARTNCIS xmlns:ns2="http://namespace_uri">
<ARTNCIS>
<IDOCDATA>
...
</IDOCDATA>
</ARTNCIS>
</ns2:ARTNCIS>
Expected request XML should be like below,
<ARTNCIS xmlns="http://namespace_uri">
<ARTNCIS>
<IDOCDATA>
...
</IDOCDATA>
</ARTNCIS>
</ARTNCIS>
Below provided is package-info.java file.
#XmlSchema(
namespace = "http://namespace_uri",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED,
xmlns={#XmlNs(prefix = "", namespaceURI = "http://namespace_uri")}
)
package com.vam.abc.motor;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
While marshaling JAXB element added NamespacePrefixMapper to remove default "ns2" prefix. Find below code,
NamespacePrefixMapper mapper = new NamespacePrefixMapper() {
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
if ("http://namespace_uri".equals(namespaceUri) && !requirePrefix)
return "";
return suggestion;
}
};
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
marshaller.marshal(reqObject, document);
Below is my Root Element declaration.
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = { "artncis" })
#XmlRootElement(name = "ARTNCIS")
public class ARTNCIS {
...
}
Related
Sorry for the foggy title, I know it does not tell much.
Please consider the following xsd type definition:
<xsd:complexType name="TopicExpressionType" mixed="true">
<xsd:sequence>
<xsd:any processContents="lax" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Dialect" type="xsd:anyURI" use="required"/>
<xsd:anyAttribute/>
</xsd:complexType>
Complete XSD: http://docs.oasis-open.org/wsn/b-2.xsd
Corresponding JAXB generated Java class:
package org.oasis_open.docs.wsn.b_2;
import org.w3c.dom.Element;
import javax.xml.bind.annotation.*;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "TopicExpressionType", propOrder = {
"content"
})
public class TopicExpressionType {
#XmlMixed
#XmlAnyElement(lax = true)
protected List<Object> content;
#XmlAttribute(name = "Dialect", required = true)
#XmlSchemaType(name = "anyURI")
protected String dialect;
#XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
public String getDialect() {
return dialect;
}
public void setDialect(String value) {
this.dialect = value;
}
public Map<QName, String> getOtherAttributes() {
return otherAttributes;
}
}
The first goal is to produce an XML like this with JAXB:
<wsnt:TopicExpression Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete" xmlns:tns="http://my.org/TopicNamespace">
tns:t1/*/t3
</wsnt:TopicExpression>
Please note the followings:
The value of the TopicExpression element is basically a query string that refers to QNames. Example: tns:t1/*/t3
The value of the TopicExpression element contains one or more QName like strings (tns:t1). It must be a string as in the example, it cannot be an Element (e.g.: <my-expresseion>tns:t1/*/t3<my-expresseion/>)
The value of the TopicExpression element is an arbitrary string (at least from the schema's perspective, it follows the rules defined here: https://docs.oasis-open.org/wsn/wsn-ws_topics-1.3-spec-os.pdf page 18)
Even though the value is a string, I need to define the corresponding name space declarations. So if I have an expression like this:
tns:t1 then xmlns:tns has to be declared. If my expresseion is tns:t1/*/tns2:t3 then both xmlns:tns and xmlns:tns2 have to be declared.
The second goal is to get the value of TopicExpression on the other side together with the namespace, using JAXB.
I am completely stuck, I don't know how I could implement this. My only idea is to manually build the value for the TopicExpression and somehow tell the marshaller to include the related namespace declaration despite there is no actual element using it.
Update
Example for a complete SOAP request that includes the before mentioned TopicExpression:
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeRequest</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:57182d32-4e07-4f5f-8ab3-24838b3e33ac</MessageID>
</env:Header>
<env:Body>
<ns3:Subscribe xmlns:ns3="http://docs.oasis-open.org/wsn/b-2" xmlns:ns4="http://www.w3.org/2005/08/addressing" >
<ns3:ConsumerReference>
<ns4:Address>http://my-notification-consumer-url</ns4:Address>
</ns3:ConsumerReference>
<ns3:Filter>
<ns3:TopicExpression Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple" xmlns:ns5="http://my.org/TopicNamespace" xmlns:ns6="http://extension.org/TopicNamespace">
ns5:t1/*/ns6:t3
<ns3:TopicExpression/>
</ns3:Filter>
</ns3:Subscribe>
</env:Body>
</env:Envelope>
Not sure, If I have understood your requirement correctly. See if this code sample is helpful for you. If not then maybe try to edit your question a bit and make me understand what exactly you are looking for. I will try to modify and update the code accordingly. Trying with a simple example would be better than providing the complete XSD. Also, look into the following methods: beforeMarshal and afterUnmarshal.
Following is the XML I am trying to marshal and unmarshal
<tns:TopicExpression Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete" xmlns:tns="http://my.org/TopicNamespace">
tns:t1/*/t3
</tns:TopicExpression>
TopicExpressionType.class:
#Data
#XmlAccessorType(XmlAccessType.FIELD)
public class TestPojo {
#XmlValue
private String TopicExpression;
#XmlAnyAttribute
private Map<String, Object> anyAttributes = new HashMap<>();
}
Main.class:
public class Main {
public static void main(String[] args) throws JAXBException, XMLStreamException {
final InputStream inputStream = Unmarshalling.class.getClassLoader().getResourceAsStream("topic.xml");
final XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
final Unmarshaller unmarshaller = JAXBContext.newInstance(TestPojo.class).createUnmarshaller();
final TestPojo topic = unmarshaller.unmarshal(xmlStreamReader, TestPojo.class).getValue();
System.out.println(topic.toString());
StringWriter stringWriter = new StringWriter();
Map<String, String> namespaces = new HashMap<String, String>();
namespaces.put("http://my.org/TopicNamespace", "tns");
Marshaller marshaller = JAXBContext.newInstance(TestPojo.class).createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER, namespaces);
QName qName = new QName("http://my.org/TopicNamespace","TopicExpression","tns");
JAXBElement<TestPojo> root = new JAXBElement<TestPojo>(qName, TestPojo.class, topic);
marshaller.marshal(root, stringWriter);
String result = stringWriter.toString();
System.out.println(result);
}
}
As you can see as of now I have populated the namespaces map directly. If this is dynamic then you can populate the same in a map and accordingly you can add it while marshaling.
This will provide the following output during the unmarshalling:
TestPojo(TopicExpression=
tns:t1/*/t3
, anyAttributes={Dialect=http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete})
During marshaling:
<tns:TopicExpression xmlns:tns="http://my.org/TopicNamespace" Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete">
tns:t1/*/t3
</tns:TopicExpression>
So the solution I've implemented:
Created a new TopicExpressionType class which has fields not only for the expression but for the namespaces too, used in the expression:
public class TopicExpressionType {
String dialect;
String expression;
List<Namespace> namespaces;
public TopicExpressionType(String dialect, String expression, List<Namespace> namespaces) {
this.dialect = dialect;
this.expression = expression;
this.namespaces = namespaces;
}
public static class Namespace {
String prefix;
String namespace;
public Namespace(String prefix, String namespace) {
this.prefix = prefix;
this.namespace = namespace;
}
public String getPrefix() {
return prefix;
}
public String getNamespace() {
return namespace;
}
}
}
Then implemented an XmlAdapter that is aware of the specifics, knows how to extract namespace prefixes from the expression string and it can read/write namespace declarations on the TopicExpression XML element:
public class TopicExpressionTypeAdapter extends XmlAdapter<Element, TopicExpressionType> {
#Override
public Element marshal(TopicExpressionType topicExpression) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.newDocument();
Element element = document.createElementNS("http://docs.oasis-open.org/wsn/b-2", "mns1:TopicExpression");
element.setAttribute("Dialect", topicExpression.getDialect());
element.setTextContent(topicExpression.getExpression());
for (var ns : topicExpression.namespaces) {
element.setAttribute("xmlns:" + ns.prefix, ns.namespace);
}
return element;
}
#Override
public TopicExpressionType unmarshal(Element arg0) throws Exception {
if (arg0.getFirstChild() instanceof Text text) {
var expression = text.getData();
if (expression == null || expression.isBlank())
throw new TopicExpressionAdapterException("Empty content");
// Extract the prefixes from the expression
var namespacePrefixes = new ArrayList<String>();
getNamespacePrefixes(expression, namespacePrefixes);
//Now get the namespaces for the prefixes
var nsMap = new ArrayList<TopicExpressionType.Namespace>();
for (var prefix : namespacePrefixes) {
var namespace = arg0.getAttribute("xmlns:" + prefix);
if (namespace == null || namespace.isBlank())
throw new TopicExpressionAdapterException("Missing namespace declaration for the following prefix: " + prefix);
nsMap.add(new TopicExpressionType.Namespace(prefix, namespace));
}
var dialect = arg0.getAttribute("Dialect");
if (dialect == null || dialect.isBlank())
throw new TopicExpressionAdapterException("Missing Dialect attribute");
return new TopicExpressionType(dialect, expression, nsMap);
} else {
throw new TopicExpressionAdapterException("Unexpected child element type: " + arg0.getFirstChild().getClass().getName());
}
}
public static class TopicExpressionAdapterException extends Exception {
public TopicExpressionAdapterException(String message) {
super(message);
}
}
}
Note: Implementation of the getNamespacePrefixes() method is left out intentionally from this answer.
The last step is to add the following annotation wherever the TopicExpressionType is used in JAXB generated classes:
#XmlJavaTypeAdapter(TopicExpressionTypeAdapter.class)
TopicExpressionType topicExpression;
This is my XML
<?xml version="1.0"?>
<gpx version="1.1" creator="Example" xmlns="http://www.Example.com/1" xmlns:football="https://www.Example-football.com/xsd/football-ext">
<metadata>
<name>hello world</name>
<time>2018-04-26T12:32:52</time>
<extensions>
<sportsMeta>
<football:length>5080.3714454417996</football:length>
</sportsMeta>
</extensions>
</metadata>
</gpx>
Added this to package-info.java
#javax.xml.bind.annotation.XmlSchema(namespace = "http://www.Example.com/1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, attributeFormDefault = XmlNsForm.UNQUALIFIED, xmlns = {
#javax.xml.bind.annotation.XmlNs(prefix = "football", namespaceURI = "https://www.Example-football.com/xsd/football-ext"),
#javax.xml.bind.annotation.XmlNs(prefix = "", namespaceURI = "https://www.Example-football.com/xsd/football-ext/1/1") })
package com.example.football.share.gpx;
import javax.xml.bind.annotation.XmlNsForm;
I am able to read name, time. But not able to read guid, length.
Here is SportsMeta.java
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "sportsMeta", propOrder = {
"length"
})
public class SportsMeta {
protected BigDecimal length;
public BigDecimal getLength() {
return length;
}
public void setLength(BigDecimal length) {
this.length = length;
}
}
How can I read length info from the XML file.
In your XML input you have this part:
<sportsMeta>
<football:length>5080.3714454417996</football:length>
</sportsMeta>
where the namespace prefix football refers to the namespace URI
"https://www.Example-football.com/xsd/football-ext"
as defined by xmlns:football="https://www.Example-football.com/xsd/football-ext"
in your XML.
To map this XML to Java correctly you need to specify
that namespace URI for the length property of yourSportsMeta class.
You do this by annotating the length property
with #XmlElement and specifying the namespace within there.
(See also the API documentation of XmlElement.namespace.)
#XmlElement(namespace = "https://www.Example-football.com/xsd/football-ext")
protected BigDecimal length;
My JAVA program uses an internal class hierarchy which resembles GPX 1.1, but is not identical. since rewriting it to conform 1:1 to GPX is a huge effort, I'd like to change it bit by bit, i.e. reading the <metadata> subtree into the Class MetadataType as generated with xjc from the XSD file
the remaining GPX file is parsed with DOM, until <metadata> shows up:
private void parseMetadata(MetadataType metadata, Element element) throws JAXBException {
try {
System.out.println(element.getNodeName()); // output: metadata
JAXBContext context = JAXBContext.newInstance(MetadataType.class);
javax.xml.bind.Unmarshaller u = context.createUnmarshaller();
JAXBElement<MetadataType> meta = u.unmarshal(element, MetadataType.class);
metadata = meta.getValue();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(metadata.getName()); // NULL
System.out.println(metadata.getAuthor().getName()); // NULL
}
throws
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"metadata"). Expected elements are <{http://www.topografix.com/GPX/1/1}gpx>
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:647)
the class looks like this:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "metadataType", propOrder = {
"name",
"desc",
"author",
"copyright",
"link",
"time",
"keywords",
"bounds",
"extensions"
})
#XmlRootElement(name = "metadata")
public class MetadataType {
protected String name = "";
protected String desc = "";
protected PersonType author;
protected CopyrightType copyright = new CopyrightType();
protected List<LinkType> link = new ArrayList<LinkType>();
#XmlSchemaType(name = "Date")
protected Date time;
protected String keywords = "";
protected BoundsType bounds = new BoundsType();
protected ExtensionsType extensions = new ExtensionsType();
[...]
}
is it possible to unmarshal from an XML subtree; and if yes, what am I doing wrong?
UPDATE/1:
thanks to lexicore, I'm a step further: element definitely contains the metadata node, #XmlRootElement is set, unmarshaling now with unmarshal(element, MetadataType.class).
unmarshaling works, but the content of the objects is empty. I wonder if I run into some namespace troubles here?
the package com.topografix.gpx._1._1 contains a package-info.java, generated by xjc:
#javax.xml.bind.annotation.XmlSchema(namespace = "http://www.topografix.com/GPX/1/1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.topografix.gpx._1._1;
here's one of the test files:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1"
xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"
xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
creator="GPSMAP 62s" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1
http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas /GpxExtensions/v3
http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1
http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1
http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">
<metadata>
<link href="http://www.garmin.com">
<text>Garmin International</text>
</link>
<time>2014-01-01T22:26:49Z</time>
</metadata>
[...]
UPDATE/2: the namespace/package name is right. If the namespace is set to (i.e.) "foobar", the following exception is thrown:
javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated:
javax.xml.bind.JAXBException: "foobar" doesnt contain ObjectFactory.class or jaxb.index
when initialized as before, the exception is not thrown, meaning that the namespace is correct AND the ObjectFactory.class is found.
String contextPath = MetadataType.class.getPackage().getName();
JAXBContext context = JAXBContext.newInstance(contextPath);
So, the namespace is correct, but somehow the "link" to the MetadataType class is missing?
I guess you have a few problems here:
Your MetadataType does not have the #XmlRootElement. So JAXB does not know which element is supposed to match it.
You want to unmarshal partially, but you're unmarshalling (I guess) the whole document.
What you could try:
Try unmarshalling a specific class from the specific node using the unmarshal(node, class) method
From your stack trace, you try to unmarshal gpx:gpx element, not the metadata element. You have to go deeper
You have to overtake package-info.java as well (or provide namespaces in your MetadataType, otheriwse you're missing namespaces
See this answer about partial unmarshalling.
I had this exception: unexpected element (uri:"", local:"Fid1Instruments"). Expected elements are <{http://proba.org/proba}Fid1Instruments>
i have package-info.java file:
#javax.xml.bind.annotation.XmlSchema(namespace = "http://proba.org/proba")
package com.enum1.instruments;
in the main class i do this:
JAXBContext jx = JAXBContext.newInstance(Fid1Instruments.class);
Unmarshaller u = jx.createUnmarshaller();
JAXBElement<?> ue= (JAXBElement<?>) u.unmarshal(new File("ex1.xml"));
In the generated java file:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"fid1Bond"
})
#XmlRootElement(name = "Fid1Instruments", namespace="http://proba.org/proba")
I read answers for same problems, but they doesn't work.
Based on your mappings JAXB is expecting your document to look like the following where the element Fid1Instruments is qualified by the namespace http://proba.org/proba.
<ns:Fid1Instruments xmlns:ns="http://proba.org/proba">
...
</ns:Fid1Instruments>
And you are currently passing it:
<Fid1Instruments>
...
</Fid1Instruments>
For More Information
http://blog.bdoughan.com/2010/08/jaxb-namespaces.html
I am trying to unmarshal a given XML:
<FHcomment>
<TX>rewriting of file</TX>
<tool_id>toolA</tool_id>
<tool_vendor>Company</tool_vendor>
<tool_version>1.7.36.0</tool_version>
</FHcomment>
The schema has already been compiled to JAXB classes, see here:
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"tx",
"toolId",
"toolVendor",
"toolVersion",
"userName",
"commonProperties",
"extensions"
})
#XmlRootElement(name = "FHcomment")
public class FHcomment {
#XmlElement(name = "TX", required = true)
protected TX tx;
#XmlElement(name = "tool_id", required = true)
protected BaseName toolId;
#XmlElement(name = "tool_vendor", required = true)
protected BaseName toolVendor;
#XmlElement(name = "tool_version", required = true)
protected BaseVersion toolVersion;
#XmlElement(name = "user_name")
protected BaseName userName;
#XmlElement(name = "common_properties")
protected CommonPropertiesType commonProperties;
protected ExtensionsType extensions;
#XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
.....
/*
* GETTERS and SETTERS for the fields have been removed here
*/
.....
}
My code to unmarshal the XML is as follows:
JAXBContext jc = JAXBContext.newInstance(FHcomment.class);
String s = "<FHcomment>....</Fhcomment>";
Unmarshaller unmarshaller = jc.createUnmarshaller();
XMLInputFactory fac = XMLInputFactory.newFactory();
XMLStreamReader xsr = fac.createXMLStreamReader(new StringReader(s));
JAXBElement<FHcomment> foo = unmarshaller.unmarshal(xsr, FHcomment.class);
FHcomment val = foo.getValue();
Problem: The resulting FHcomment object does not contain the children elements of FHcomment. All are null which is not the desired result.
How can I tell JAXB to completely unmarshal the given XML into an object?
EDIT: After adding a ValidationHandler to the Unmsarshaller, I got closer to the problem:
unexpected element (uri:"", local:"TX"). Expected elements are <{htp://www.example.com/mdf/v4}tool_id>,<{htp://www.example.com/mdf/v4}TX>,<{htp://www.www.example.com/mdf/v4}common_properties>,<{htp://www.example.com/mdf/v4}tool_version>,<{htp://www.example.com/mdf/v4}extensions>,<{htp://www.www.example.com/mdf/v4}tool_vendor>,<{htp://www.www.example.com/mdf/v4}user_name>
unexpected element (uri:"", local:"tool_id"). Expected elements are....
It turns out JAXB does not like the fact that the provided XML does not contain namespace information.. So how do I tell the unmarshaller to ignore the namespaces?
EDIT2:
After some more research I could not find a way to trick JAXB into working without namespace verification. I used the tutorial at http://cooljavablogs.blogspot.de/2008/08/how-to-instruct-jaxb-to-ignore.html to circumvent my problem. Not a nice solution but the best at hand...
Your XML document does not match the namespace qualification that was defined in your mappings (see: http://blog.bdoughan.com/2010/08/jaxb-namespaces.html). You could leverage an XMLFilter to apply a namespace to your XML document during the unmarshal operation.
import org.xml.sax.*;
import org.xml.sax.helpers.XMLFilterImpl;
public class NamespaceFilter extends XMLFilterImpl {
private static final String NAMESPACE = "htp://www.example.com/mdf/v4";
#Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
super.endElement(NAMESPACE, localName, qName);
}
#Override
public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException {
super.startElement(NAMESPACE, localName, qName, atts);
}
}
Below is an example of how you would leverage the XMLFilter during an unmarshal.
// Create the XMLFilter
XMLFilter filter = new NamespaceFilter();
// Set the parent XMLReader on the XMLFilter
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
filter.setParent(xr);
// Set UnmarshallerHandler as ContentHandler on XMLFilter
Unmarshaller unmarshaller = jc.createUnmarshaller();
UnmarshallerHandler unmarshallerHandler = unmarshaller
.getUnmarshallerHandler();
filter.setContentHandler(unmarshallerHandler);
// Parse the XML
InputSource xml = new InputSource("input.xml");
filter.parse(xml);
Object result = unmarshallerHandler.getResult();
For More Information
http://blog.bdoughan.com/2012/11/applying-namespace-during-jaxb-unmarshal.html
Change BaseName and TX to String and it shall work. As it is the xml doesn't comply with your schema, which is represented by the class in this case.
Try to remove following code, and try again:
#XmlType(name = "", propOrder = {
"tx",
"toolId",
"toolVendor",
"toolVersion",
"userName",
"commonProperties",
"extensions"
})
How do you have annotated the classes BaseName , BaseVersion and TX?
If you have not annotated these classes, you will annotated the String inside of this classes as #XmlValue