You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Mike Beckerle (Jira)" <ji...@apache.org> on 2022/07/14 18:14:00 UTC

[jira] [Created] (DAFFODIL-2711) fn:count( non-array ) must issue SDE

Mike Beckerle created DAFFODIL-2711:
---------------------------------------

             Summary:  fn:count( non-array ) must issue SDE
                 Key: DAFFODIL-2711
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2711
             Project: Daffodil
          Issue Type: Improvement
          Components: Front End
    Affects Versions: 3.3.0
            Reporter: Mike Beckerle


The fn:count function, when called on a path expression that ends with a unique scalar element, should be an SDE.

Such a call can only return value 1, or cause a processing error if the element doesn't exist. Existance should be tested with fn:exists(...). 

If the schema really does have 
{code:java}
<element name="foo" minOccurs="0" .../>
<element name="bar" .../>
<element name="foo" maxOccurs="5" .../>{code}
and an expression has `fn:count(..../foo)` we already are giving an SDE about query-style expressions not being supported. 

If the schema does not have this issue (multiple declarations of same element name), then fn:count() makes no sense when called on a scalar, and it should be an SDE if the path is not for an array or optional element. 

My experience thusfar is that use of fn:count( ...) with a non-array, non-optional element path is always a mistake by the schema author.

Changing elements from array/optional to scalar is actually fairly common.

One decides rather than be an array, an element should instead contain the array as a child element, but now any fn:count(....) referring to the original array element is incorrect, as it now refers to the scalar element that contains the array as a child element. The schema compiler needs to help find these erroneous references. 

 

Personally, I think calling fn:count(...) on a non-array/non-optional should be an SDE, but

 

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)