tags:

views:

43

answers:

1

Hey all,

I'm using JAXB to generate java code from xsd.

I want to generate attribute (Java code) that cannot be used in the xml.

For example:

<xs:complexType name="Button">
   <xs:attribute type="xs:string"
                 name="ribbonGroup">
</xs:complexType>

I want to see the getter and setter of the attribute ribbonGroup in the Button java class, but I don't want to let the user the option to see this attribute in the xml.

Thank you.

A: 

I want to see the getter and setter of the attribute ribbonGroup in the Button java class,

You want to have the get/set method generated for ribbonGroup. This means you should not use="prohibited" to prevent the generation by XJC.

but I don't want to let the user the option to see this attribute in the xml.

Am I correct that you mean you don't want the ribbonGroup property to be loaded when reading XML, or saved when writing to XML? If so, the @XmlTransient annotation is used to prevent a field/property from being marshaled to XML.

Ultimately I believe you want the JAXB XJC tool to generate this annotation? Is this correct?

Blaise Doughan
mmm, I want that the user that write the XML occurding to the XSD, won't be able to use the "ribbonGroup" attribute.
Rotem
But, I want that the JAXB that generate java code from the XSD will generate the getters and setters to the Button class, cause I want to use it in my code.
Rotem
JAXB will generate the get/set for ribbonGroup. If the property is the marked @XmlTransient it will still exist but will not be populated during an unmarshal or produce an XML attribute when marshalling.
Blaise Doughan
Will the user that writing the XML from the XDS see this attribute?
Rotem
There is a propery called: use="prohibited", this will now allow the user to use the ribbonGroup attribute but the JAXB doesn't generate this attribute (getter and setter) to the Button Class. Can I make the JAXB to generate this attribute althought the use="prohibited" is used?
Rotem
this will now allow = this will not allow
Rotem
I have updated my answer, can you confirm I have the correct understanding of your issue?
Blaise Doughan