views:

81

answers:

1

I would like to define a schema for a document like:

...
<car>
  <make>ford</make>
  <model>mondeo</model>
</car>
...

the problem is that I would like to constraint possible values (so ford/mondeo or audi/a4 would be valid values for make/model, but audi/mondeo would not) from external data dictionary. In case when new car models needs to be added only external data file would change, but xsd schema would remain the same.

Is this possible at all? I have looked at key/keyref constraint, I see I can use them within a single document, but this is not I'm looking for. I don't want to repeat full data dictionary with every document instance, I would prefer to have the data file rather constitute part of the schema.

+1  A: 

That is not possible in XML Schema 1.0.

XML Schema 1.1 will add some support that will allow expressing this kind of constraints (although AFAIK not in external files) - but that is not yet a W3C recommendation.

It is possible to implement this now with Schematron, eventually embedded in XML Schema.

However, there was already work in this area with usable results. See OASIS Code Lists

http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=codelist

More details can be found here:

http://www.genericode.org/

This is used in the OASIS Universal Business Language (UBL) http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=ubl

Best Regards, George

George Bina