XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
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:gkholman@CraneSoftwrights.com |
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



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS