[XML Schema 1.1] I need an example that illustrates the usefulness of xs:error

Hi Folks,

Consider this usage of xs:error:

<xs:element name="Publication" type="PublicationType">
     <xs:alternative test="@kind eq 'magazine'" type="MagazineType" />
     <xs:alternative test="@kind eq 'book'" type="BookType" />
     <xs:alternative test="(@kind ne 'book') and (@kind ne 'magazine')" 
                     type="xs:error" />
</xs:element>

It says that if an instance document has a Publication element with a kind attribute not equal to 'book' or 'magazine' then throw an error.

But that doesn't illustrate the usefulness of xs:error because the same functionality can be accomplished by simply constraining @kind:

<attribute name="kind">
    <simpleType>
        <restriction base="string">
            <enumeration value="book" />
            <enumeration value="magazine" />
        </restriction>
    </simpleType>
</attribute>

Can you provide an example that illustrates the usefulness of xs:error?

/Roger

Received on Tuesday, 21 July 2009 19:57:35 UTC