- From: Costello, Roger L. <costello@mitre.org>
- Date: Sun, 9 Jan 2011 18:20:09 -0500
- To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Michael Sperberg-McQueen wrote:
> It may be worth pointing out that XSD union types are designed
> to make this kind of thing relatively easy: you can define several
> simple types, for example one for the simplest most regular values,
> another for values which are less likely (and thus more likely to
> require special handling), and at the bottom one which is (as
> Roger Costello has suggested) essentially a renamed version
> of xsd:string (or xsd:string itself).
>
> The application can then (if the XSD validator provides access to
> the appropriate information in the PSVI) dispatch the value for further
> processing to an appropriate routine or workflow suitable for a
> particular class of input.
Neat!
I think that I know how to do this, but let me reconfirm. Suppose that I create three versions of the English-language-family-name simpleType:
1. TIGHT CONSTRAINTS
<simpleType name="English-language-family-name_v1">
<restriction base="string">
<minLength value="1" />
<maxLength value="100" />
<pattern value="[a-zA-Z' \.-]+" />
</restriction>
</simpleType>
2. LOOSE CONSTRAINTS
<simpleType name="English-language-family-name_v2">
<restriction base="string" />
</simpleType>
3. MEDIUM CONSTRAINTS
<simpleType name="English-language-family-name_v3">
<restriction base="string">
<minLength value="1" />
<maxLength value="500" />
</restriction>
</simpleType>
Next, I declare Family-name to be a union of the three versions:
<element name="Family-name">
<simpleType>
<union memberTypes="fn:English-language-family-name_v1
fn:English-language-family-name_v2
fn:English-language-family-name_v3"/>
</simpleType>
</element>
Here's what an XML instance document looks like:
<Family-name>__________</Family-name>
Suppose that at data entry I want the data validated against tight constraints, i.e., English-language-family-name_v1.
How do I instruct an XML Schema validator to use that version of the simpleType?
I think that this is how to do it:
<Family-name xsi:type="fn:English-language-family-name_v1">__________</Family-name>
Is that correct?
/Roger
Received on Sunday, 9 January 2011 23:20:45 UTC