users@jaxb.java.net

Re: Newb question regarding inheritance

From: No 0ne <no0ne_at_no0ne.org>
Date: Thu, 23 Jul 2009 22:30:52 +1000

Seems to me like you are trying to restrict the actionName/Length in the
derived classes (XSD restriction, right)?

If so, I've been disappointed as well. Page 92 of the JAXB 2.0
specification:
<quote>
  * base class: A complex type definition can derive by restriction or
  extension (i.e. {derivation method} is either “extension” or
  “restriction”).
  **However, since there is no concept in Java programming
  similar to restriction, both are handled the same.**
</quote>

Which, for me, doesn't quite holds all the water one (or no0ne, for this
instance) would expect.
Rationale: I imagine that JAXB could be enhanced to override generated
getters, and hook some code to implement the restriction (or at least
allow the implementation of a plugin specific to one needs). I'm not
saying that is safe to do in all situations, I haven't performed the
in-depth analysis of all implications/consequences; what I'm saying:
this is where I'd start looking into.

Now, the reasons for my frustrations in relation with xjc: it even
refuses to accept customizations related with an "XSD restricted"
property. Wolfgang, please, once again: where should we raise
enhancement suggestions/requests?

Best regards,

no0ne
(newb as well)
   

On Thu, 2009-07-23 at 11:32 +0300, ofira shaer wrote:
> Hi.
>
>
> I am trying to understand how do I define an inheritance in XSD.
> For example, how do i define a base class
>
> BaseAction
> String actionName
> int actionLength
> List <Fields>
>
>
> and a derived class:
>
> DerivedAction
> actionName = "derivedName"
> actionLength = derivedLength
> List<DerivedFields>
>
> Should I use restriction/extenstion/substitusion group?
> I tried some options and it seems that the combination of extension
> and restriction is pretty complicated...
> I will be very thankful for any link or a general direction.
>
> Thanks.
> Ofira.