tuxji commented on code in PR #1137:
URL: https://github.com/apache/daffodil/pull/1137#discussion_r1465359110


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala:
##########
@@ -2329,6 +2342,11 @@ abstract class FunctionCallBase(
   protected def checkArgArrayOrOptional(): Unit = {
     lazy val isArrayOrOptional = expressions.head match {
       case pe: PathExpression => pe.isPathToOneWholeArrayOrOptional
+      case ie: IfExpression => {
+        val tp = ie.thenPart
+        val ep = ie.elsePart
+        tp.isPathToOneWholeArrayOrOptional || 
ep.isPathToOneWholeArrayOrOptional

Review Comment:
   I like the simplicity of allowing only a path as fn:count's argument.  I 
checked the DFDL specification and it was not very clear whether we must allow 
any DFDL expression to be given to fn:count as argument:
   
   | Function | Meaning |
   |--------|--------|
   | fn:count($arg) | Returns the number of items in the value of $arg as an 
xs:integer. Returns 0 if $arg is the empty sequence. |
   
   The following are Schema Definition Errors, regardless of whether they are 
detected in advance of processing or once processing begins:
   
     -   Expression value is not single node
       -  Most DFDL expression contexts require an expression to identify a 
single node, not an array (aka sequence of nodes). There are a few exceptions 
such as the fn:count(…) function, where the path expression must be to an array 
or optional element.
     -   Expression value is not array element or optional element.
       -  Some DFDL expression contexts require an array or an optional element.
       -  Example: The fn:count(...) function argument must be to an array or 
optional element. It is a Schema Definition Error if the argument expression is 
otherwise.
   
   Mike, please advise us with your deeper knowledge of DPath and XPath.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to