XSL-optimized DTDs (Was: Re: Mixed content: selecting current context w/out child)

Subject: XSL-optimized DTDs (Was: Re: Mixed content: selecting current context w/out child)
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Sun, 14 Mar 1999 15:10:28 -0500
>>[I wrote]:
>>    <name>Candace Hilligoss<role>Mary Henry</role></name>

At 01:29 PM 3/14/99 +0800, James Tauber pointed out:
>...I don't think the above is particularly wise markup. Of course,
>there is nothing illegal about it as far as XML goes (which is why I use the
>term _wise_). What you are marking up as a "name" isn't a name. It's a
>matching of two names and it will (as you've discovered) give you potential
>problems later on if it isn't marked up as such.

O indeed. This is the sort of reason why my 6-month-old DTD is already up
to version 3.0 :).

I think I'm learning that mixed-content models can be, well, rather
perfidious, although they're handy for simplifying things to a
structured-data-naive audience. Except in the case of paragraph-style
elements where you can foresee a need for in-line content of the HTML <br>,
<a> and <em> varieties, as well as exotica like IDREF pointers to other
content in the document -- with those exceptions, mixed content really does
seem to induce logical difficulties downstream. 

Similarly, it's beginning to seem a mistake to define first-level children
which may occur multiple times, *without* enclosing them in their own
container/wrapper parents, at least when the data are intended for XSL
transformations to rendering. 

For instance, consider a scheduling application whose root is a calendar
	<!ELEMENT calendar (year)+ >
	<!ELEMENT year (month)+ >
If left this way, when you actually have to transform a document instance
into (say) HTML, you've got to do all sorts of first-of-type and
not(first-of-type) exception processing for the for-each loops that build
tables, lists, and so on. The XSL will be much cleaner if you can use this
sort of structure instead:
	<!ELEMENT calendar (years) >
	<!ELEMENT years (year)+ >	<!-- "wrapper" for multiple years -->
	<!ELEMENT year (months) >
	<!ELEMENT months (month)+ >	<!-- "wrapper" for multiple months -->

Then you just construct the "wrapper" HTML to correspond to the "wrapper"

(I know, not that I need to tell *you* this. :)  Just recounting the kind
of thunderbolt to the consciousness that makes trying to grok all this on
one's own so worthwhile.)

John E. Simpson            | The secret of eternal youth
simpson@xxxxxxxxxxx        | is arrested development.
http://www.flixml.org      |  -- Alice Roosevelt Longworth

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread