Modifying JAXB generating classes from XML and customizing JAXB unmarshalling

snismisaHah

New Member
There is few elements in my XML/XSD like \[code\]<TestElement tc="222">SomeValue</TestElement>\[/code\]. As per the XSD tc and its value belongs to another element which has just key value pair.\[code\]<xsd:element ref="TestElement" minOccurs="0" /><xsd:element name="TestElement" type="SUBTYPE_CODES" /><xsd:complexType name="SUBTYPE_CODES"> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="tc" use="required" type="TRANS_MODE_CODES_TC" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType>\[/code\]In this way by default JAXB has generated separate class for this element with two String key and value.
JAXB generated element \[code\]@XmlElement(name = "TestElement") protected SUBTYPECODES testElement;\[/code\]Attribute class:\[code\]@XmlType(name = "SUBTYPE_CODES", propOrder = { "value"})public class SUBTYPECODES { @XmlValue protected String value; @XmlAttribute(name = "tc", required = true) protected BigInteger tc;}\[/code\]Now I have more than thousand classes for each type of attribute. And I am going to use these classes as entity classes for Hibernate.
I want to change it to in JAXB classes something like given below and get rid of all the attribute specific classes.\[code\]protected String testElementTC;protected String testElementValue;\[/code\]How can I declare above variables in JAXB generated classes without affecting marshalling/unmarshalling?
 
Back
Top