Search code examples
xpathtibcobusinessworks

TIBCO BusinessWorks XPath union operator


I don't fully understand the behaviour I'm seeing when using XPath union operator.

Having the following XML

<root>
    <foo>hello</foo>
    <bar>world</bar>
</root>

We get these results for different XPath expressions

  • (/root/foo | /root/bar)[1] -> hello

  • (/root/foo | /root/bar)[last()] -> world

  • (substring(/root/foo, 2, 4) | /root/bar)[1] -> ello

  • (substring(/root/foo, 2, 4) | /root/bar)[last()] -> world

So far, they are intuitive results but...

  • (/root/foo | substring(/root/bar, 2, 4))[1] -> orld (expected hello)

  • (/root/foo | substring(/root/bar, 2, 4))[last()] -> hello (expected orld)

Is there a reason for results presented? Are these compliant with XPath 2.0 spec?


Solution

  • TIBCO BusinessWorks is XPath 1.0 compliant only. Some XPath 2.0 functions are supported. (source: FAQ1-7BXZE5 on http://support.tibco.com)

    To answer your two questions:

    • "Is there a reason for results presented?"

    Yes. XPath 1.0 union results are unpredictable. A good rule: One should not rely on Union order in BusinessWorks, even for simple cases.

    • "Are these compliant with XPath 2.0 spec?"

    The results are not compliant with XPath 2.0 specification but your queries are evaluated with an XPath 1.0 engine.