DTD or schemas

D

David

Sorry this might sound like a dumb question but what the difference
between the two? Are they just two different ways of doing the same
thing?

I mean are the following two equilavent?

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Day">
<xs:complexType>
<xs:sequence>
<xs:element name="Bodypart" type="xs:string"/>
<xs:element name="Excercise" type="xs:string"/>
<xs:element name="Sets"type="xs:positiveInteger"/>
<xs:element name="Reps" type="xs:positiveInteger"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>



<!DOCTYPE training [
<!ELEMENT training (bodypart, excercise, sets, reps)>
<!ELEMENT bodypart (#PCDATA)>
<!ELEMENT excercise (#PCDATA)>
<!ELEMENT sets (#PCDATA)>
<!ELEMENT reps (#PCDATA)>
]>

cheers!
 
B

Bob Foster

No, they are two different ways of doing similiar things. Any document you
can describe with a DTD can also be described with an XML Schema. The
converse is not true. Just to scratch the surface, XML Schema adds
namespaces, a limited form of interleave, type-specific uniqueness and key
constraints and a plethora of simple datatypes more specific than CDATA or
(#PCDATA).

If you really want to learn about XML Schema, I recommend Priscilla
Walmsley's book, Definitive XML Schema. It's the best.

Bob
 
B

Bob Foster

Tad McClellan said:
One is optimized for humans and one is optimized for machines.

That's an interesting point of view. Which one do you think is optimized for
humans? ;-}

Bob Foster
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top