Element names

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 UTC