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

Element names

From: Daniel Acton <dacton@itouch.co.za>
Date: Sat, 2 Dec 2000 20:56:31 +0200 (SAST)
To: xmlschema-dev@w3.org
Message-ID: <Pine.BSF.4.21.0012022025290.55438-100000@alcapone.intouch.co.za>

Hi.

I am trying to make an xmlschema to vaalidate different instances of an
xml document. Do I have to explicitly name the elements in the schema, or
can I make an element be recognised by it's attributes. Here's a scenario:

--First instance--
<Dog>
  <sleep time="10" energy="5joules"/>
  <walk time="10km" energy="10joules"/>
  ...
</Dog>

--Second instance--
<Cat>
  <sleep time="25" energy="14joules"/>
  <stroll distance="2km" energy="50joules"/>
  ...
</Cat>


--Schema--

<xsd:element name="sleep" type="activityType"/>
<xsd:element name="walk" type="activityType"/>

<xsd:complexType="activityType">
  <xsd:attribute name="distance" type="xsd:string"/>
  <xsd:attribute name="energy" type="xsd:string"/>
</xsd:complexType>


The above schema, I assume, and once again am standing to correction,
would validate the first instance, but not the second. I have tried
something similar, and have received the following:  
 > Element 'stroll' not expected

Is there a way I can tell the schema to expect an element with those
attributes, but not explicitly state the name?

Thank you in advance
Daniel
Received on Saturday, 2 December 2000 14:00:17 GMT

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