Hi
I am using dfdl assertions to implement business rules for a particular model.
This model consists of an unordered sequence of optional records, however,
1. At least one of those optional records must exist to have a valid
model;
2. A particular record type must be preceded by another specific record
type for (the former record) to be accepted.
In the latter case, I am using the exists function to determine whether
expected records are in place and the error function to raise a fault should
the conditions not be met, as shown in the DFDL schema snippet below. The
intention of this schema is that should a C_Record be found, it must be
preceded by either an X, Y or Z _Record.
In some tests I am finding that if a C_Record is preceded by an L_Record (a
cause for an error), the system outputs the L_Record to the info set and does
not raise a fault: if element C_Record's minOccurs is set to 1, the parsing
raises an error or the form
Validation Error: cvc-complex-type.2.4.a: Invalid content was found starting
with element '{"tc":L_Record}'. One of '{"tc":X_Record, "tc":C_Record}' is
expected.
What is the expected behaviour in such situations? or perhaps someone can point
me in the right direction to help me achieve a schema that describes this type
of model?
I am using Daffodil 2.5.0 public release.
<xs:element dfdl:lengthKind="implicit" name="T_Records" minOccurs="1">
<xs:complexType>
<xs:sequence dfdl:sequenceKind="unordered">
<xs:element ref="X_Record" minOccurs="0"
dfdl:occursCountKind="parsed" />
<xs:element ref="C_Record" minOccurs="0"
dfdl:occursCountKind="parsed">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:assert message="Unexpected record found: must be
preceded by X_Record, Y_Record or Z_Record." testKind='expression'>
{
if (fn:exists(../X_Record) or
fn:exists(../Y_Record) or
fn:exists(../Z_Record)) then
fn:true()
else
fn:error()
}
</dfdl:assert>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element ref="Y_Record" minOccurs="0"
dfdl:occursCountKind="parsed" />
<xs:element ref="Z_Record" minOccurs="0"
dfdl:occursCountKind="parsed" />
<xs:element ref="L_Record" minOccurs="0"
dfdl:occursCountKind="parsed" />
<xs:element dfdl:lengthKind="implicit" name="S_Records"
minOccurs="0" dfdl:occursCountKind="parsed">
<xs:complexType>
<xs:sequence>
<xs:element ref="S_Record" minOccurs="1"
maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:assert message='Unexpected record
found: must be preceded by C_Record.' testKind='expression'>
{
if (fn:exists(../../C_Record)) then
fn:true()
else
fn:error()
}
</dfdl:assert>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Peter
This e-mail and any attachment is intended for the party to which it is
addressed and may contain confidential information or be subject to
professional privilege. Its transmission in not intended to place the contents
into the public domain. If you have received this e-mail in error, please
notify us immediately and delete the email and all copies. AWTA Ltd does not
warrant that this e-mail is virus or error free. By opening this e-mail and any
attachment the user assumes all responsibility for any loss or damage resulting
from such action, whether or not caused by the negligence of AWTA Ltd. The
contents of this e-mail and any attachments are subject to copyright and may
not be reproduced, adapted or transmitted without the prior written permission
of the copyright owner.