DTD or schemas

David (60)

Usenet Archive
Joined
Aug 13, 2003
Messages
7
Reaction score
0
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!
 

Bob Foster

Usenet Archive
Joined
Aug 14, 2002
Messages
220
Reaction score
0
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
 

Bob Foster

Usenet Archive
Joined
Aug 14, 2002
Messages
220
Reaction score
0
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
 

Tad McClellan

Usenet Archive
Joined
Jan 11, 2000
Messages
5,652
Reaction score
0
Bob Foster wrote:
"Tad McClellan" wrote:

> David wrote:
>
> > Subject: DTD or schemas
>
> > what the difference
> > between the two?
>
>
> One is optimized for humans and one is optimized for machines.

...

Depends on which of the "kinds" of humans you are speaking of. :)

Of the 3 "usual suspects" for people doing XML:

documents
databases
world wide web

I'm the "document" kind.

(and that will color all that follows below.)

My data is not orderly, like columns and rows, with perhaps values in some columns matching with values in some other set of columns and rows.

My data is not dynamic or "on demand", where the processing is central to production. I do "batch" type conversion jobs.

The structures I work with are complex and largish (ie. lots of elements, not necessarily large instances).

The hard part of the type of jobs I've worked on is
understanding the document's model, rather than the subsequent processing.

DTD's are much easier for humans, and being the human, I choose DTDs over schemas, let the machines fend for themselves. :)

Schemas are like assembly language, eventually we won't see them, just manipulate them indirectly through tools. We'll direct the machines on how to carry out the grunt work for us.

By "schema" I mean W3C schemas, RelaxNG is much nicer.
 

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
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top