- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Mon, 3 Dec 2001 22:32:22 +0000
- To: Stanley Guan <Stanley.Guan@oracle.com>
- CC: Schema XML <xmlschema-dev@w3.org>, Joerg.Rieger@informatik.med.uni-giessen.de
Hi Stanley,
> Look at d2d2xs translated result. Isn't it better to translate
> <!ATTLIST patient
> pat_id CDATA #REQUIRED
> kennung (intern|extern|beides) #REQUIRED
> hausarzt IDREF #IMPLIED>
> to:
>
> <xs:attribute name="kennung" use="required">
> <xs:simpleType>
> <xs:restriction base="xs:NMTOKEN">
> <xs:enumeration value="intern" />
> <xs:enumeration value="extern" />
> <xs:enumeration value="beides" />
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
>
> instead of:
>
> <xs:attribute name="kennung" use="required">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration value="intern" />
> <xs:enumeration value="extern" />
> <xs:enumeration value="beides" />
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> because
> Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
Yes, using xs:NMTOKEN is better, although I think it could equally be
derived from xs:token - the only thing that xs:NMTOKEN gives you over
xs:string (aside from checking that the enumerated values are legal
NMTOKENs, and I assume you're assuming a valid DTD) is the
normalization of whitespace in attribute values, such that:
kennung=" intern "
would be a valid attribute value, whereas it isn't if it's derived
from xs:string (unless you explicitly set the whiteSpace facet to
collapse).
There's another tool at http://www.w3.org/2000/04/schema_hack/, which
has some useful examples of the conversions that it makes, although it
looks like it's based on an older version of XML Schema. I believe
that many XML editors have DTD to XML Schema converters built in (as
part of their support for XML Schema), try XML Spy for example.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
Received on Monday, 3 December 2001 17:32:25 UTC