[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
RE: [xml-dev] Use DTDs!
- From: "Costello, Roger L." <costello@mitre.org>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Mon, 2 May 2016 11:49:52 +0000
>> Dan Connolly pioneered a simple approach
>> using parameter entities, see e.g.
>>
>> https://www.w3.org/2001/XMLSchema.dtd
> And that's not cumbersome?
Compare DTDs and XSDs for this simple example:
An element, altitude, with an attribute,
units whose value is restricted to feet
or meters:
Altitude.dtd
--------------------------------------------------------
<!ELEMENT altitude (#PCDATA)>
<!ATTLIST altitude
units (feet|meters) #REQUIRED>
--------------------------------------------------------
Altitude.xsd
--------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="altitude">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="units" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="feet" />
<xs:enumeration value="meters" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
--------------------------------------------------------
DTD: 3 lines
XSD: 21 lines
DTD: easy to understand
XSD: impossible to understand without deep knowledge of XSDs
DTD: simple problem, simple solution
XSD: simple problem, difficult solution
/Roger
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]