W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2010

RE: help with xsd

From: Michael Kay <mike@saxonica.com>
Date: Fri, 15 Jan 2010 09:29:33 -0000
To: "'apollo'" <apollo135@gmail.com>, <xmlschema-dev@w3.org>
Message-ID: <1B01A50563C64BD09FD499C97A1B5374@Sealion>
> 
> I am a new-user of xsd, and at the moment I got confusing 
> with some stuff Could someone please correct me if we can 
> declare something like:
> 
> <xsd:sequence>
>    <xsd:element name="var_name" type="xsd:string"/>
> 
> <!-- this means optional. which is similar to <xsd:element 
> name="var_name" type="xsd:string" use="optional"/> 
> --> 
> 
>    <xsd:element name="var_value" type="xsd:integer" 
> use="required"/> </xsd:sequence>
> 
> In some stuff, it is mentioned that  'use="optional/required" 
> ' can be added to attribute only. but elements are instances 
> of attributes . Is this correct?
> 

There are many differences in the way attributes and elements are described
in XML Schema (probably more differences than are strictly necessary).

With attributes, you use use="optional|required" to indicate optionality.

With elements, you use minOccurs="0|1|....". The difference of course is
that elements can appear more than once, so it's possible to say things such
as minOccurs="4", though this rarely arises in practice.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 
Received on Friday, 15 January 2010 09:30:01 GMT

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