stevedlawrence commented on a change in pull request #153: Add a distinction
between how expressions and literals are compiled
URL: https://github.com/apache/incubator-daffodil/pull/153#discussion_r241127674
##########
File path:
daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/variables.tdml
##########
@@ -1061,4 +1061,67 @@
</tdml:errors>
</tdml:parserTestCase>
+
+ <tdml:defineSchema name="logical_default_values">
+
+ <xs:include
schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+ <dfdl:format ref="ex:GeneralFormat" />
+
+ <dfdl:defineVariable name="float" type="xs:float" defaultValue="-INF" />
+ <dfdl:defineVariable name="double" type="xs:double" defaultValue="1.0e-5"
/>
+ <dfdl:defineVariable name="bool" type="xs:boolean" defaultValue="false" />
Review comment:
This came up in a review on changes needed to get ISO8583 to work with
Daffodil:
https://github.com/DFDLSchemas/ISO8583/pull/2#pullrequestreview-183819263
You'll need to click "show resolved" to show the conversation about the
defaultValue="false".
Section 7.7 of the spec says that a logical value is allowed as the
defaultValue. I'm not sure the spec is clear on what is meant by a "logical
value", but Steve Hanson did state in the review that "false" should be allowed.
For this implementation, this change requires that the logical type be
parsable by PrimType.fromXMLString. In the boolean case that's just Scala's
string.toBoolean method, which means it will accept "true" or "false" ignoring
case. Note that PrimeType.fromXMLString is what we use for converting XML
Infoset strings to the internal types, so in theory this allows anything that
XSD would allow for a type. Seems like a reasonable interpretation of logical
type. So for example, for xs:hexBinary you could do ``defaultValue="DEADBEEF"``.
Regarding inputValueCalc, this change would potentially allow something like
dfd:inputValueCalc="false" to work if the type was xs:boolean, but I don't
think that's new behavior. That would have worked before this change except
that there are other checks that ensure that inputValueCalc is an actual
expression, and the above wouldn't be allowed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services