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

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

I created a test with the following schema:

{code:xml}
<tdml:defineSchema name="contentLengthArray">
  <xs:include 
schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
  <dfdl:format ref="ex:GeneralFormat"/>

  <xs:element name="line">
    <xs:complexType>
      <xs:sequence dfdl:separator="%WSP;">
        <xs:element name="first" type="xs:string" dfdl:lengthKind="delimited"/>
        <xs:element name="other" type="xs:string" dfdl:lengthKind="delimited" 
maxOccurs="unbounded"/>
        <xs:element name="len" type="xs:unsignedInt" 
dfdl:inputValueCalc='{dfdl:contentLength(../ex:other, "bytes")}'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</tdml:defineSchema>
{code}

when I create a parser test, I do get an error but its text is a little 
confusing but makes sense given the explanation in this ticket's description:

{code}
Expression Evaluation Error: Content length unknown for element 'ex:line'
{code}

So, it looks like an error is properly raised for parsing even though the 
message might be slightly inaccurate. I looked to see if I could improve that 
message but it looks like at evaluation time there is no reference to "other" 
and only "line". The recipe has that information but that is not available 
after the argument has been evaluated for calculation. 

For unparsing, I used the same schema but replaced inputvalueCalc with 
outputValueCalc and used this infoset:

{code:xml}
<tdml:infoset>
  <tdml:dfdlInfoset>
    <ex:line>
      <ex:first>one</ex:first>
      <ex:other>two</ex:other>
      <ex:other>three</ex:other>
    </ex:line>
  </tdml:dfdlInfoset>
</tdml:infoset>
{code}

When I run that test, I get this error:

{code:xml}
Expressions/Unparsers are circularly deadlocked (mutually defined)
{code}

I'm not sure if that is the expected result or not. If I change contentLength 
to use ex:first instead of ex:other, then I get no error. 






> 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