
This is most easily done by computing two physical fields that just grab the strings, then two logical fields, which standardize those strings to lower case (or upper if you prefer), then an assert with a big case analysis that passes for valid pairings, and fails for invalid pairings. Because DFDL expressions are based on XPath, there is only nested if-then-else available to do this, but that said, at least it is straightforward what you need to create: <dfdl:assert message="Illegal type and subtype pair."> { if (../Type eq 'text') then if (../Subtype eq 'html') then true else if (../Subtype eq 'plain') then true else false else if (../Type eq 'application') then if (../Subtype eq 'pdf') then true else false else false } </dfdl:assert> I believe we need the fn:error function (not currently in DFDL spec, but has been discussed), so that you can get a reasonable diagnostic message from this rather than just "Assertion failed: illegal type and subtype pair.", but something that actually mentions what the type and subtype values were. On Thu, Jun 20, 2013 at 11:33 AM, Garriss Jr., James P. <jgarriss@mitre.org>wrote:
Content types come in pairs. So while the type can be “text” and the subtype can be “pdf”, the complete content type cannot be “text/pdf”. It can, however, be “text/html” or “application/pdf”.****
** **
So in my DFDL it’s not sufficient to specify enumerated lists for types and subtypes (as I have done below), I must also specify which types are allowed to go with which subtypes.****
** **
How would I do that, given this complexType? TIA!****
** **
<xsd:complexType name="MimeTypeType"> <xsd:sequence dfdl:separator="/"> <xsd:element name="Type" dfdl:initiator=""> <xsd:annotation> <xsd:appinfo source="http://www.ogf.org/dfdl/dfdl-1.0/ "> <dfdl:assert test="{ dfdl:checkConstraints(.) }"message ="The type must match one of the values on the enumerated list."/> </xsd:appinfo> </xsd:annotation> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value= "([a|A][p|P][p|P][l|L][i|I][c|C][a|A][t|T][i|I][o|O][n|N])|
([m|M][u|U][l|L][t|T][i|I][p|P][a|A][r|R][t|T])| ([m|M][e|E][s|S][s|S][a|A][g|G][e|E])| ([t|T][e|E][x|X][t|T])" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="Subtype" dfdl:terminator=""> <xsd:annotation> <xsd:appinfo source="http://www.ogf.org/dfdl/dfdl-1.0/ "> <dfdl:assert test="{ dfdl:checkConstraints(.) }"message ="The subtype must match one of the values on the enumerated list."/> </xsd:appinfo> </xsd:annotation> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="([p|P][d|D][f|F])|
([a|A][l|L][t|T][e|E][r|R][n|N][a|A][t|T][i|I][v|V][e|E])| ([m|M][i|I][x|X][e|E][d|D])| ([r|R][f|F][c|C]822)| ([p|P][l|L][a|A][i|I][n|N])| ([h|H][t|T][m|M][l|L])" /> </xsd:restriction> </xsd:simpleType> </xsd:element> </xsd:sequence> </xsd:complexType>****
** **
** **
-- 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