Unique attribute value within grandparent element
Posted: Thu Jan 08, 2015 4:27 pm
Hi!
Please consider the following XML document described in Relax NG(Root element- Country, contains of one or more cities; Each city has one or more streets; then each street has one children: info. Info element has text and zero or more fact elements within the text (mixed). Fact element has an ID attribute);
I want that fact elements had unique ID values at the city level (grand-grandparent). The following Schematron rule does not work;
Would you please help me on this issue?
P.S. If it was possible to write: preceding-sibling:://street/fact/@id), it may had worked, but it is not!
Thank you in advance
Please consider the following XML document described in Relax NG(Root element- Country, contains of one or more cities; Each city has one or more streets; then each street has one children: info. Info element has text and zero or more fact elements within the text (mixed). Fact element has an ID attribute);
Code: Select all
<element name="country">
<oneOrMore>
<element name="city">
<oneOrMore>
<element name="street">
<element name="info">
<mixed>
<zeroOrMore>
<element name="fact">
<attribute name="id"/>
<text/>
</element>
<zeroOrMore>
</mixed>
</element>
</element>
</oneOrMore>
</element>
</oneOrMore>
</element>
Code: Select all
<iso:rule context="city">
<iso:assert test="count(//street//fact)=count(//street//fact[not(@id=preceding- sibling::fact/@id)])">Error!
</iso:assert>
</iso:rule>
P.S. If it was possible to write: preceding-sibling:://street/fact/@id), it may had worked, but it is not!
Thank you in advance