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

Steve Lawrence resolved DAFFODIL-2041.
--------------------------------------
       Resolution: Won't Fix
    Fix Version/s: 2.3.0

[Section 23.4 DFDL Expression 
Syntax|https://daffodil.apache.org/docs/dfdl/#_Toc398030826] defines the 
grammar for DFDL expressions. In this grammar, parenthesis are required around 
the if-expression. I also found that an [Online XPath 
tester|https://www.freeformatter.com/xpath-tester.html] requires parenthesis 
around the if-expression, so this appears to be consistent with XPath and is 
not something unique to DFDL's expression syntax.

Unfortunately, the error isn't all that helpful, but is actually reasonable. 
What is actually happening is that the parser thinks you're calling a function 
call "if" which extraneous stuff after it, hence the error message contining 
"then 1 else 2". For example, if you had the expression: 

{{{ 1 + fn:floor(foo) then 1 else 2 }}}

then the error is actually pretty helpful, since 1 + fn:floor(foo) is valid, 
and the stuff after it doesn't make sense. Unfortunately this is just syntax 
parsing so we can't differentiate between fn:foor(foo) and if(foo).

Since we follow both the DFDL expression grammar and the XPath grammar and the 
error is actually reasonable, closing and marking this as Won't Fix.

> Parse error on if statements in expressions
> -------------------------------------------
>
>                 Key: DAFFODIL-2041
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2041
>             Project: Daffodil
>          Issue Type: Bug
>    Affects Versions: 2.1.0
>            Reporter: Brandon Sloane
>            Priority: Minor
>             Fix For: 2.3.0
>
>         Attachments: test.dfdl.xsd
>
>
> In complex dfdl expressions, if statements do not get processed correctly 
> without extraneus parenthesis.
> The following expressions produces an error:
>     \{ 1 + if(fn:true()) then 1 else 2 }
> [error] Schema Definition Error: Unable to parse expression. Message: `}' 
> expected but `t' found
> Next: then 1 else 2 }.
> In contrast, the following works as expected:
>     \{ 1 + (if(fn:true()) then 1 else 2) }
>  
> Attached is a basic schema demonstrating the issue.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to