users@jaxb.java.net

Re: Schema best practice for modeling UML association

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Fri, 11 Jan 2008 18:01:12 -0500

Sorry my my lack of RTFM. The answer to my question is described in
"7.8.2.2 Generalize/Specialize baseType with attribute @name" of JAXB
2.1 spec and would look like this:

<complexType abstract="true" name="IdentifiableType">
<attribute name="id" type="ID" use="required">
<xs:annotation><xs:appinfo>
<jaxb:property>
<jaxb:baseType name=”IdentifiableType.class”/>
</jaxb:property>
</xs:appinfo></xs:annotation>
</attribute>
<attribute name="dependsUpon" type="IDREF" use="optional"/>
</complexType>

Let me know if I am offbase anywhere. Thanks.

Farrukh Najmi wrote:
>
> Answering my own question, I am assuming that the best practice would
> be ID/IDREF as datatype for id attribute and dependsUpon attribute
> respectively.:
>
> <complexType abstract="true" name="IdentifiableType">
> <attribute name="id" type="ID" use="required"/>
> <attribute name="dependsUpon" type="IDREF" use="optional"/>
> </complexType>
>
> I am further assuming that Key/KeyRef is not advised as it is overly
> complex and ugly.
>
> Let me know if I am offbase.
>
> On a related note, if I use the above schema, it generates a getter
> method like the following:
>
> Object getDependsUpon();
>
> How can I customize it so it generated a getter method like:
>
> IdentifiableType getDependsUpon();
>
> Thanks.
>
> Farrukh Najmi wrote:
>> Dear Colleagues,
>>
>> I have the following simple schema that defines a type hierarchy with
>> base IdentifiableType and derived types FooType and BarType.
>> The BaseType defines an id attribute that uniquely identifies the
>> object. It also defines a dependsUpon attribute which is intended to
>> reference
>> a concrete sub-type of IdentifiableType. I am looking for guidance on
>> how to design my schema to that the generated bindings will use Java
>> object reference exemplified by the getDependsUpon method below:
>>
>> Class IdentifiableType {
>> String getId();
>> IdentifiableType getDependsUpon();
>> }
>>
>> What I want to avoid is a getter that returns the id value for the
>> dependency object shown below:
>> String getDependsUpon();
>>
>> The simplified schema is as follows and I have the flexibility to
>> make changes to it to accomplish what I need in the bindings.
>>
>> <complexType abstract="true" name="IdentifiableType">
>> <attribute name="id" type="anyURI" use="required"/>
>> <attribute name="dependsUpon" type="anyURI" use="optional"/>
>> </complexType>
>> <complexType name="FooType">
>> <complexContent>
>> <extension base="tns:IdentifiableType">
>> ....
>> </extension>
>> </complexContent>
>> </complexType>
>>
>> <complexType name="BarType">
>> <complexContent>
>> <extension base="tns:IdentifiableType">
>> ....
>> </extension>
>> </complexContent>
>> </complexType>
>>
>> TIA for your help.
>>
>
>


-- 
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com