Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DAFFODIL-2352

dfdl:newVariableInstance with non-constant defaultValue fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.6.0
    • 3.1.0
    • Back End
    • None

    Description

      If we have a schema with newVariableInstance that uses a non-constant DFDL expression for the default value, that default value is never set. For example:

      Unable to find source-code formatter for language: xsd. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:newVariableInstance ref="foo" defaultValue="{ /some/non/constant/thing }" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name="fooValue" type="xs:int" dfdl:inputValueCalc="{ $foo }" />            </xs:sequence>
      

      When the inputValueCalc expressoin is evaluated, we fail with the error

      Runtime Schema Definition Error: Variable Error: Variable map (runtime): variable foo has no value. It was not set, and has no default value.
      

      According to the spec:

      If a default value is specified this initial value of the instance will be set when the instance is created
      

      So we are likely just missing the logic to evaluate and set the default when when we create the new VariableInstacne.

      This might also affect dfdl:defineVariable as well, which is allowed to also have expressions as the defaultValue, as long as the expression doesn't reference the infoset and only other variables.

      Attachments

        Activity

          People

            Unassigned Unassigned
            slawrence Steve Lawrence
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: