[DFDL-WG] How to ignore case and validate an element with an enumerated list

Garriss Jr., James P. jgarriss at mitre.org
Thu Jun 20 14:17:14 EDT 2013


Mike came up with a solid solution to the problem I posted previously.  While not quite as elegant as adding the "dfdl:ignoreElementCase=yes" property that I would prefer, it's good enough.  Thanks, Mike!

Here's the relevant parts:

    <xsd:complexType name="MimeTypeType">
        <xsd:sequence>
            <xsd:sequence dfdl:hiddenGroupRef="MixedCaseMimeTypeGroup"/>
            <!-- logical representation of the type and subtype, where xPath is used to convert all the characters to lower case -->
            <xsd:element name="Type" dfdl:inputValueCalc="{ fn:lower-case(../MixedCaseType) }">
                <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:enumeration value="application"/>
                        <xsd:enumeration value="multipart"/>
                        <xsd:enumeration value="message"/>
                        <xsd:enumeration value="text"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="Subtype" dfdl:inputValueCalc="{ fn:lower-case(../MixedCaseSubtype) }">
                <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:enumeration value="pdf"/>
                        <xsd:enumeration value="ms-tnef"/> <!-- outlook -->
                        <xsd:enumeration value="alternative"/>
                        <xsd:enumeration value="mixed"/>
                        <xsd:enumeration value="rfc822"/>
                        <xsd:enumeration value="plain"/>
                        <xsd:enumeration value="html"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

    <!-- physical representation of the type and subtype, which can contain upper and lowercase characters -->
    <xsd:group name="MixedCaseMimeTypeGroup">
        <xsd:sequence dfdl:separator="/">
            <xsd:element name="MixedCaseType" type="xsd:string"/>
            <xsd:element name="MixedCaseSubtype" type="xsd:string"/>
        </xsd:sequence>
    </xsd:group>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20130620/bc5cde19/attachment-0001.html>


More information about the dfdl-wg mailing list