
Section 18 only says that about arrays, because we don't allow more complicated predicates that you can have with XPath, such as /class/student[@rolllno = 493]. But saying "only used for indexing arrays" is a bit misleading. The infoset has no concept of an array, it just has elements that can have the same name, so the predicate is selecting one of those. Take these three schema snippets... . 1) xs:element name="x" minOccurs="3" maxOccurs="3" ... 2) xs:element name="x" minOccurs="1" ... xs:element name="x" minOccurs="1" ... xs:element name="x" minOccurs="1" ... 3) xs:element name="x" minOccurs="1" ... xs:element name="y" minOccurs="0" ... xs:element name="x" minOccurs="1" ... xs:element name="z" minOccurs="0" ... xs:element name="x" minOccurs="1" ... Each of these can give rise to an infoset containing ... "x" : "value1" "x" : "value2" "x" : "value3" A predicate of x[2] returns the 2nd "x" value in all cases. Maybe we should take an erratum on section 18 to clarify that. To your question ... if other XPath tools allow it and give an obvious behaviour then we should follow that ... so that's (b). I'll add to agenda for next WG call. Regards Steve Hanson IBM Hybrid Integration, Hursley, UK Architect, IBM DFDL Co-Chair, OGF DFDL Working Group smh@uk.ibm.com tel:+44-1962-815848 mob:+44-7717-378890 Note: I work Tuesday to Friday From: "Mike Beckerle" <mbeckerle.dfdl@gmail.com> To: "DFDL-WG" <dfdl-wg@ogf.org> Date: 29/06/2021 16:31 Subject: [EXTERNAL] [DFDL-WG] Clarification needed " .[1] " expression on an array element Sent by: "dfdl-wg" <dfdl-wg-bounces@ogf.org> 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 -- dfdl-wg mailing list dfdl-wg@ogf.org https://www.ogf.org/mailman/listinfo/dfdl-wg 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