Re: XML Schema (2/25 WD) Questions

"Eric Rehm" <rehm@singingfish.com> writes:

> What's the correct way, according to the XML Schema 25-Feb-2000 WD to 
> define a <complexType> which has content based on a simple or primitive
> type, but also has other attributes and/or elements?
> 
> E.g., Are the following correct?
> 
>     <complexType name="controlledTerm" base="string" derivedBy="extension">
>         <attribute name="CSName" type="string" minOccurs="0"/>
>     </complexType>
>     <element name="genre" type="controlledTerm" />

Exactly right.

>     <simpleType name="WeightValueType" base="double">
>       <minInclusive>0.0</minInclusive>
>       <maxInclusive>1.0</maxInclusive>
>     </simpleType>
> 
>     <complexType name="WeightValue" base="WeightValueType">
>       <element name="Reference" type="ReferenceType" minOccurs="0"/>
>     </DType>
>     <element name="Confidence" type="WeightValue"/>
>
>    For instance: 
> 	<Confidence>.9<Reference idref="id123" href="www.foo.com"/></Confidence>

Nope, for four reasons:

1) To allow elements and text, you need "content='mixed'";
2) You've left off the 'derivedBy';
3) Neither value would be acceptable:  you can't go from
simple->complex by restriction, and you can't extend simple with
elements.  In other words, you can't constrain the text component of
mixed content;
4) That spurious </DType>.

>    Is this also a valid instance?
> 	<Confidence><Reference idref="id123" href="www.foo.com"/>.9</Confidence>

No, as discussed above, but it helps point out _why_.  If those two
were OK, how about this:

       <Confidence>0.<Reference.../>9</Confidence>

and so on into absurdity.

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/

Received on Monday, 27 March 2000 03:16:47 UTC