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: Fri, 3 Sep 2004 16:52:14 +1000
To: <xmlschema-dev@w3.org>
Message-ID: <E1C37ww-0006Pg-I3@frink.w3.org>


Thanks again for your help. Your approach worked perfectly, though I now
realise there was a bug in my original question. In the "semantically
equivalent to..." bit, it should have been
       <xsd:element ref="Object1"/>
       <xsd:element ref="Object2"/>
i.e. without the minOccurs="0" on each of these. I changed this in your
solution and it started giving me the (correct) validation errors I was
hoping for when the child elements weren't present in myConcreteElement.

That said, I think I may have managed to do it in one go without the tmp

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="test">
    <xsd:element ref="myAbstractElement"/>
 <xsd:element name="myAbstractElement" type="myAbstractElementType"
abstract="true"/>  <xsd:complexType name="myAbstractElementType">
   <xsd:element ref="Object1" minOccurs="0"/>
   <xsd:element ref="Object2" minOccurs="0"/>
 <xsd:element name="myConcreteElement"
    <xsd:restriction base="myAbstractElementType">
      <xsd:element ref="SpecialObject1"/>
       <xsd:element ref="Object1"/>
       <xsd:element ref="Object2"/> 
       <!-- note - had to remove the minOccurs="0" on these two-->
 <xsd:element name="Object1"/>
 <xsd:element name="Object2"/>
 <xsd:element name="SpecialObject1"/>

With this, the following file (correctly) fails in the same way as your
method, with the error "Require mandatory child elements (SpecialObject1 |
(Object1, Object2))" using both XMLSpy and MSV.

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Is this a valid way of doing things, or am I missing something?
Interestingly, it works exactly the same doing myConcreteElement as an
extension on myAbstractElement instead of as a restriction.

Thanks again,


> -----Original Message-----
> From: George Cristian Bina [mailto:george@sync.ro]
> Sent: Thursday, September 02, 2004 7:54 PM
> To: Shane Lauf
> Cc: xmlschema-dev@w3.org
> Subject: Re: Extending abstract elements with a choice
> Hi Shane,
>  > There's
>  > no way to do it in one go (i.e. without the tmp element), right?
> That is a type not an element. AFAIK yes, you need to have an additional
> type.
> Best Regards,
> George
> -----------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor & XSLT Editor/Debugger
> http://www.oxygenxml.com
> Shane Lauf wrote:
> > George,
> >
> > Thanks very much for the quick reply on this - I'll give it a try.
> > no way to do it in one go (i.e. without the tmp element), right?
> >
> > Shane
Received on Friday, 3 September 2004 06:53:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:24 UTC