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

Josh Adams resolved DAFFODIL-2481.
----------------------------------
      Assignee:     (was: Josh Adams)
    Resolution: Fixed

This has been fixed in commit 04beffc77afb93e51098c78eaf33ca0c38956e5b

> 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
>            Priority: Major
>             Fix For: 3.1.0
>
>
> 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)

Reply via email to