Here is snippet of schema:
...
<xs:element name="Parameters_Length" type="xs:int"/>
<xs:choice dfdl:choiceDispatchKey="{ Parameters_Length eq 0 }">
    <xs:element name="Parameters_Empty" dfdl:choiceBranchKey"true"
        type="xs:hexBinary" dfdl:lengthUnits="bytes" dfdl:length="{0}"
dfdl:lengthKind="explicit"/>
    <xs:element name="Parameters" dfdl:choiceBranchKey="false"
dfdl:lengthKind="explicit" dfdl:length="{ ../Parameters_Length }">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Parameter" type="parameters_record"
minOccurs="0" maxOccurs="unbounded" dfdl:occursCountKind="parsed"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:choice>
...

<xs:complexType name="parameters_record">
    <xs:sequence>
        <xs:element name="Record_Type" type="xs:short"/>
        <xs:sequence>
            <xs:annotation>
                <xs:appinfo source="http://www.ogf.org/dfdl/";>
                    <dfdl:assert message="Only record types 1, 2, & 3 are
allowed." test="{ Record_Type eq 1 or Record_Type eq 2 or Record_Type eq 3
}"/>
                </xs:appinfo>
            </xs:annotation>
         </xs:sequence>
         ...
     </xs:sequence>
</xs:complexType>

When I send bad data containing an invalid setting for Record_Type (e.g.,
5), the assert is not triggered and the xml output is produced.

The xml output looks as follows:
...
<Parameters_Length>16</Parameters_Length>
<Parameters></Parameters>

I need the assert to be triggered and error thrown.

Thanks,

Kevin







On Fri, May 31, 2019 at 7:40 AM Steve Lawrence <[email protected]> wrote:

> It's not 100% clear to me what behavior you are seeing and what you
> expect to see. Could you maybe provide a schema snippet of your complex
> and assert and what result you are looking for?
>
> - Steve
>
> On 5/30/19 3:49 PM, Kevin Moser wrote:
> > Another question related to this topic.  During testing, we noticed that
> > dfdl:asserts were not failing (sending bad data to parser) if using
> "parsed".
> > The asserts are located within the parameter complex type to check if
> valid
> > record type. Any insight?
> >
> > On Tue, May 28, 2019, 3:14 PM Kevin Moser <[email protected]
> > <mailto:[email protected]>> wrote:
> >
> >     Working on schema and am hoping to get some assistance on writing
> schema to
> >     perform an iterative process.  The protocol contains a length of
> parameters
> >     field.  It does not contain the number of parameters.  I want to
> write the
> >     schema to handle a variable number of parameters until the length of
> >     parameters field is consumed (essentially a for loop or while
> loop).  Any
> >     suggestions?
> >     Thanks, Kevin
> >
>
>

Reply via email to