Given the following XML I want to reference the different exercises by their type:

```
<root>
    <exercises type="foo">
        <text></text>
    </exercises>
    <exercises type="bar">
        <audio></audio>
    </exercises>
</root>

```

I would set this up like that:

```
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- xml def -->
<xs:element name="root">
<xs:complexType>
    <xs:sequence>
        <xs:element name="exercises" type="foo-exercises"/>
        <xs:element name="exercises" type="bar-exercises"/>
    </xs:sequence>
</xs:complexType>
</xs:element>

```

But how do I explicitly check for the "type" definition in the given xml? That is, that the elements are of the given type? That is, that the given types are checked against the corresponding definition?

---

Edit:
I put it oddly: My problem is, to reference the "type" / attribute not in the type definition but in the reference to the fields. 

Say: I want to check, whether there actually are 3 elements of type foo and 2 elements of type bar. So exercise is not descriptive enough...