You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Steve Lawrence (Jira)" <ji...@apache.org> on 2020/06/10 17:22:47 UTC

[jira] [Created] (DAFFODIL-2354) newVariableInstance leads to mark state exception

Steve Lawrence created DAFFODIL-2354:
----------------------------------------

             Summary: newVariableInstance leads to mark state exception
                 Key: DAFFODIL-2354
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2354
             Project: Daffodil
          Issue Type: Bug
          Components: Back End
    Affects Versions: 2.6.0
            Reporter: Steve Lawrence


The following schema uses newVariableInstance with the goal of parameterizing repeated types. Note that this snippet does not even use the type and count variables, or parameterizes anything, which is the intention. The ultimate goal is to have set the type and count variables based on the type/count elements, and then use those variables in the choice rather than using XPath to access the elements. Things were simplified to create the smallest test case.

{code:xml}
<?xml version="1.0" encoding="UTF-8"?> 

<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/">

  <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />

  <xs:annotation>
    <xs:appinfo source="http://www.ogf.org/dfdl/">
      <dfdl:format ref="GeneralFormat" />
      <dfdl:defineVariable name="type" type="xs:int" />
      <dfdl:defineVariable name="count" type="xs:int" />
    </xs:appinfo>
  </xs:annotation>

  <xs:element name="file">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="records" maxOccurs="unbounded" dfdl:terminator="%NL;">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="type" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="1" />
              <xs:element name="count" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="1" />
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo source="http://www.ogf.org/dfdl/">
                    <dfdl:newVariableInstance ref="type" />
                    <dfdl:newVariableInstance ref="count" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:sequence>
                  <xs:choice dfdl:choiceDispatchKey="{ xs:string(./type) }">
                    <xs:element name="int" type="xs:int" dfdl:choiceBranchKey="1" maxOccurs="unbounded"
                      dfdl:occursCountKind="expression" dfdl:occursCount="{ ../count }"
                      dfdl:lengthKind="explicit" dfdl:length="1" />
                    <xs:element name="str" type="xs:string" dfdl:choiceBranchKey="2" maxOccurs="unbounded"
                      dfdl:occursCountKind="expression" dfdl:occursCount="{ ../count }"
                      dfdl:lengthKind="explicit" dfdl:length="1" />
                  </xs:choice>
                </xs:sequence>
              </xs:sequence>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

{code}

So each line has a type (either 1 for int or 2 for string) and a count, followed by count occurrances of that type.

This should parse data that looks something like this:
{code}
1512345
26abcdef
{code}

However, trying to parse this data leads to a usage exception about the mark state being messed up.

Simply removing the newVariableInstance annotation allows things to work, so somehow that is messing with state in a way that is unexpected.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)