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>
>
>

Reply via email to