0

I've checked this 2009 answer: xsd - validating values from external dictionary file says not but says it only applies to XSD 1.0, not 1.1.

I've followed the links in the answer and they don't help (that I can see). This Validation Layer with interdependency checks says plonking schematron on top would work but we'd really like to avoid that (yet another tech, one which I've never used either, and we're dealing with potentially large amounts of data).

We need to do stuff like 'check this value is a valid UK postcode'.

So, can XSD do "callouts" for this as it validates?

Community
  • 1
  • 1
user3779002
  • 566
  • 4
  • 17

2 Answers2

0

You don't need "callouts" for this.

In both XSD 1.0 and XSD 1.1, xsd:enumeration is a simple and common way to enforce that a value must be a member of a pre-defined set of values. Enumerations can be defined in their own file and included or imported into an XSD.

A step-up in generality is afforded by xsd:pattern regular expressions. See UK Postcode Regex (Comprehensive) if you wish to go this route. Again, both XSD 1.0 and 1.1 will work.

Community
  • 1
  • 1
kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • I've considered enumeration and seriously doubt they area realistic for millions of data items (or more - this is not just for postcodes). Postcode regex is new to me but we must validate precisely against a client's (large) extant property list. And there will be other lists too... But thanks. – user3779002 Feb 17 '15 at 10:58
0

Officially, the XPath expressions used in XSD 1.1 assertions do not allow use of the doc() function which gives access to external documents; that's because the WG wasn't keen on the idea that document validity should depend on factors other than the instance document and the schema. In practice there are probably (implementation-dependent) ways around this. Certainly with the Saxon XSD 1.1 processor, your assertions can call Java extension functions, which can do anything they like.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • "...the WG wasn't keen on the idea that..." and I understand and agree too but it's necessary here. The implementation-dependent ways of escaping are well worth looking for, though. Thanks! – user3779002 Feb 17 '15 at 11:03