[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

  • From: ht@c... (Henry S. Thompson)
  • To: José Manuel Beas <jmbeas@t...>
  • Date: Fri, 05 Jan 2001 14:02:43 +0000

w schema
"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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.