The requested nodes cannot be selected with a single XPath 1.0 expression .
If the hosting language is XSLT 1.0, then an expression can be created using the current() function, which selects the desired nodes.
Use the following XPath 2.0 expression:
for $x in /*/e[@s = (preceding-sibling::e | following-sibling::e ) /@s ], $y in /*/e[@s = $x/@s] return $x[not(@t = $y/@t)]
source share