<structure>
<pause length="2s" />
<action ref="move" />
<action ref="replace" />
<pause length="2s" />
<pause length="2s" /> <!-- error -->
<action ref="move" />
<action ref="move" /> <!-- error -->
<pause length="2s" title="cd"/>
<pause length="2s" title="cu"/> <!-- ok -->
<action ref="move" title="m1" />
<action ref="move" title="m2" /> <!-- ok-->
<action ref="remove" />
<pause length="2s" /> <!-- error -->
<structure>
I’m a new at writing XML Schemas. I would like to know is there a way to do the following validation operation with XSD:
- STRUCTURE contains PAUSE and ACTION in any order
- STRUCTURE contains at least one ACTION
- no STRUCTURE with a PAUSE only ALLOWED
- no PAUSE can follow PAUSE, until they both (or just one if that impossible) have different @TITLE
- STRUCTURE cannot end with PAUSE
- no ACTION can follow ACTION with the same @REF, until they both (or just one if that impossible) have different @TITLE
XSD 1.0 basically allows you to specify constraints in the form of a grammar. You haven’t described your constraints that way, and I doubt whether it is possible to express them as a grammar. For rules like this you want a schema that describes a set of integrity constraints or rules, which means either Schematron or XSD 1.1 or a custom validator written using XSLT.
It’s fairly easy to express these rules as XSD 1.1 assertions on the structure element. The details depend on whether “follows” in your description means “immediately follows”.