Re: Key/IDREF checking as a pattern fragment

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
that.

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:restriction>
    <xs:simpleType>
      <xs:list>
        <xs:simpleType>
          <xs:union memberTypes="xs:IDREF">
            <xs:simpleType>
              <xs:restriction base="xs:NMTOKEN">
                <xs:enumeration value="doThis" />
                <xs:enumeration value="doThat" />
                <xs:enumeration value="doSomethingElseEntirely" />
              </xs:restriction>
            </xs:simpleType>
          </xs:union>
        </xs:simpleType>
      </xs:list>
    </xs:simpleType>
    <xs:minLength value="2" />
    <xs:pattern value="(doThis|doThat|doSomethingElseEntirely) \c+ ((doThis|doThat|doSomethingElseEntirely) \c+ )*" />
  </xs:restriction>
</xs:simpleType>

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.

Untested.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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