This is one of the variants I tried:
following-sibling[name()!=Reference]
It looks to me as if you're trying to learn the language by trial and error. Guesswork will never get you there.
An axis-name in XPath is always followed by "::" and a NodeTest. "following-sibling" without "::" is interpreted as an element name, so this test is looking for all child elements named following-sibling whose name is the same as the content of the grandchild element named Reference. In other words, your guess is a pretty wild one.
You want test="following-sibling::*[1][self::Reference]"
That is:
- select all the following sibling elements (following-sibling::*)
- choose the first one ([1])
- select this element if its name is Reference ([self::Reference])
- return true if the resulting node-set is non-empty
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference