IATI-Schemas icon indicating copy to clipboard operation
IATI-Schemas copied to clipboard

Why aren't codelists specified as XMLSchema enumeration restrictions?

Open jpmckinney opened this issue 5 years ago • 3 comments

I searched the repo, but haven't seen this discussed before.

I see there's a mapping file between fields and codelists, but – for complete codelists at least – wouldn't it be possible to restrict the possible values using plain XMLSchema?

For example, the EU has a currency codelist file t_currency_publicProcurement.xsd that starts as:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:cur="http://publications.europa.eu/resource/authority/currency" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://publications.europa.eu/resource/authority/currency" elementFormDefault="qualified" attributeFormDefault="unqualified" version="20171020-0">
	<xs:simpleType name="t_currency_tedschema_ted">
		<xs:restriction base="xs:string">
			<xs:enumeration value="AED">
				<xs:annotation>
					<xs:documentation>UAE dirham UAE dirhams  / adm.status[current]</xs:documentation>
				</xs:annotation>
			</xs:enumeration>
			<xs:enumeration value="AFN">
				<xs:annotation>
					<xs:documentation>Afghani  / adm.status[current]</xs:documentation>
				</xs:annotation>
			</xs:enumeration>

This is then referred to by the type attribute of xsd:attribute elements.

The XMLSchema codelist files can be auto-generated from the current IATI codelist files (to avoid breaking changes).

This would allow XMLSchema validators to work out of the box, without having to implement custom logic to understand how to validate fields that use codelists.

jpmckinney avatar May 01 '19 20:05 jpmckinney