[ 
https://issues.apache.org/jira/browse/DAFFODIL-2887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dave Thompson closed DAFFODIL-2887.
-----------------------------------

Verified the specified commit (commit 2037fe9a54db0ea17ba4871c99a6e2f0eb4f13a3) 
is included in the latest pull from the daffodil repository.

Verified, via review, changes identified in the commit comment were 
implemented. 

Verified the affected daffodil subproject sbt test suites executed 
successfully, including the added test.

Rolled commit back to pre-fix commit and verified that the identified error 
message as identified in the initial writeup occurred with the added test.

> Choice branch array with discriminator or direct dispatch broken
> ----------------------------------------------------------------
>
>                 Key: DAFFODIL-2887
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2887
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Front End
>    Affects Versions: 3.7.0
>            Reporter: Steve Lawrence
>            Priority: Major
>             Fix For: 3.8.0
>
>
> Say we have this schema:
> {code:xml}
> <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>
> {code}
> 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
> {code}
>  Relative path '../../Type eq foo' past root element
> {code}
> If we remove an up step and change the discriminators to "../Type eq 'foo'", 
> then we get the error:
> {code}
> No element corresponding to step {}Type found. Possibilities for this step 
> include: {}Foo, {}Bar.
> {code}
> 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:
> {code}
> 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.
> {code}
> Something seems to be wrong with our implied sequence choice branches.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to