In XSD I would like to define a type Country
including a restriction which sets the list of country names that can be used.
Which can be done easily by using enumeration as a restriction.
However, this list will vary when time goes by. For example: in the past we had Yugoslavia which doesn't exist anymore; Croatia, Slovenia, etc appeared instead.
So a country will have a start date and (potentially) an end date. StartDate
and EndDate
will set the date range of existence for each particular country.
When validating an XML I would like to verify whether the XML refers to an existing country.
Therefore the XML will also contain variable ReferenceDate
which will be used to check against StartDate and EndDate.
Actually I would like to define type Country
with attributes CountryName
, StartDate
and Enddate
set.
When validating the XML with - for example - values Croatia and ReferenceDate
I would like to verify whether Croatia is a valid country at date ReferenceDate
, using type Country
being defined in the XSD.
Any ideas with the restriction given that I'm using XSD 1.0?
You could consider a framework that allows you to generate the schema appropriate to a particular date (typically by applying an XSLT transformation to some kind of meta-schema).
For example, your meta-schema could be essentially an XSD file where any element can have start-date and end-date attributes, and you could process this very easily using XSLT to retain only the elements that apply on a particular date.