James Cummings writes:
 > What I want to be able to test is whether every MS mentioned
 > in a particular @wit is then given a reading. (And
 > vice-versa.)
 > So if we have an element like:
 > -------
 > <antiphon id="c1692" wit="CAO Hyd Cht">
 > Benedicat terra
 >         <app><rdg wit="CAO">Domino et omnia</rdg>
 >         <rdg wit="Hyd Cht">deo et cuncta</rdg></app>
 > nascentia in ea hymnum
 >         <app><rdg wit="CAO">dicat Alleluia alleluia. alleluia alleluia</rdg>
 >         <rdg wit="Hyd Cht">dicant ei in saecula</rdg></app>.
 > </antiphon>
 > -------
 > What we want to be able to test is that for each app, that
 > there is a rdg/@wit which contains each of the manuscripts
 > mentioned in [log in to unmask]  And of course the reverse, that
 > for each manuscript in the antiphon/@wit that every app
 > has a rdg/@wit which contains the manuscript sigil.

well, you can test one way by making the @wit attribute of <rdg> be of
type IDREF, and the @id attribute of <app> is of type ID.
Then the XML/SGML parser will check that no <rdg> does not have a
corresponding <app>.

You can check the other way (that every <app> has at least one <rdg>)
very easily in XSLT, using the "key" feature, eg

 <xsl:key name="RDGINGS" match="rgd" use="@wit"/>


 <xsl:template match="app">
  <xsl:if test="key('RDGINGS',@id) =0">
   <xsl:message>Look out <xsl:value-of select="@id"/> has no rdgs</xsl:message>

all untested, but this is the kind of thing XSLT is very good at.

if that does not make sense, please ask further