Yes that looks good. It will only parse
the data though. Do you need to unparse? To unparse you will need dfdl:outputValueCalc="{../Type}"
on MixedCaseType, and dfdl:outputValueCalc="{../Subtype}" on
MixedCaseSubtype.
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:
20/06/2013 19:19
Subject:
[DFDL-WG] How
to ignore case and validate an element with an enumerated
list
Sent by:
dfdl-wg-bounces@ogf.org
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>--
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