W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2000

Re: Element containing a list of IDs

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 21 Dec 2000 17:14:30 +0000
To: MarkH@i2.co.uk
Cc: xmlschema-dev@w3.org
Message-ID: <f5by9x9wvbd.fsf@cogsci.ed.ac.uk>
MarkH@i2.co.uk writes:

> I want to represent something like
> 
> <exporteditems>
> 	<endids>id21 id2 id5 id23</endids>
> <exporteditems/>
> 
> Where the ids are IDs (or possibly some other type).
> 
> What's wrong with this schema...?
> 
>     <element name='exporteditems'>
>      <complexType>
>       <sequence>
>        <element minOccurs='0' maxOccurs='1' name='endids'>
>          <simpleType>
>           <restriction>
>            <list itemType='ID'>
>            </list>
>           </restriction>
>          </simpleType>
>        </element>
>       </sequence>
>      </complexType>
>     </element>
> 
> I've tried a few variations but looking at previous posts the above seems to
> be ok, while XSV reports:
> 
> Problems with the schema-validity of the target
> file:/E:/My Documents/_ Work Current/_VLV/XML/vlxdoc-xed.xsd:64:12: Invalid
> cvc-complex-type.1.2.4: element {http://www.w3.org/2000/10/XMLSchema}:list
> not allowed here in element
> {http://www.w3.org/2000/10/XMLSchema}:restriction:
> file:/E:/My Documents/_ Work Current/_VLV/XML/vlxdoc-xed.xsd:64:12: Invalid
> src-resolve: undeclared element {http://www.w3.org/2000/10/XMLSchema}:list

So look at the DTD or Schema or the spec. itself [1], or best of all
the Primer [2], where you will find

  
List Type for Six US States:

            <xsd:simpleType name="USStateList">
             <xsd:list itemType="USState"/>
            </xsd:simpleType>

            <xsd:simpleType name="SixUSStates">
             <xsd:restriction base="USStateList">
              <xsd:length value="6"/>
             </xsd:restriction>
            </xsd:simpleType>

The USStateList type is directly relevant to your needs, just copy,
change the itemType and anonymise.  The SixUSStates example shows the
way forward for a more complex case.

ht

[1] http://www.w3.org/TR/xmlschema-1/
[2] http://www.w3.org/TR/xmlschema-0/#ListDt
-- 
  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 Thursday, 21 December 2000 12:14:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:19 GMT