[
Lists Home |
Date Index |
Thread Index
]
Dennis Sosnoski scripsit:
> Simplicity and terseness are at the top of my list. The only real
> problem with using DTDs now is Namespaces. The non-XML format is a pain,
> but less so than the verbosity and complexity of Schemas. DTDs are
> simple enough that they don't really require any special tools, in my
> experience; Schemas do.
How does this suit you?
## Simplified purchase order schema for Example.com.
## Copyright 2002 Example.com. All rights reserved.
start = element purchaseOrder { purchaseOrderType }
comment = element comment { text }
purchaseOrderType =
element shipTo { USAddress },
element billTo { USAddress },
comment?,
element items { Items },
attribute orderDate { text }
USAddress =
element name { text },
element street { text },
element city { text },
element state { text },
element zip { xsd:decimal },
attribute country { xsd:NMTOKEN "US" }
Items =
element item {
element productName { text },
element quantity {
xsd:positiveInteger params { maxExclusive = "100" }
},
element USPrice { xsd:decimal },
comment?,
element shipDate { xsd:date },
attribute partNum { SKU }
}
## Stock Keeping Unit, a code for identifying products -->
SKU = xsd:string params { pattern = "d{3}-[A-Z]{2}" }
(This schema slavishly imitates the one in XS-0, and is not an example
of my personal style.)
> Familiarity is certainly a part of this. I strongly suspect, though,
> that given equal time spent on both most users would be able to work
> with DTDs far more reliably and confidently than with Schemas.
Quite likely true, since DTDs have fewer things to learn about.
As a result, one can go more deeply into each feature in a given time.
> Rudimentary validation support makes sense to me as a developer using
> XML (basically what's provided by DTDs, element and attribute names,
> nesting, and ordering). Going beyond that is redundant to my application
> code, which means that either I'll ignore the extra validation features
> or will just turn off validation in the parse.
Okay, here's a stripped-down version of the above with no datatypes:
start = element purchaseOrder { purchaseOrderType }
comment = element comment { text }
purchaseOrderType =
element shipTo { USAddress },
element billTo { USAddress }
comment?,
element items { Items },
attribute orderDate { text }
USAddress =
element name { text },
element street { text },
element city { text },
element state { text },
element zip { text },
attribute country { "US" }
Items =
element item {
element productName { text },
element quantity { text },
element USPrice { text },
comment?,
element shipDate { text },
attribute partNum { text }
}
> My main argument is just that validation through Schema or any of the
> alternatives does not eliminate the need for a consciencious developer
> to verify the data as received by the application - and if you're doing
> this, why have the parser run a subset of the same checks?
Well, there is verifying and there is verifying. Why bother to program
checks in full generality using procedural code if you can partially
express them in declarative language? The same applies to structural
checks, after all: do you write code when processing an element to
verify that it has correct parents and children, or do you rely on the
declarative validation? It's all in where you draw the line.
> Now I see Schema as the reincarnation of Ada (my apologies to
> any Ada fans on the list, but I went through much the same experience
> with that initiative at the time it came out) - elegant in a way, but
> far too complex to be appealing.
On this analogy, RELAX NG is Scheme.
> Join the DTD Underground! The Evil Elitist Schema Empire will be Crushed
> by the Indifference of the Uprisen Masses of the Developer Proletariat!
> We Shall Overcome!!!
Having fought the good fight for DTDs, fight the better fight for RELAX NG.
> Or not... ;-)
The people united can never be defeated.
--
John Cowan <jcowan@reutershealth.com> http://www.reutershealth.com
I amar prestar aen, han mathon ne nen, http://www.ccil.org/~cowan
han mathon ne chae, a han noston ne 'wilith. --Galadriel, _LOTR:FOTR_
|