[ 
https://issues.apache.org/jira/browse/DAFFODIL-1651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17686688#comment-17686688
 ] 

Mike McGann commented on DAFFODIL-1651:
---------------------------------------

Yes, the target type is NodeInfo.Exists. If I change it to NodeInfo.AnyType 
then I get what appears to be the correct error message:

{noformat}
Query-style paths not supported. Must have '[...]' after array-element's name. 
Offending path step: 'ex:other'.
{noformat}

There is a comment in the code there explaining the use of NodeInfo.Exists and 
it says:

{quote} 
The above specifies Exists, because we want to know a node exists, but it has 
to be a node, not a simple value. E.g., dfdl:contentLength("foobar", "bits") 
makes no sense. The first argument has to be a path to a node, otherwise we 
don't have format properties and so can't determine a content length.
      
One might argue that dfdl:contentLength("foobar", "characters") is meaningful 
and should be 6. But that's fairly pointless.
{quote}

If I change the test to take the contentLength of the literal "123" I get the 
following error:

{noformat}
java.lang.ClassCastException: class 
org.apache.daffodil.core.dpath.LiteralExpression cannot be cast to class 
org.apache.daffodil.core.dpath.PathExpression 
(org.apache.daffodil.core.dpath.LiteralExpression and 
org.apache.daffodil.core.dpath.PathExpression are in unnamed module of loader 
'app')
{noformat}

So it looks like the use of Exists was intentional but I'm not sure that I 
agree with the reasoning that taking the content length of a literal is 
meaningless but rather a valid expression that could be optimized. len("foo"), 
5 == 3 + 2, not true are all valid even though they could be written as 3, 
true, false. I'm wondering if the true bug was that len("foo") was failing and 
the quick fix was to simply prohibit that. I don't see anything in the DFDL 
specification that says the length of a literal is not allowed. 



> Unparse: dfdl:content/valueLength of an Array returns unexpected result
> -----------------------------------------------------------------------
>
>                 Key: DAFFODIL-1651
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-1651
>             Project: Daffodil
>          Issue Type: Bug
>          Components: General, Unparsing
>    Affects Versions: 2.0.0
>            Reporter: Steve Lawrence
>            Assignee: Mike McGann
>            Priority: Major
>             Fix For: 3.5.0
>
>
> When trying to get the dfdl:contentLength of dfdl:valueLength of an array, 
> Daffodil returns the length of it's parent, rather than the array. This is 
> because the NodeType.Exists parameter type ends up creating a DownArrayExists 
> recipe, which does not change the current node. Either we need to disallow 
> getting the content/valueLength of an array and require the user to wrap the 
> array in a complex type, or we need to allow it and modify/add parsers to 
> store value/contentLength of an array.
> Alternatively, we maybe be able to do some magic where we get the start pos 
> of the first child and the end pos of the last child and return that length. 
> It's not immeidately clear if that is correct.



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

Reply via email to