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 2021/03/11 14:34:00 UTC
[jira] [Created] (DAFFODIL-2481) newVariableInstance does not use
external values when defaultValue is not defined
Steve Lawrence created DAFFODIL-2481:
----------------------------------------
Summary: newVariableInstance does not use external values when defaultValue is not defined
Key: DAFFODIL-2481
URL: https://issues.apache.org/jira/browse/DAFFODIL-2481
Project: Daffodil
Issue Type: Bug
Affects Versions: 3.0.0
Reporter: Steve Lawrence
Regarding newVariableInstance and defaultValue, the spec says:
{quote}
If the instance is not assigned a new default value then it inherits the default value specified by dfdl:defineVariable or externally provided by the DFDL processor.
{quote}
Daffodil does not support the "or externally provided" part of this. If NVI does not provide a defaultValue, then we always use the defaultValue specified by the defineVariable, regardless if it was set externally.
For example, say we have this schema:
{code:xml}
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format ref="ex:GeneralFormat" />
<dfdl:defineVariable name="var1" type="xs:int" defaultValue="1" external="true" />
</xs:appinfo>
</xs:annotation>
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="beforeNVI" type="xs:int" dfdl:inputValueCalc="{ $ex:var1 }" />
<xs:sequence>
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:newVariableInstance ref="ex:var1" />
</xs:appinfo>
</xs:annotation>
<xs:element name="afterNVI" type="xs:int" dfdl:inputValueCalc="{ $ex:var1 }" />
</xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
{code}
So the "var1" variable defaults to "1", and newVariableInstance does not provide a default value.
If we run the following to parse with an externally set value of 2:
{code}
daffodil parse -Dvar1=2 ...
{code}
Then we get the resulitng infoset:
{code:xml}
<root>
<beforeNVI>2</beforeNVI>
<afterNVI>1</afterNVI>
</root>
{code}
Which isn't correct. Because var1 was set externally to 2, the NVI should use that value as the default, so both beforeNVI and afterNVI should have a value of 2.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)