tags:

views:

59

answers:

2

When you generate java classes with JAXB you'll always get a Class named ObjectFactory. In this class there is a private attribute QName with the namespace in it.

Is it possible to tell the generator to make this attribute accessible from the outside. So maybe make it public or create a getter for it?

A: 

I am not aware of a way to do this using the XJC tool that comes with the JAXB reference implementation. However, XJC does allow you to create custom plugins that may let you do need to:

Blaise Doughan
+1  A: 

I believe those private static QName fields are only generated if the ObjectFactory needs methods that create JAXBElement<...> instances. If you call one of those methods to get a JAXBElement instance, you can then invoke its getName method to retrieve its associated QName.

kschneid
I can create such a JAXBElement<> by passing null value into the createXXX() method. With this created object I could use the getName() method. Thanks for this solution.
flash