[DFDL-WG] Clarification needed " .[1] " expression on an array element

Mike Beckerle mbeckerle.dfdl at gmail.com
Tue Jun 29 11:28:47 EDT 2021


Apache Daffodil has this bug report:
https://issues.apache.org/jira/browse/DAFFODIL-2182

It calls for getting clarification from the DFDL WG.

Suppose I have an array element named "a" and it contains an assert.

The assert expression can contain the subexpression " .[1] "

Section 18 does say predicates (i.e., the square brackets) are only used
for indexing arrays. It says it is an SDE if the predicate value doesn't
evaluate to an integer index. But it does not say that one cannot put the
predicate brackets on scalars, context elements, relative path steps, etc.,
however, this can only be meaningful if the predicate value evaluates to 1.
The grammar given for the expression language explicitly does allow " .[1]
" to be syntactically allowed.

The question is does the ".[1]" mean:

(a) the whole array, so that ".[1]" refers to the first element of the
array, so equivalent to "../a[1]"
(b) the current element, so equivalent to "../a[dfdl:occursIndex()]"
(c) SDE the expression is illegal as "." is never an array, and only arrays
can be indexed with predicates.

I believe (b) is consistent with XPath behavior for XML documents.  An
online XPath tool verifies this.

That means the only way to refer to other array element items in the
infoset is to reference the array itself via ../a[N].

This has the drawback of not being polymorphic - the array element name
must be used as a path step. That may well be livable as a restriction.

-mikeb

Mike Beckerle | OGF DFDL Workgroup Co-Chair | Owl Cyber Defense |
www.owlcyberdefense.com
Please note: Contributions to the DFDL Workgroup's email discussions are
subject to the OGF Intellectual Property Policy
<http://www.ogf.org/About/abt_policies.php>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20210629/0b496958/attachment.html>


More information about the dfdl-wg mailing list