I thought I'd let you know about an interesting
processing error that occurred today when testing IBM DFDL.
An expression of the form:
{if (fn:exists(x) and fn:contains('abc',
x/y)) then 1 else 0}
gave a parser error saying that x/y
didn't exist, when x was not in the message. This surprised me,
as I was assuming that the IBM DFDL parser would lazily evaluate the operands
of the logical expression. I was going to raise a bug, but thought I had
best read the XPath 2.0 spec first. The relevant section is here:
http://www.w3.org/TR/xpath20/#id-logical-expressions
The section says that unless you are
in XPath 1.0 compatibility mode (which a DFDL processor would not be),
the order of evaluation of operands of a logical expression is actually
implementation dependent. So it is therefore unsafe to rely on lazy evaluation
to implement a guard in the manner that I had. I have rewritten the expression
as:
{if (fn:exists(x)) then if (fn:contains('abc',
x/y)) then 1 else 0 else 0}
I think this might catch people out
and is certainly worthy of mention in (at least) a tutorial on DFDL expressions.
Regards
Steve Hanson
Architect, IBM
DFDL
Co-Chair, OGF
DFDL Working Group
IBM SWG, Hursley, UK
smh@uk.ibm.com
tel:+44-1962-815848
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU