Data Model WD: Appendix D

Hi,

(I seem to comment on this appendix in every draft, sorry!)

There are a couple of problems with the schema in Appendix D of the
Data Model WD.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.example.com/PartSchema"
           xmlns="http://www.example.com/PartSchema"
           elementFormDefault="qualified">
  <xs:element name="part" type="part-type"/>
  <xs:complexType name="part-type">
    <xs:sequence>
      <xs:element name="mfg" type="xs:string"/>
      <xs:element name="price" type="xs:decimal"/>
    </xs:sequence>
    <xs:attribute name="name" type="part-name"/>
  </xs:complexType>
  <xs:simpleType name="part-name">
    <xs:restriction base="xsd:string">
      <xs:pattern value="[A-Z]{2}-\d{3}-[A-Z]*"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

First, in the part-name simple type definition, the xs:restriction
element has a base attribute with the value 'xsd:string'. That should
be 'xs:string', or you should add a namespace declaration associating
the prefix 'xsd' with the XML Schema namespace.

Second, I think that the pattern for the part-name type should be:

  [A-Z]{2}-\d{3}-[a-z]*

At least, in the instance that you claim to be valid against this
schema, the part-name is "NB-401-nutbolt" which doesn't match the
pattern as currently specified.

If you make those changes it validates according to Xerces-J, and by
eye.

There are also a couple of problems in the description of the data
model generated from the instance and the schema.

First, dm:type(A1) (the type of the name attribute) should be

  xf:QName-from-uri("http://www.example.com/PartSchema",
                    "part-name")

shouldn't it? Or was the invalidity on purpose? If it was, then
surely dm:typed-value(A1) should be:

  dm:atomic-value("NB-401-nutbolt",
      xf:QName-from-uri("http://www.w3.org/2001/XMLSchema",
                        "anySimpleType"))

and dm:type(A1) should be:

  xf:QName-from-uri("http://www.w3.org/2001/XMLSchema",
                    "anySimpleType")

Second, dm:string-value(A2) (the string value of the
xsi:schemaLocation attribute) seems to have a '\' in it? I'm not sure
what that's doing there, or is it meant to indicate that there's an
insignificant line break?

Finally, in the picture, the schemaLocation attribute should probably
be called xsi:schemaLocation, since the other qualified nodes use the
prefix to indicate their namespace.

As it stands, this example is fairly straight-forward. It would be
great if this example could be turned into something that really
demonstrated some of the stickier features of the data model, such as:

  - partial validity
  - union types
  - list types
  - lists of unions
  - unions of lists
  - whitespace normalisation of values
  - the effect of xml:base
  - anonymous types
  - a schema with more than one level in the type hierarchy

I think that such an example would greatly illuminate the spec.
  
Cheers,

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

Received on Monday, 19 August 2002 18:41:55 UTC