RE: [xml-dev] Use DTDs!

From
G. Ken Holman <>
To
"Costello, Roger L." <>, "" <>
Date
2016-05-02T13:42:12Z
ID
<>
Thread
RE: [xml-dev] Use DTDs!
In ISO/IEC 19757-2 RELAX-NG Compact Syntax:

element altitude { attribute units { 'feet' | 'meters' }, text }

At 2016-05-02 11:49 +0000, Costello, Roger L. wrote:
>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


--
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Streaming hands-on XSLT/XPath 2 training @US$45: http://goo.gl/Dd9qBK |
Crane Softwrights Ltd. _ _ _ _ _ _ http://www.CraneSoftwrights.com/x/ |
G Ken Holman _ _ _ _ _ _ _ _ _ _ mailto: |
Google+ blog _ _ _ _ _ http://plus.google.com/+GKenHolman-Crane/posts |
Legal business disclaimers: _ _ http://www.CraneSoftwrights.com/legal |


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus