Hi Mike
Yes I think your interpretation of the
spec is correct. If you removed dfdl:initiatedContent and used a
discriminator on foo instead then you have an analogous situation.
The awkward scenario is 4, when the
points of uncertainty vary depending on the occurrences.
Possibly writing Scenario 4 as follows
makes things clearer:
<xs:choice dfdl:initiatedContent="yes">
....
<xs:element name="foo" minOccurs="5"
maxOccurs="5" dfdl:initiator="foo:" dfdl:occursCountKind="fixed".../>
<xs:element name="foo" minOccurs="0"
dfdl:initiator="foo:" dfdl:occursCountKind="implicit".../>
...
</xs:choice>
When I get a chance I will create a
schema for your scenarios, and see what IBM DFDL does and what it outputs
in its trace.
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:
14/06/2019 22:57
Subject:
[DFDL-WG] Tracker
299 and clarifications needed for dfdl:initiatedContent="yes"
behaviors
Sent by:
"dfdl-wg"
<dfdl-wg-bounces@ogf.org>
Clarifications around initiatedContent="yes",
choices, and array elements
DFDL spec says in Section 15 that the root of a choice
branch must not be optional, meaning minOccurs cannot be 0.
This was questioned and resulted in tracker 299. The last
comment there suggests a need to revisit.
Here's the link: https://redmine.ogf.org/issues/299
The additional clarification I seek is whether I have
properly understood how dfdl:initiatedContent works in scenarios involving
a combination of choices with
array elements.
Consider this schema fragment:
<!-- Scenario 1 -->
<xs:choice dfdl:initiatedContent="yes">
....
<xs:element name="foo" minOccurs="5"
dfdl:initiator="foo:" dfdl:occursCountKind="parsed".../>
...
</xs:choice>
When parsing this choice, if you encounter "foo:"
in the data stream, that discriminates two things: the choice itself, and
the first occurrence of the array foo. Both that choice branch (aka the
array), and the first occurrence of the array are "known to exist"
per section 9.3.1.1.
Subsequent occurrences of additional foo elements with
their initiators "foo:" discriminate only the array occurrences.
The minOccurs="5" is ignored (except for validation)
<!-- Scenario 2 -->
<xs:choice dfdl:initiatedContent="yes">
....
<xs:element name="foo" minOccurs="5"
dfdl:initiator="foo:" dfdl:occursCountKind="fixed".../>
...
</xs:choice>
When parsing this choice, if you encounter "foo:"
in the data stream, that discriminates the choice, but only for the first
occurrence of element foo. There is no point of uncertainty for the array.
Subsequent occurrences of element foo do not discriminate anything. There
must be exactly 5 occurrences of element foo with initiators.
<!-- Scenario 3 -->
<xs:choice dfdl:initiatedContent="yes">
....
<xs:element name="foo" minOccurs="5"
dfdl:initiator="foo:" dfdl:occursCountKind="expression".../>
...
</xs:choice>
When parsing this choice, if you encounter "foo:"
that discriminates the choice, but there are no points of uncertainty for
the array. MinOccurs is ignored (except for validation).
Subsequent occurrences of element "foo" do not
discriminate anything.
<!-- Scenario 4 -->
<xs:choice dfdl:initiatedContent="yes">
....
<xs:element name="foo" minOccurs="5"
dfdl:initiator="foo:" dfdl:occursCountKind="implicit".../>
...
</xs:choice>
When parsing this choice, if you encounter "foo:"
that discriminates the choice, but there is no point of uncertainty for
the array until 5 occurrences have been parsed.
Once the occurs index is 6 then if you encounter "foo:"
that discriminates the occurrence of the array element foo, but the choice
is already decided.
I raise these scenarios because they show that there is
quite a bit of complexity associated with dfdl:initiatedContent if viewed
as a mechanism for setting discriminators.
Sometimes more than one discriminator must be set, other
times only one, and sometimes it depends on the array index.
So the question is: Is my understanding of the above scenarios
correct?
Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology
| www.tresys.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