I think this is a bug in Daffodil. I think what you have should work. I've created DAFFODIL-2648 to track this issue and provide a more minimal example that reproduces the issue.

  https://issues.apache.org/jira/browse/DAFFODIL-2648

Unfortunately, I can't come up with a workaround, without perhaps changing how terminators are described in your schema. We'd probably need more information about your format to know what might work.


On 2/4/22 7:15 PM, Thompson, Mark M [US] (DS) wrote:
Newby alert:

I am attempting to define a terminator string for one element based on the
existence/non--existence of a prior element.

- When the element exists, I get what I want.

- When the element does not exist, I get the following from Daffodil during 
unparse:

[error] Unparse Error: Expression Evaluation Error: Child element
legacy:FmtLine12-BodyLineNoEOL does not exist.

Prior element example (with BodyLineNoEOLelement):

    <legacy:FmtLine7-12>

                 <legacy:FL11_BT>BT</legacy:FL11_BT>

                 <legacy:FmtLine12-ClassLine>C O N F I D E N T I A
L</legacy:FmtLine12-ClassLine>

                 <legacy:FmtLine12-DelimiterLine>

                    <legacy:FL12SubjLine>SUBJ: TEST MSG - FL11/FL13
BT</legacy:FL12SubjLine>

                </legacy:FmtLine12-DelimiterLine>

                 <legacy:FmtLine12-BodyLine>Just some random
junk.</legacy:FmtLine12-BodyLine>

                <legacy:FmtLine12-BodyLine>More 
stuff.</legacy:FmtLine12-BodyLine>

                <legacy:FmtLine12-BodyLine>That's all
folks.</legacy:FmtLine12-BodyLine>

<legacy:FmtLine12-BodyLineNoEOL xsi:nil="true"></legacy:FmtLine12-BodyLineNoEOL>

    </legacy:FmtLine7-12>

    <legacy:FL12_LastEOL></legacy:FL12_LastEOL>

Schema definition for FL12_LastEOL

<xs:elementname="FL12_LastEOL"type="xs:string"minOccurs="0"maxOccurs="1"

dfdl:terminator="{if
(fn:exists(../legacy:FmtLine7-12/legacy:FmtLine12-BodyLineNoEOL)) then '%ES;'
else '%LF; %CR;%CR;%LF; %CR;%LF; %ES;'}"

dfdl:lengthKind="pattern"dfdl:lengthPattern="(\n);"/>

                My expectation is that when BodyLineNoEOL does not exist, the
terminator will use the else string.

                What am I missing?

Thank you for your time,

    Mark T

-----Original Message-----
From: Roger L Costello <[email protected]>
Sent: Thursday, February 3, 2022 4:46 AM
To: [email protected]
Subject: EXT :Writing DFDL schemas for processing data from Europe? Better know
how to express monetary values

USA uses the $ symbol. Finland uses EUR.

USA places the $ symbol before the number. Finland places EUR after the number.

USA doesn't use a space between the $ symbol and the number. Finland uses a
space between the number and EUR.

USA uses the decimal point symbol. Finland uses the comma symbol.

USA separates groups of three digits using a comma. Finland uses a space.

Example:

USA                     Finland

$7,593.86           7 593,86 EUR

For negative quantities, USA puts a dash symbol immediately before the $ symbol.
Finland uses a dash then space.

Example:

USA                     Finland

-$7,593.86          - 7 593,86

For international monetary values, USA precedes the number with USD and space
(omits the $ symbol). Finland makes no change.

Example:

USA                     Finland

USD 7,593.86     7 593,86 EUR

For negative international monetary values, USA precedes USA with a dash symbol
(no space after the dash symbol). Finland makes no change.

Example:

USA                     Finland

-USD 7,593.86   - 7 593,86 EUR


Reply via email to