|
Subject: [xsl] XPath for expressing contiguous elements? From: "Costello, Roger L. costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 1 May 2017 12:59:49 -0000 |
Hi Folks,
I want an XPath expression that implements this rule:
All <A> elements shall be contiguous within <Test>.
In this example all A's are contiguous, so the rule is satisfied:
<Test>
<B/>
<A/>
<A/>
<A/>
<B/>
</Test>
In this example there is an intervening B, so the rule is not satisfied:
<Test>
<B/>
<A/>
<A/>
<B/>
<A/>
<B/>
</Test>
Below is the XPath that I created. I have two questions about it:
(1) Is it correct? Do you see anything it would fail to catch?
(2) Is there a better (simpler, more efficient) XPath expression?
Here is the XPath (within a Schematron rule):
<sch:rule context="Test">
<sch:assert test="
every $i in A satisfies
(if ($i/preceding-sibling::A) then
$i/preceding-sibling::*[1][self::A] else true())
and
(if ($i/following-sibling::A) then
$i/following-sibling::*[1][self::A] else true())
">
All A's shall be contiguous within Test.
</sch:assert>
</sch:rule>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Thread | Re: [xsl] XPath for expressing cont, Syd Bauman s.bauman@ | |
| Date | Re: [xsl] XPath for expressing cont, Syd Bauman s.bauman@ | |
| Month |