users@jaxb.java.net

AW: Still no Substitution group support?

From: Yi Wasser <yi_wasser_at_freenet.de>
Date: Fri, 06 Jun 2003 14:20:39 +0200

Hello, everyone,

I have a similiar problem for the extension. So to make it simple, I
continue with the "animal" schema instead to post my own.

My wished schema will look like this:

 <xs:schema ..>
 <xs:ComplexType name="Animal">
   <xs:attribute name="name" type="xs:string"
 use="required"/>
 </xs:ComplexType>

 <xs:ComplexType name="dogType">
   <xs:ComplexContent>
     <xs:extension base="Animal/>
     <!--add dog specific elements/attr-->
   </xs:ComplexContent>
 </xs:ComplexType>

 <xs:ComplexType name="catType">
   <xs:ComplexContent>
     <xs:extension base="Animal/>
     <!--add cat specific elements/attr-->
   </xs:ComplexContent>
 </xs:ComplexType>

 <xs:element name="creature" type="Animal"/>
</xs:schema>

and the XML instance document should look like this:

 ...
 <creature name="myDog" xsi:type="dogType">
   <!-- here is dog specific elments/attr --> <!-- here validation excpetion
thrown -->
 </creature>

My own schema's structure is sth look like the above. But during
unmarshalling, JAXB threw validation exception ---- It seems that it will
not accept any extra elements from derived type like "catType" or "dogType".

I've read some posts here, it is said that in JAXB1.0.1 only substitution
for element is supported, but not substitution for complex type. My question
is: Do we have a workaround to cope with the above schema ? ---If I use the
<xs:sequence> solution in the previous post, then the Java application has
to know all the data type in advance. This is not ok in my case, I need a
generic program which shall be able to handle classes that are added later.

Can anyone give me a hint?
Thanks!






> -----Ursprungliche Nachricht-----
> Von: Discussion list for the Java Architecture for XML Binding
> [mailto:JAXB-INTEREST_at_JAVA.SUN.COM]Im Auftrag von Ganga Sah
> Gesendet: Freitag, 6. Juni 2003 08:03
> An: JAXB-INTEREST_at_JAVA.SUN.COM
> Betreff: Re: Still no Substitution group support?
>
>
> How about this:
>
> <xs:schema ..>
> <xs:ComplexType name="Animal">
> <xs:attribute name="name" type="xs:string"
> use="required"/>
> </xs:ComplexType>
>
> <xs:ComplexType name="dogType">
> <xs:ComplexContent>
> <xs:extension base="Animal/>
> <!--add dog specific elements/attr-->
> </xs:ComplexContent>
> </xs:ComplexType>
>
> <xs:ComplexType name="catType">
> <xs:ComplexContent>
> <xs:extension base="Animal/>
> <!--add cat specific elements/attr-->
> </xs:ComplexContent>
> </xs:ComplexType>
>
> <xs:sequence>
> <xs:element name="dog" type="dogType"/>
> <xs:element name="cat" type="catType"/>
> </xs:sequence>
>
> </xs:schema>
>
>
> --- Gary Gregory <ggregory_at_seagullsw.com> wrote:
> > IOW, how do I do this:
> >
> > Snoopy.xml:
> > <dog name="Snoopy"><!-- dog elements --></dog>
> >
> > Felix.xml:
> > <cat name="Felix"><!-- cat elements --></cat>
> >
> > And get
> >
> > interface Dog extends Animal
> > interface Cat extends Animal
> > Animal implements get/setName()
> >
> > ?
> >
> > Thanks,
> > Gary
> >
> >
> > -----Original Message-----
> > From: Gary Gregory
> > Sent: Thursday, June 05, 2003 16:13
> > To: 'Discussion list for the Java Architecture for
> > XML Binding'
> > Subject: Still no Substitution group support?
> >
> > Hello,
> >
> > From the 1.0 spec:
> >
> > "Substitution group
> > Any XML Schema concepts indicating that substitution
> > group support is
> > a necessary component of the schema should be
> > reported as an error."
> >
> > When will Substitution group be supported?
> >
> > Is my only alternative is to use a vendor extension
> > to specify a common
> > supertype?
> >
> > Thanks,
> > Gary
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
>
>