stevedlawrence opened a new pull request #153: Add a distinction between how expressions and literals are compiled URL: https://github.com/apache/incubator-daffodil/pull/153 Sometimes, we compile non-expressions just to benefit from the value conversion capabilities of DPath. For example, if a property was either "{ 1.234 }" or just "1.234", compilation would still convert it to the correct float value, regardless if there were curly braces or not. This is flexible, but can lead to unexpected behavior, specifically with the defaultValue attribute in dfdl:defineVariable. This attribute can accept either an expression or a literal value, so we use the above logic to compile the expression or literval value to an expression. But this does not always work as expected. For example, if the defineVariable type was an xs:boolean, the defaultAttribute could accept either "{ fn:false() }" or "false". Note that "false" is not a valid expression, so if we try to compile this literval value we get an error. So our current behavior of compiling literals as if they were expressions without curly braces prevents the correct use of literals in some cases. To resolve this, we need to make a clear distinction between how to handle expression and literals. With this change, a property value is now only considered an expression and compiled if it starts with an unescaped curly brace. All other values are treated as literal values, the appropriate type conversion is performed by the fromXMLString() method of the primitive type, and a ConstantExpression is created. Additionally, the DPath expression grammar is modified to be more strict and to only accept actual expressions that start and end with a curly--this should help to prevent accidental compilation of non-expressions. This change allows the use of literal values in the defaultValue attribute in a dfdl:defineVariable element and have them converted appropriately. DAFFODIL-2033
---------------------------------------------------------------- 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
