Description
Say we have this schema:
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:ex="http://example.com" targetNamespace="http://example.com" elementFormDefault="unqualified"> <include schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" /> <annotation> <appinfo source="http://www.ogf.org/dfdl/"> <dfdl:format ref="ex:GeneralFormat" lengthKind="delimited"/> </appinfo> </annotation> <element name="file"> <complexType> <sequence dfdl:separator="%SP;"> <element name="Type" type="xs:string" /> <element name="Values"> <complexType> <choice> <element name="Foo" type="xs:string" maxOccurs="unbounded"> <annotation> <appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator test="{ ../Type eq 'foo' }" /> </appinfo> </annotation> </element> <element name="Bar" type="xs:string" maxOccurs="unbounded"> <annotation> <appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator test="{ ../../Type eq 'bar' }" /> </appinfo> </annotation> </element> </choice> </complexType> </element> </sequence> </complexType> </element> </schema>
So it is a space separated list of items, where the first is either "foo" or "bar", and that defines the type of all following items to be an array of Foo's or an array of Bar's.
This currently fails to compile with the error
Relative path '../../Type eq foo' past root element
If we remove an up step and change the discriminators to "../Type eq 'foo'", then we get the error:
No element corresponding to step {}Type found. Possibilities for this step include: {}Foo, {}Bar.
So there is no way to reference Type using up-steps.
A workaround is to wrap the array elemens in a sequence so the choice branches are now sequenes instead of arrays. Doing this allows the scheme to work. But when a choice branch is an array, there is an implied surrounding sequence so these should be exactly the same.
Potentially related, if we change the above snippet to remove the discriminators and instead use direct dispatch and put dfdl:choiceDispatchKey on the choice and dfdl:choiceBranchKey on the Foo/Bar arrays, we get the warning and error:
DFDL property was ignored: choiceBranchKey="foo" (id: ignoreDFDLProperty)
[error] Parse Error: Choice dispatch branch failed: List(Parse Error: Array element parsed succesfully, but consumed no data and is stuck in an infinite loop as it is unbounded.
Something seems to be wrong with our implied sequence choice branches.