jQuery in Action, 2nd edition*
The moose likes XML and Related Technologies and the fly likes JAXB - getting java class for an xml-tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB - getting java class for an xml-tag" Watch "JAXB - getting java class for an xml-tag" New topic
Author

JAXB - getting java class for an xml-tag

Simran Brar
Greenhorn

Joined: Jun 01, 2004
Posts: 3
Hi All,

I just started using JAXB in a new project. I have successfully created the schema objects using the xsd and compiled etc etc.

One gating item is - I am not sure on how to get the name of corresponding java class depending on the xml-tag? For e.g. I have this defined in the xsd:

<xsd:element name="assembly-lot">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="lot" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="lot-attr" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="product" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="operation" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="route" minOccurs="0" maxOccurs="1"/>
<xsd:element ref="lot-hist" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

Now the user can configure some update logic (in a customized flat file)like if value of assembly-lot/product = 'XYZ' then change
assembly-lot/operation='123'.

After unmarshalling and parsing this customized rule, how can I know that for assembly-lot, the name of the class that I need to work with is AssemblyLot? Is there a way to get the java class instance depending on QName?

- Any help would be much appreciated
Thanks
Simran
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JAXB - getting java class for an xml-tag