简体   繁体   中英

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?

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.

No, the last two results are not compliant with the spec. It's a type error if an operand to the union operator is a string rather than a node, which is the case in your last two examples.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM