I don't agree that patterns and separator suppression *should* interact this way.
But I am not sure what is going on here without seeing a trace. You're trying to parse A/C and get infoset with just A and C in it. B should not be present in the data nor the infoset. It seems that when parsing element B, it should parse the separator, then for the element it would get a pattern length of 0, construct the element, but then the assert should fail, preventing a B from being added to the array, but as minOccurs=0, that's ok. There will be no B elements. The backtracking should remove the separator as well. Then it should parse a separator and then C. My rough mental exercise of how the parse should work does not see an error here, but I would need to see the trace to tell what is going wrong. Possibly a bug. If Daffodil is committing to the element B being added to the array before the assert is evaluated that would explain the behavior, but that would just be a bug plain and simple. On Fri, Feb 4, 2022 at 12:23 PM Roger L Costello <[email protected]> wrote: > 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 <[email protected]> > *Sent:* Friday, February 4, 2022 12:04 PM > *To:* [email protected] > *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 <[email protected]> > 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> > >
