RE: XML DTD for the package configuration file

As I understand it, XML Schema are the successor for DTDs. My guess is that we should use a Schema unless there's a good reason to use a DTD. Here's a snip from http://www.w3schools.com/schema/schema_intro.asp but I'm sure there are better sources of information: XML Schemas are the Successors of DTDs We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons: XML Schemas are extensible to future additions XML Schemas are richer and more useful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces Simon | -----Original Message----- | From: libraries-bounces@haskell.org [mailto:libraries-bounces@haskell.org] On Behalf Of Isaac Jones | Sent: 15 October 2003 05:55 | To: libraries | Subject: XML DTD for the package configuration file | | This is my first attempt at an XML DTD. Does anyone have any | suggestions for good XML references either a book or a web site? | Google seems to be suffering from too much XML information. Is there | a Haddock / Javadoc type way to notate a DTD? Should I be using | schemas? Are they overkill? What do you think of the style? | Sometimes I have trouble choosing between using an attribute, and | using a nested element. For instance:

"Simon Peyton-Jones"
XML Schemas are extensible to future additions XML Schemas are richer and more useful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces
Like XML in general, they also tend to be verbose and noisy, and difficult to read for a human. So if you want my opinion, I don't like them much, but then I don't like many of the directions XML is moving anyway. I'll accept it as a lost battle, and move on. :-) -kzm -- If I haven't seen further, it is by standing in the footprints of giants

At 13:27 15/10/03 +0200, ketil+haskell@ii.uib.no wrote:
XML Schemas are extensible to future additions XML Schemas are richer and more useful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces
Like XML in general, they also tend to be verbose and noisy, and difficult to read for a human. So if you want my opinion, I don't like them much, but then I don't like many of the directions XML is moving anyway. I'll accept it as a lost battle, and move on. :-)
FWIW, the complexity of XML schema did attract some considerable flack within W3C a couple of years ago. Some leading XML activists were openly critical about the complexity of XML schema, coupled with the fact that it doesn't handle *everything* that one can do with DTDs. That said, XML schema *is* a full W3C recommendation, and it is being widely used. Both DTDs and XML schema are commonly used still. There is another specification, which has now ended being consensualized (not quite "standardized") by OASIS, called Relax NG [http://www.relaxng.org/]. This is regarded by many as being technically superior, but I don't see it getting much attention outside the technical community. I think the main problem here is that XML is not really a human-readable language for highly structured information like a grammar description. Now, if we could come up with a surface syntax for XML Schema that also happens to be valid and executable Haskell, I think that would be interesting. I was very taken when I wrote a URI parser a while back how closely the Haskell source code reflected the specification from which I was working; I find similar benefits using Parsec to write a Notation 3 parser. And does such code need to be used just for parsing? Could a Haskell-ized version of XML schema together with an appropriate function library be used to perform all kinds of XML schema processing? For example the same source code used as a validator, OR to generate an XML schema file for use by other tools (OR a DTD, OR Relax NG, ...) #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact

On Wed, Oct 15, 2003 at 11:35:41AM +0100, Simon Peyton-Jones wrote:
As I understand it, XML Schema are the successor for DTDs. My guess is that we should use a Schema unless there's a good reason to use a DTD.
Um, why do we want to use either to describe this data structure? I thought the plan was to eat our own dog food (and it tastes so much nicer).

Ross Paterson
On Wed, Oct 15, 2003 at 11:35:41AM +0100, Simon Peyton-Jones wrote:
As I understand it, XML Schema are the successor for DTDs. My guess is that we should use a Schema unless there's a good reason to use a DTD.
Um, why do we want to use either to describe this data structure? I thought the plan was to eat our own dog food (and it tastes so much nicer).
We are. The data structure itself will be in Haskell, and the XML will be parsed by Haskell. The DTD is a means of describing the XML file, not the data structure. Is there some Haskell way to describe the structure of an XML file? Or are you agreeing with Daan that we shouldn't be using XML? peace, isaac

On Wed, Oct 15, 2003 at 09:59:41AM -0400, Isaac Jones wrote:
Or are you agreeing with Daan that we shouldn't be using XML?
I am, and for the same reasons he gave:
If we describe packages just like ghc-pkg is doing, as a Haskell record, we get: - very simple code for reading and writing those - syntax that is understood by all haskell programmers - optional elements (by using records) - list elements (by using lists)
I think the second one is the most important, with the flexibility of Haskell data structures coming second. There's also brevity, ease of preparation by humans, simplicity and avoiding reliance on lots of tools. Note, however, that the package.conf approach is a little more than Haskell records: the hand-written parsers used by GHC and Hugs allow omitted fields to be filled in with default values, and the output function does pretty printing. (Specs generated by this function or the derived show can be read with the derived read, though.) But I think a little extra code in the library is fine.

Isaac Jones
The data structure itself will be in Haskell, and the XML will be parsed by Haskell. The DTD is a means of describing the XML file, not the data structure. Is there some Haskell way to describe the structure of an XML file?
Don't forget that HaXml also has a "Haskell2Xml" facility for dumping any Haskell data structure (not containing functions) as an XML document, complete with embedded DTD. (Requires DrIFT to derive the Haskell2Xml class, although I'll bet that Template Haskell could also do the job nicely.) Regards, Malcolm

Simon Peyton-Jones wrote:
As I understand it, XML Schema are the successor for DTDs.
W3C XML Schema is at best an alternative to DTDs. The logical _successor_ for DTDs is Relax NG [1].
My guess is that we should use a Schema unless there's a good reason to use a DTD.
In my experience, you should only use W3C XML Schema
if there is absolutely no other choice. Relax NG
is almost always the more appropriate technology.
[1]
participants (7)
-
Graham Klyne
-
Isaac Jones
-
Joe English
-
ketil+haskell@ii.uib.no
-
Malcolm Wallace
-
Ross Paterson
-
Simon Peyton-Jones