Can anyone help me out with my problem for writing a JAXB java modules from XML Sample XML is as below. The issue I am having is with the Attribute class I am writing. In the XML you can see that the tag can be repeatable and has values. So if I put the List attribute, how can I fetch the value as well.
<top>
<attribute name="root">
<attribute name="a">
<attribute name="b">abValue</attribute>
<attribute name="d">
<attribute name="e">eValue</attribute>
</attribute>
</attribute>
<attribute name="c">cValue</attribute>
</attribute>
</top>
For human readability, here is formatted version:
<top>
<attribute name="root">
<attribute name="a">
<attribute name="b">abValue</attribute>
<attribute name="d">
<attribute name="e">eValue</attribute>
</attribute>
</attribute>
<attribute name="c">cValue</attribute>
</attribute>
</top>
I have been referred to How to deal with JAXB ComplexType with MixedContent data? However If you see the tag will not contain both Value and XML at the same time. Either it will be a List or have value.
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Top {
List<Attribute> attribute;
}
I am having the issue with my Attribute class. I have no wsdl. I want a xml to be generated from the Java object after I do some pre-processing on it based upon the name attribute within every tag. It depends upon the values I fetch from the database.
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
public class Attribute {
@XmlAttribute(name="name")
String name;
List<Attribute> attribute;
}