W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2003

simple schema Q

From: Sam Carleton <sam@linux-info.net>
Date: Sun, 2 Mar 2003 20:39:49 -0500
To: xmlschema-dev@w3.org
Message-ID: <20030303013949.GB11053@miltonstreet.com>

Hi,

I have a very simply scema Q.  I am defining a menu in XML and
trying to get the schema put together for it.  The problem I am
having is that a menu must have at least one item element and can
have zero or more itemSep<arators> elements.  I cannot figure out
how to layout the schema for this.  What I have currently is:

<xs:complexType name="menuItem">
  <xs:choice>
    <xs:element name="item" type="itemItem" maxOccurs="unbounded"/>
    <xs:element name="itemSep" type="itemSepItem" minOccurs="0" maxOccurs="unbounded"/>
  </xs:choice>
  <xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>

<xs:complexType name="itemItem">
  <xs:sequence>
    <xs:element name="menu" type="menuItem" minOccurs="0"/>
  </xs:sequence>
  <xs:attribute name="name" type="xs:string" use="required"/>
  <xs:attribute name="url" type="xs:anyURI" use="optional"/>
</xs:complexType>

<xs:complexType name="itemSepItem"/>

Sam

P.S.  As you can tell, I name my types based on the element name
then tag Item onto the end.  Is there a standard that I could
adopt? Or at least a better way of doing this?
Received on Sunday, 2 March 2003 20:41:00 GMT

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