W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2002

Re: Key/IDREF checking as a pattern fragment

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 29 Nov 2002 15:31:19 +0000
Message-ID: <130125914685.20021129153119@jenitennison.com>
To: xmlschema-dev@w3.org, Stuart Brown <sbrown@extenza.com>

Hi Stuart,

> I can write a xsd:restriction pattern for the attribute simple type
> as follows:
> <xsd:pattern
> value="(doThis|doThat|doSomethingElseEntirely)\(\c+\)(,(doThis|doThat|doSome
> thingElseEntirely)\(\c+\))*"/>
> which (I hope) enforces the function names, the parens, and a
> requirement that the content of the parens by characters permitted
> by xsd:NMTOKEN only, but (and I bet you saw this coming) is there
> any way that I can enforce the parens contents to be IDREFs? At the
> moment I am contemplating either leaving it with my clunky element
> sequence, or using the above pattern and providing additional
> Schematron (or sim.) validation for the key validation.

Yes, you'd have to use Schematron to validate a string structured like

What about having the structure look more like:

<implement do="doThis DEF1 doThat DEF2 doSomethingElseEntirely DEF3" />

and then defining the simple type for the do attribute as a list type:

<xs:simpleType name="actions">
          <xs:union memberTypes="xs:IDREF">
              <xs:restriction base="xs:NMTOKEN">
                <xs:enumeration value="doThis" />
                <xs:enumeration value="doThat" />
                <xs:enumeration value="doSomethingElseEntirely" />
    <xs:minLength value="2" />
    <xs:pattern value="(doThis|doThat|doSomethingElseEntirely) \c+ ((doThis|doThat|doSomethingElseEntirely) \c+ )*" />

In other words, make the do attribute hold a list of IDREFs and
function names, paired together. The pattern guarantees that the
values are arranged properly in pairs.




Jeni Tennison
Received on Friday, 29 November 2002 10:31:31 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:59 UTC