DTD vs. schema?

D

D. Alvarado

Hello,
I am sort of new to all this XML, but I would like to enforce a
date format within one of my XML elements. Everything I've read
indicates that a DTD is not suitable for this purposes, so I should
use a schema. In as far as this seems to be the only limitation of a
DTD, are there any disadvantages to using a schema? Or should I just
use a DTD and have a little extra programming to verify valid date
formats (which seems to defeat the purpose of XML)?

Thanks for any advice anyone can provide, Dave
 
A

Ashmodai

D. Alvarado scribbled something along the lines of:
Hello,
I am sort of new to all this XML, but I would like to enforce a
date format within one of my XML elements. Everything I've read
indicates that a DTD is not suitable for this purposes, so I should
use a schema. In as far as this seems to be the only limitation of a
DTD, are there any disadvantages to using a schema? Or should I just
use a DTD and have a little extra programming to verify valid date
formats (which seems to defeat the purpose of XML)?

Thanks for any advice anyone can provide, Dave

You can't use the W3C Validator any longer if you use Schema instead of
a DTD, but if your text editor can do that or you care to search for a
schema based validator, even that shouldn't be an issue.

Read a little about RELAX NG and W3C's XML Schema, then decide which
suits you most. I think there's other schemas as well, but those are the
only ones I can think of right now.
You should be able to find the XML Schema recommendation in the XML
section of the W3C website [1] and the RELAX NG spec should be somewhere
at OASIS [2].

[1] http://www.w3.org
[2] http://www.oasis-open.org
 
M

Martin Honnen

D. Alvarado said:
I am sort of new to all this XML, but I would like to enforce a
date format within one of my XML elements. Everything I've read
indicates that a DTD is not suitable for this purposes, so I should
use a schema. In as far as this seems to be the only limitation of a
DTD, are there any disadvantages to using a schema? Or should I just
use a DTD and have a little extra programming to verify valid date
formats (which seems to defeat the purpose of XML)?

If you want to use a schema you need a parser that understands schemas
and can validate against schemas and schema validation is more complex
than DTD validation. However by now there are many parsers with schema
support, look at http://xml.apache.org/ for the Xerces C++ and the
Xerces Java solution for instance, or on Windows MSXML 4 is an option.
 
G

GIMME

It's been a while since I experimented with it but ...

You can use a DTD if you opt to have the data be an attribute
instead of an element.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top