checkConstraints example?

Can you please supply an example of using checkConstraints to valid an enumeration? There's not one in the spec, and none of the tutorials I have demo this. Suppose I have this DFDL: <xsd:element name="DayOfTheWeek"...> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Mon" /> <xsd:enumeration value="Tue" /> <xsd:enumeration value="Wed" /> ... </xsd:restriction> </xsd:simpleType> </xsd:element> TIA

James dfdl:checkConstraints() does not validate against a specific facet, it validates against all facets and the fixed attribute. So it checks that a simple element conforms to its simple type. It does exactly the checks that switching on validation would do, but it causes a processing error instead of a validation error when it fails, enabling the parser to backtrack. <xsd:element name="DayOfTheWeek“ minOccurs="0" …> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Mon" /> <xsd:enumeration value="Tue" /> <xsd:enumeration value="Wed" /> … </xsd:restriction> </xsd:simpleType> <xsd:annotation> <xsd:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator>dfdl:checkConstraints()</dfdl:discriminator> </xsd:appinfo> </xsd:annotation> </xsd:element> Regards Steve Hanson Architect, IBM Data Format Description Language (DFDL) Co-Chair, OGF DFDL Working Group IBM SWG, Hursley, UK smh@uk.ibm.com tel:+44-1962-815848 From: "Garriss Jr., James P." <jgarriss@mitre.org> To: "dfdl-wg@ogf.org" <dfdl-wg@ogf.org>, Date: 26/03/2013 11:39 Subject: [DFDL-WG] checkConstraints example? Sent by: dfdl-wg-bounces@ogf.org Can you please supply an example of using checkConstraints to valid an enumeration? There’s not one in the spec, and none of the tutorials I have demo this. Suppose I have this DFDL: <xsd:element name="DayOfTheWeek“…> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Mon" /> <xsd:enumeration value="Tue" /> <xsd:enumeration value="Wed" /> … </xsd:restriction> </xsd:simpleType> </xsd:element> TIA-- dfdl-wg mailing list dfdl-wg@ogf.org https://www.ogf.org/mailman/listinfo/dfdl-wg Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

We haven't implemented the recoverableError feature of assertions yet, but that combined with checkConstraints would get you a warning about constraint failure rather than a backtrack I believe. This might be useful for "spot" validation rather than validation of everything. ...mike On Tue, Mar 26, 2013 at 7:48 AM, Steve Hanson <smh@uk.ibm.com> wrote:
James
dfdl:checkConstraints() does not validate against a specific facet, it validates against all facets and the fixed attribute. So it checks that a simple element conforms to its simple type. It does exactly the checks that switching on validation would do, but it causes a processing error instead of a validation error when it fails, enabling the parser to backtrack.
<xsd:element name="DayOfTheWeek“ minOccurs="0" …> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Mon" /> <xsd:enumeration value="Tue" /> <xsd:enumeration value="Wed" /> … </xsd:restriction> </xsd:simpleType> <xsd:annotation> <xsd:appinfo source="http://www.ogf.org/dfdl/"> <dfdl:discriminator>dfdl:checkConstraints()</dfdl:discriminator> </xsd:appinfo> </xsd:annotation> </xsd:element>
Regards
Steve Hanson Architect, IBM Data Format Description Language (DFDL) Co-Chair, *OGF DFDL Working Group* <http://www.ogf.org/dfdl/> IBM SWG, Hursley, UK* **smh@uk.ibm.com* <smh@uk.ibm.com> tel:+44-1962-815848
From: "Garriss Jr., James P." <jgarriss@mitre.org> To: "dfdl-wg@ogf.org" <dfdl-wg@ogf.org>, Date: 26/03/2013 11:39 Subject: [DFDL-WG] checkConstraints example? Sent by: dfdl-wg-bounces@ogf.org ------------------------------
Can you please supply an example of using checkConstraints to valid an enumeration? There’s not one in the spec, and none of the tutorials I have demo this.
Suppose I have this DFDL:
<xsd:element name="DayOfTheWeek“…> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Mon" /> <xsd:enumeration value="Tue" /> <xsd:enumeration value="Wed" /> … </xsd:restriction> </xsd:simpleType> </xsd:element>
TIA-- dfdl-wg mailing list dfdl-wg@ogf.org https://www.ogf.org/mailman/listinfo/dfdl-wg
Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
-- dfdl-wg mailing list dfdl-wg@ogf.org https://www.ogf.org/mailman/listinfo/dfdl-wg
-- Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com

James, Taylor excerpted this from our tests. It uses checkConstraints along with an enumeration constraint. I am assured there are negative tests as well as this one. ....mike ------------------------------ *From:* Taylor Wise [twise@tresys.com] *Sent:* Tuesday, March 26, 2013 9:11 AM *To:* mbeckerle.dfdl@gmail.com *Subject:* RE: [DFDL-WG] checkConstraints example? <xs:element name=*"e"* dfdl:lengthKind=*"delimited"*> <xs:annotation> <xs:appinfo source=*"http://www.ogf.org/dfdl/dfdl-1.0/"*> <dfdl:assert test=*"{ dfdl:checkConstraints(.) }"* message=*"Assertion failed for dfdl:checkConstraints(.)"* /> </xs:appinfo> </xs:annotation> <xs:simpleType> <xs:restriction base=*"ex:stWeekend"* /> </xs:simpleType> </xs:element> <xs:simpleType name=*"stWeekend"*> <xs:restriction base=*"ex:stWeekdays"*> <xs:enumeration value=*"SATURDAY"*/> <xs:enumeration value=*"SUNDAY"*/> </xs:restriction> </xs:simpleType> <xs:simpleType name=*"stWeekdays"*> <xs:restriction base=*"xs:string"*> <xs:enumeration value=*"MONDAY"*/> <xs:enumeration value=*"TUESDAY"*/> <xs:enumeration value=*"WEDNESDAY"*/> <xs:enumeration value=*"THURSDAY"*/> <xs:enumeration value=*"FRIDAY"*/> <xs:enumeration value=*"SATURDAY"*/> <xs:enumeration value=*"SUNDAY"*/> </xs:restriction> </xs:simpleType> <!-- Test name: checkEnumeration_Pass_Subset Schema: checkConstraints Purpose: This test demonstrates the use of validation for the enumeration facet. --> <tdml:parserTestCase name=*"checkEnumeration_Pass_Subset"* root=*"e"* model=*"TestFacets"*> <tdml:document>SATURDAY</tdml:document> <tdml:infoset> <tdml:dfdlInfoset> <e>SATURDAY</e> </tdml:dfdlInfoset> </tdml:infoset> </tdml:parserTestCase> *From:* Mike Beckerle [mailto:mbeckerle.dfdl@gmail.com] *Sent:* Tuesday, March 26, 2013 9:03 AM *To:* Taylor Wise *Subject:* Fwd: [DFDL-WG] checkConstraints example? Taylor, do we have a test that calls checkConstraints to check enumeration facets? Is that even implemented yet? ...mike ---------- Forwarded message ---------- From: *Garriss Jr., James P.* <jgarriss@mitre.org<https://exchange10.columbia.tresys.com/owa/redir.aspx?C=aa8b7b062a6b46f4a9be1653e2fa9bf2&URL=mailto%3ajgarriss%40mitre.org>
Date: Tue, Mar 26, 2013 at 7:28 AM Subject: [DFDL-WG] checkConstraints example? To: "dfdl-wg@ogf.org<https://exchange10.columbia.tresys.com/owa/redir.aspx?C=aa8b7b062a6b46f4a9be1653e2fa9bf2&URL=mailto%3adfdl-wg%40ogf.org>" <dfdl-wg@ogf.org<https://exchange10.columbia.tresys.com/owa/redir.aspx?C=aa8b7b062a6b46f4a9be1653e2fa9bf2&URL=mailto%3adfdl-wg%40ogf.org>
Can you please supply an example of using checkConstraints to valid an enumeration? There’s not one in the spec, and none of the tutorials I have demo this. Suppose I have this DFDL: <xsd:element name="DayOfTheWeek“…> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Mon" /> <xsd:enumeration value="Tue" /> <xsd:enumeration value="Wed" /> … </xsd:restriction> </xsd:simpleType> </xsd:element> TIA -- dfdl-wg mailing list dfdl-wg@ogf.org<https://exchange10.columbia.tresys.com/owa/redir.aspx?C=aa8b7b062a6b46f4a9be1653e2fa9bf2&URL=mailto%3adfdl-wg%40ogf.org> https://www.ogf.org/mailman/listinfo/dfdl-wg<https://exchange10.columbia.tresys.com/owa/redir.aspx?C=aa8b7b062a6b46f4a9be1653e2fa9bf2&URL=https%3a%2f%2fwww.ogf.org%2fmailman%2flistinfo%2fdfdl-wg> -- Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | www.tresys.com<https://exchange10.columbia.tresys.com/owa/redir.aspx?C=aa8b7b062a6b46f4a9be1653e2fa9bf2&URL=http%3a%2f%2fwww.tresys.com>
participants (3)
-
Garriss Jr., James P.
-
Mike Beckerle
-
Steve Hanson