[
Lists Home |
Date Index |
Thread Index
]
Sean McGrath wrote:
> I use DTDs for their most excellent powerful, intuitive, concise,
> extended regular expression notation. [...]
> DTDs are not perfect, there are multiple alternatives, some better
> than others for document-oriented XML applications.
RELAX NG serves these purposes very well, and could well have been
called "DTD NG". Using the unofficial non-XML syntax, I think
it deserves all of your adjectives quite as much as DTDs.
Just for the fun of it, here is one of my own DTDs converted to
RNG unofficial syntax. I have removed the introductory comments;
the DTD version is at http://www.ccil.org/~cowan/XML/ibtwsh6.dtd
I have added some datatypes based on the HTML 4.0 documentation.
SGML weenies should note particularly the definitions of "simple"
and "head".
IBTWSH is intended to be used to add rich documentation to elements
of basically data-oriented XML applications.
=====cut here=====
# ibtwsh.rngnx
# This is the Itsy Bitsy Teeny Weeny Simple Hypertext RELAX NG Schema.
default namespace = "http://www.w3.org/1999/xhtml"
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
start = html # Override this when including
# COMMON ATTRIBUTES
# All elements (except full-document elements) have these attributes
all = attribute id {xsd:ID}?,
attribute class {text}?,
attribute title {text}?
# All non-empty elements have these attributes
i18n = attribute xml:lang {text}?,
attribute dir {"ltr"|"rtl"}?
# Most elements have both sets of attributes
basic = all, i18n
# MODELS
horiz = mixed {simple | a | br}
vert = address | blockquote | \div | dl | headings |
list | p | pre | table
horiz.model = horiz*
vert.model = (horiz | vert)*
struct.model = vert*
# HORIZONTAL FORMATTING
simple = element
abbr|acronym|cite|code|dfn|em|kbd|q|samp|span|strong|var
{basic, horiz.model}
a = element a {
basic,
attribute href {xsd:anyURI}?,
attribute name {text}?,
(attribute rel {text} | attribute rev {text})?,
horiz.model}
br = element br {all}
# LISTS
dl = element dl {basic, (dt, dd)+}
dt = element dt {basic, horiz.model}
dd = element dd {basic, horiz.model}
list = element ol|ul {basic, li+}
li = element li {basic, horiz.model}
# BASIC TABLE SUPPORT
aligns = attribute align {"left"|"center"|"right"|"justify"}?,
attribute valign {"top"|"middle"|"bottom"|"baseline"}?
tblinfo = attribute abbr {text}?,
attribute axis {text}?,
attribute colspan {xsd:integer}?,
attribute headers {xsd:IDREFS}?,
attribute rowspan {xsd:integer}?,
attribute scope {"row"|"col"|"rowgroup"|"colgroup"}
table = element table {
basic,
attribute border {xsd:integer}?,
attribute cellpadding {text}?,
attribute cellspacing {text}?,
attribute summary {text}?,
attribute width {text}?,
caption?, tr+}
caption = element caption {basic, horiz.model}
tr = element tr {basic, aligns, (th | td)+}
th = element th {basic, aligns, tblinfo, vert.model}
td = element td {basic, aligns, tblinfo, vert.model}
# OTHER VERTICAL ELEMENTS
address = element address {basic, horiz.model}
blockquote = element blockquote {
basic,
attribute cite {xsd:anyURI},
struct.model}
\div = element div {basic, struct.model}
h = element h1|h2|h3 {basic, horiz.model}
p = element p {basic, horiz.model}
pre = element pre {basic, horiz.model}
# HTML DOCUMENTS
html = element html {
i18n,
attribute xml:base {xsd:anyURI}?,
attribute xml:space {"default"|"preserve"}}?
head = element head {i18n, (title & base?)}
title = element title {i18n, text}
base = element base {attribute href {xsd:anyURI}}
body = element body {all, struct.model}
--
Not to perambulate || John Cowan <jcowan@reutershealth.com>
the corridors || http://www.reutershealth.com
during the hours of repose || http://www.ccil.org/~cowan
in the boots of ascension. \\ Sign in Austrian ski-resort hotel
|