Hi Roland,
Then you will need Schematron to test that for an b/a there is at least
a c/a with the same value. Here it is a complete working schema that
does that:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:sch="http://www.ascc.net/xml/schematron">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="b"/>
<xs:element maxOccurs="unbounded" ref="c"/>
</xs:sequence>
</xs:complexType>
<xs:key name="aOfb">
<xs:selector xpath="b/a"/>
<xs:field xpath="."/>
</xs:key>
<xs:keyref refer="aOfb" name="aOfc">
<xs:selector xpath="c/a"/>
<xs:field xpath="."/>
</xs:keyref>
</xs:element>
<xs:element name="b">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="a"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="c">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="a"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="a" type="xs:NCName">
<xs:annotation>
<xs:appinfo>
<sch:pattern name="Check that b/a has a c/a with the same
value.">
<sch:rule context="a[parent::b]">
<sch:assert test=".=../../c/a">There is no c/a with the
same value.</sch:assert>
</sch:rule>
</sch:pattern>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:schema>
On the following document
<root>
<b>
<a>John</a>
<a>Paul</a>
<a>George</a>
<a>Ringo</a>
<a>NotHere</a>
</b>
<c>
<a>John</a>
<a>Paul</a>
<a>Ringo</a>
</c>
<c>
<a>John</a>
<a>Paul</a>
<a>George</a>
</c>
</root>
I get:
SystemID: C:\george\workspace\oXygen\samples\test.xml
Location: 8:0
Description: There is no c/a with the same value. (.=../../c/a)
where line 8 is <a>NotHere</a>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com