How to allow lower and upper case and mixed combination in xsd schema

Viewed 19

This is my current XSD

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:rixmldt="http://www.rixml.org/2013/2/RIXML-datatypes" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:import namespace="http://www.rixml.org/2013/2/RIXML-datatypes" schemaLocation="RIXML-datatypes-2_4.xsd"/>
        <xs:element name="AssetClasses">
            <xs:annotation>
                <xs:documentation>Container element for one or more individual AssetClass elements..</xs:documentation>
            </xs:annotation>
            <xs:complexType>
                <xs:sequence>
                    <xs:element ref="AssetClass" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
</xs:schema>

The xml looks that we can get is below

<AssetClass assetClass="Equity"/>

I need to allow XSD validation when we get Equity in many other combinations like

<AssetClass assetClass="Equity"/>
<AssetClass assetClass="equity"/>
<AssetClass assetClass="EQUITY"/>

and in any of the above case schema validation should not fail and the value should always be Equity .

Can we do this in XSD schema ? Do we have to allow all combinations or can we use regex in schema ?

1 Answers

It's tricky to achieve in XSD 1.0, which doesn't even have case-blind regex matching in pattern facets.

In XSD 1.1 you can define a case-blind enumeration type using

<xs:assert test="upper-case($value) = ('EQUITY', 'PROPERTY', 'CASH', ...)"/>
Related