OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem w/ Schema for elements with similar defs



"Josť Manuel Beas" <jmbeas@telenium.es> writes:

> > Without prejudice wrt the 'extension' issue, I commend Jeff's _other_
> > solution to you, the one using a repeated <choice>.
> >
> 
> But this is the core of my problem. I'd like to "declare" an "object class"
> named "recurso" wich has a lot in common with "consulta". But they are not
> the same "class", "consulta" is more than "recurso". The technical problem
> arises when I am trying to say that:
> 
> Recurso ::= "<recurso" AttributesOfRecurso ">" (Texto)* "</recurso>"
> Consulta ::= "<consulta" AttributesOfRecurso ">" (Texto|Imagen)*
> "</consulta>"
> 
> e.g.
> <consulta nombre="C1">
>   <imagen nombre="I1"/>
>   <texto nombre="T1"/>
>   <imagen nombre="I2"/>
> </consulta>
> 
> 
> But with the Schema mechanism "extension" like Jeff proposes I cannot write
> the former example because it is treated like:
> 
> Consulta ::= "<consulta" AttributesOfRecurso ">" (Texto Imagen)*
> "</consulta>"
> 
> i.e. every "Texto" has to be followed by a "Imagen", and that's not what I
> am looking for. :-(

Ah, right.  Well, somewhat counter-intuitively, the way to get what
you want is to define consulto first, conceptually, and define recurso 
as a _restriction_ of it:

 <xs:complexType name="cType">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
   <xs:element ref="Texto"/>
   <xs:element ref="Imagen"/>
  </xs:choice>
  <xs:attribute name="ra1" type="..."/>
  <xs:attribute name="ra2" type="..."/>
  . . .
 </xs:complexType>

 <xs:complexType name="rType">
  <xs:complexContent>
   <xs:restriction base="cType"
    <xs:choice minOccurs="0" maxOccurs="unbounded">
     <xs:element ref="Texto"/>
     <xs:element ref="Imagen"/>
    </xs:choice>
   </xs:restriction>
  </xs:complexContent>
 </xs:complexType>

Hope this helps,

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/