Wondering in the group has looked at Schematron as a way to detect these kind of issues. It is based on simple declarative rule assertion in combination with XPath, and so it provides great expressive power.
As such problems and pathologies get detected, eventually someone writing a Daffodil Tidy stylesheet would be possible to rewrite some of the suboptimal patterns in best-practices form too. Both approaches have extended the quality assurance of XML Schema in our support for X3D, Extensible 3D graphics. all the best, Don -- Don Brutzman Naval Postgraduate School, Code USW/Br brutz...@nps.edu Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149 X3D graphics, virtual worlds, Navy robotics https://faculty.nps.edu/brutzman ________________________________ From: Steve Lawrence <slawre...@apache.org> Sent: Wednesday, February 14, 2024 12:20:32 PM To: users@daffodil.apache.org <users@daffodil.apache.org> Subject: Re: circular deadlock on NITF unparse NPS WARNING: *external sender* verify before acting. This looks like a schema bug, and there are circular deadlocks. One common way to fix this issue is to break up an outputCalc expression so that instead of calculating the length of an element, you calculate the length of its children and add them together. This makes for a more complicated expression, but often times avoids circular references. In this particular case the dfdl:outputCalc property on the DataExtensionSegmentLengths/DataLength element can be changed from this: dfdl:outputValueCalc="{ dfdl:valueLength(../../../DataExtensionSegment[dfdl:occursIndex()]/Data, 'bytes') } To this: dfdl:outputValueCalc="{ if (fn:exists(../../../DataExtensionSegment[dfdl:occursIndex()]/Data/nitf:TaggedRecordExtensions)) then dfdl:valueLength(../../../DataExtensionSegment[dfdl:occursIndex()]/Data/nitf:TaggedRecordExtensions, 'bytes') else dfdl:valueLength(../../../DataExtensionSegment[dfdl:occursIndex()]/Data/DESUserDefinedData, 'bytes') } So instead of evaluating the length of just the Data element, it is changed to get the length of the TaggedRecordExtensions element or the DESUserDefinedData element depending on which one exists (since they are in a choice). You can see we do similar things to avoid deadlocks when calculating the lengths of various HeaderLength elements in the schema. On 2024-02-14 02:33 PM, Lara Blatchford wrote: > I’m using an older version of the NITF schema from github (attached) and > can parse the attached NITF file successfully. On unparse I get the > circular deadlock error below. I’m using Daffodil 3.5.0. > > How can I determine whether this is an issue with the data itself or a > bug in Daffodil as I see other open issues regarding circular deadlocks? > > Runtime Schema Definition Error: Expressions/Unparsers are circularly > deadlocked (mutually defined): - target length for Data expr > <EvaluatableExpression eName='DataExtensionSegment/Data' expr='{ > ../../Header/DataExtensionSegmentLengths[dfdl:occursIndex()]/DataLength > }' /> - target length for DESUserDefinedData expr > <EvaluatableExpression > eName='DataExtensionSegment/Data/DESUserDefinedData' expr='{ > ../../../Header/DataExtensionSegmentLengths[dfdl:occursIndex()]/DataLength }' > /> - SuspendableExpression(DataLength, expr={ > dfdl:valueLength(../../../DataExtensionSegment[dfdl:occursIndex()]/Data, > 'bytes') }) Schema context: Data Location line 781 column 16 in nitf.dfdl.xsd > Data location was preceding byte 1074 > > Thank you! > > Lara Blatchford > > Principal Engineer > > 240-341-1421 >