|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Problem w/ Schema for elements with similar defs
"José Manuel Beas" <jmbeas@t...> 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@c...
URL: http://www.ltg.ed.ac.uk/~ht/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








