W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2004

RE: Extending abstract elements with a choice

From: Shane Lauf <srl01@uow.edu.au>
Date: Thu, 2 Sep 2004 14:47:58 +1000
To: <xmlschema-dev@w3.org>
Message-ID: <E1C2jX0-0008TU-5h@frink.w3.org>

George,

Thanks very much for the quick reply on this - I'll give it a try. There's
no way to do it in one go (i.e. without the tmp element), right?

Shane

> -----Original Message-----
> From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org]
On
> Behalf Of George Cristian Bina
> Sent: Thursday, September 02, 2004 1:10 PM
> To: Shane Lauf; xmlschema-dev@w3.org
> Subject: Re: Extending abstract elements with a choice
> 
> 
> Hi Shane,
> 
> I guess can do that with a restriction to an empty content model and then
> extend that to your desired content model:
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>   <xsd:element name="test">
>     <xsd:complexType>
>       <xsd:sequence>
>         <xsd:element ref="myAbstractElement"/>
>       </xsd:sequence>
>     </xsd:complexType>
>   </xsd:element>
>   <xsd:element name="myAbstractElement" type="myAbstractElementType"
> abstract="true"/>
>   <xsd:complexType name="myAbstractElementType">
>     <xsd:sequence>
>       <xsd:element ref="Object1" minOccurs="0"/>
>       <xsd:element ref="Object2" minOccurs="0"/>
>     </xsd:sequence>
>   </xsd:complexType>
>   <xsd:element name="Object1"/>
>   <xsd:element name="Object2"/>
>   <xsd:complexType name="tmp">
>     <xsd:complexContent>
>       <xsd:restriction base="myAbstractElementType"/>
>     </xsd:complexContent>
>   </xsd:complexType>
>   <xsd:element name="myConcreteElement"
> substitutionGroup="myAbstractElement">
>     <xsd:complexType>
>       <xsd:complexContent>
>         <xsd:extension base="tmp">
>           <xsd:choice>
>             <xsd:element ref="SpecialObject1"/>
>             <xsd:sequence>
>               <xsd:element ref="Object1" minOccurs="0"/>
>               <xsd:element ref="Object2" minOccurs="0"/>
>             </xsd:sequence>
>           </xsd:choice>
>         </xsd:extension>
>       </xsd:complexContent>
>     </xsd:complexType>
>   </xsd:element>
>   <xsd:element name="SpecialObject1"/>
> </xsd:schema>
> 
> 
> <?xml version="1.0"?>
> <test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:noNamespaceSchemaLocation="test.xsd">
>   <myConcreteElement>
>     <SpecialObject1></SpecialObject1>
>   </myConcreteElement>
> </test>
> 
> Best Regards,
> George
> -------------------------------------------------------
> George Cristian Bina mailto:george@oxygenxml.com
> <oXygen/> XML Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com/
> 
> 
> ----- Original Message -----
> From: "Shane Lauf" <srl01@uow.edu.au>
> To: <xmlschema-dev@w3.org>
> Sent: Thursday, September 02, 2004 5:24 AM
> Subject: Extending abstract elements with a choice
> 
> 
> >
> > I have a question about extending abstract elements with a choice, and
> > maintaining substitutability.
> >
> > Say I have an abstract element myAbstractElement, defined with some
child
> > elements which all have minOccurs=0 attributes set.
> >
> >       <xsd:sequence>
> >        <xsd:element ref="Object1" minOccurs="0"/>
> >        <xsd:element ref="Object2" minOccurs="0"/>
> >       </xsd:sequence>
> >
> > Is there a way that I can extend/restrict myAbstractElement to another
> > element myConcreteElement, which ends up with a definition semantically
> > equivalent to:
> >      <xsd:sequence>
> >      <xsd:choice>
> >       <xsd:element ref="SpecialObject1"/>
> >       <xsd:sequence>
> >        <xsd:element ref="Object1" minOccurs="0"/>
> >        <xsd:element ref="Object2" minOccurs="0"/>
> >       </xsd:sequence>
> >      </xsd:choice>
> >     </xsd:sequence>
> >
> > - in otherwords, so that myConcreteElement must have one or the other of
> > [the child elements as defined in myAbstractElement i.e. Object1 and
> Object
> > 2], [a SpecialObject1 child] - and still be substitutable for
> > myAbstractElement?
> >
> > Regards,
> >
> > Shane
> >
> >
> >
> 
> 
Received on Thursday, 2 September 2004 04:49:06 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:06 UTC