[Schematron] syntax?
G. Ken Holman
gkholman at CraneSoftwrights.com
Tue Nov 22 20:43:42 EST 2011
At 2011-11-22 14:23 +0000, Dave Pawson wrote:
>I'm using
> <rule context="div1[@id='pr-section']//div3">
> <let name="thisID" value="@id"/>
> <assert test="count(//div1[@id='pr-section']//div3[@id = $thisID])
> > 1" diagnostics="dupID">Two properties with same id!</assert>
>
>to test if there is a child div1[]//div3 with an id the same as the
>current element.
>
>Is my syntax right please? It seems to be picking up every such div3?
Do you perhaps have two div1's with the same @id?
Perhaps try:
count(ancestor::div1[@id='pr-section'][1]//div3[@id=$thisID]) > 1
To avoid the count() function you could do something like this in XSLT 2:
ancestor::div1[@id='pr-section'][1]//div3[@id=$thisID][not(@id is $thisID)]
... or in XSLT 1:
ancestor::div1[@id='pr-section'][1]//div3[@id=$thisID]
[generate-id(@id)!=generate-id($thisID)]
I hope this helps.
. . . . . . . . Ken
--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman at CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
More information about the Schematron
mailing list