Adding to the story …

I changed the type for the A, B, and C elements to xs:string:

   <xs:element name="test">
        <xs:complexType>
            <xs:sequence dfdl:separator="/" dfdl:separatorPosition="infix"
                             dfdl:separatorSuppressionPolicy="anyEmpty">
                <xs:element name="A" type="xs:string" dfdl:lengthKind="pattern"
                                             dfdl:lengthPattern="A"/>
                <xs:element name="B" minOccurs="0" 
dfdl:occursCountKind="implicit"
                                             type="xs:string"
                                             dfdl:lengthKind="pattern"
                                             dfdl:lengthPattern="B"/>
                <xs:element name="C" type="xs:string" dfdl:lengthKind="pattern"
                                             dfdl:lengthPattern="C"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

With this input:

A/C

I get this error:

Parse Error: Separator '/' not found

I conclude that:


  1.  anyEmpty does not work.
  2.  There is an illogical dependency in the DFDL language between 
lengthPattern and separatorSuppressionPolicy="anyEmpty"

Do you agree?

/Roger
From: Roger L Costello <coste...@mitre.org>
Sent: Friday, February 4, 2022 12:31 PM
To: users@daffodil.apache.org; mbecke...@apache.org
Subject: RE: Doesn't separatorSuppressionPolicy=trailingEmpty mean the input 
can suppress (omit) separators?

Let me elaborate on my last email.

If I use lengthPattern and don’t specify <dfdl:assert test="{ . ne '' }"/> then 
the schema will erroneously accept this input:

A//C

If I do use lengthPattern and do specify <dfdl:assert test="{ . ne '' }"/> then 
the DFDL does not allow me to have this input:

A/C

There is (in my view) an illogical dependency in the DFDL language between 
lengthPattern and separatorSuppressionPolicy="anyEmpty"

Do you agree?

/Roger

From: Roger L Costello <coste...@mitre.org<mailto:coste...@mitre.org>>
Sent: Friday, February 4, 2022 12:23 PM
To: users@daffodil.apache.org<mailto:users@daffodil.apache.org>; 
mbecke...@apache.org<mailto:mbecke...@apache.org>
Subject: Re: Doesn't separatorSuppressionPolicy=trailingEmpty mean the input 
can suppress (omit) separators?

Thanks Mike. I changed my schema to separatorSuppressionPolicy="anyEmpty" and 
now I get this error:

Parse Error: Assertion failed: { . ne '' } failed

It appears that if a schema uses lengthPattern, then the schema cannot use 
separatorSuppressionPolicy="anyEmpty". Do agree?

/Roger

From: Mike Beckerle <mbecke...@apache.org<mailto:mbecke...@apache.org>>
Sent: Friday, February 4, 2022 12:04 PM
To: users@daffodil.apache.org<mailto:users@daffodil.apache.org>
Subject: [EXT] Re: Doesn't separatorSuppressionPolicy=trailingEmpty mean the 
input can suppress (omit) separators?

That B middle element is not "trailing". Element C, after it, is required, so B 
can never be trailing.

You want separatorSuppressionPolicy='anyEmpty' which means any empty element 
wherever it is located is suppressed. Note that this very often goes with 
non-positional formats, i.e., formats that have initiators so that whether an 
element is B or C can be distinguished by looking at the data stream.

With trailing suppression of separators, you can use position, i.e., can 
determine which element declaration applies by counting the separators. With 
'anyEmpty' suppression of separators, counting isn't sufficient any more.

On Fri, Feb 4, 2022 at 11:55 AM Roger L Costello 
<coste...@mitre.org<mailto:coste...@mitre.org>> wrote:
Hi Folks,

My input consists of 3 data items separated by slash, e.g.,

A/B/C

The middle data item is optional.

If there is no data for the middle data item, I want the separator suppressed 
(omitted), so I use separatorSuppressionPolicy="trailingEmpty". I expect this 
to be the appropriate input:

A/C

Is that correct?

When I run my DFDL schema I get this error:

        Parse Error: Separator '/' not found

When I use this input:

A//C

There is no error.

I'm confused. I thought separatorSuppressionPolicy="trailingEmpty" means that I 
can suppress (omit) the separator when there is no data available. What am I 
failing to understand?  Below is my DFDL schema.  /Roger

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
    <xs:annotation>
        <xs:appinfo source="http://www.ogf.org/dfdl/";>
            <dfdl:format textBidi="no" floating="no" 
encodingErrorPolicy="replace" outputNewLine="%CR;%LF;" leadingSkip="0" 
trailingSkip="0" alignment="1" alignmentUnits="bytes" textPadKind="none" 
textTrimKind="none" truncateSpecifiedLengthString="no" escapeSchemeRef=""
                representation="text" encoding="ASCII" lengthKind="delimited" 
initiator="" terminator="" ignoreCase="yes" sequenceKind="ordered" separator="" 
initiatedContent="no" emptyValueDelimiterPolicy="none" fillByte="%SP;" 
textNumberRep="standard" textStandardBase="10"
                textStandardZeroRep="0" textNumberRounding="pattern" 
textStandardExponentRep="E" textNumberCheckPolicy="strict" 
lengthUnits="characters" nilKind="literalValue" nilValue="-" 
nilValueDelimiterPolicy="none" 
separatorSuppressionPolicy="trailingEmptyStrict"/>
        </xs:appinfo>
    </xs:annotation>
    <xs:element name="test">
        <xs:complexType>
            <xs:sequence dfdl:separator="/" dfdl:separatorPosition="infix"
                        dfdl:separatorSuppressionPolicy="trailingEmpty">
                <xs:element name="A" type="non-zero-length-string" 
dfdl:lengthPattern="A"/>
                <xs:element name="B" minOccurs="0"
                dfdl:occursCountKind="implicit"
                type="non-zero-length-string"
                dfdl:lengthPattern="B"/>
                <xs:element name="C" type="non-zero-length-string" 
dfdl:lengthPattern="C"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="non-zero-length-string" dfdl:lengthKind="pattern">
        <xs:annotation>
            <xs:appinfo source="http://www.ogf.org/dfdl/";>
                <dfdl:assert test="{ . ne '' }"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string"/>
    </xs:simpleType>
</xs:schema>

Reply via email to