I need to reference a sibling of a node (actually I need an interval of 5 nodes before and 5 behind a certain node).
In XSLT I used the preceding-sibling and following sibling, but in Tamino- XQuery this is not possible, at least as far as I know.
Anyone having an idea for a workaround?
Unfortunately XQuery offers only a subset of the XPath axes.
You can get all the preceding sibling elements of a node $x using the XQuery expression
and the following siblings as
(I haven’t checked whether these work in Tamino 4.1)
$x/…/[.>>$x] does not work with Tamino in result expressions (Probably not in other expressions as well) at least I cannot make it work.
I tried to use the position statement:
$x/…/[position()= 7], which works but of course I need to replace the number by something like “[position()=$x/position() + 1]”, i.e. depending on the position of the source node in the document tree, or even better as a rule “[position()< $x/position() +5 and position()>= $x/position()]”, defining the interval.
But for both I cannot figure out
a) if it is possible at all in Tamino XQUERY
b) which is the correct syntax.
Any ideas would be appreciated.
No, both << and >> do not yet work in Tamino.
Yes, this is the other way I thought of. To use the position() function within a filter upon other nodes besides the current node. But Tamino only supports a limited syntax with path expressions, i.e. only the first step of a path might be something different from a location step. Thus expressions like $x/position() are prohibited position() being a function call and not a location step. So to my knowledge Tamino does currently not allow what you want to do. I am sorry, but you’ll have to wait. I guess we’ll allow a more general path syntax in the next release.