Re: gutvol-d Digest, Vol 13, Issue 24

David A. Desrosiers" <hacker@gnu-designs.com> wrote:
I've learned the fear the <div> container. Let me show you why using a <div> container for "non-specific" blocks of text won't work.
<div> <head>Level 1</head> <p>Paragraph 1.</p> <div>Block o' text.</div> <p> Paragraph 2.</p> </div>
Improperly nested tags will never validate. You can't have a bare string inside the <head> tag like that, and <head> isn't a child of <div>, so that won't work either. After correcting those errors, it validates fine.
The above will not validate. Once you go one deeper in a nest, you cannot come back up just one level. You have to close the whole nesting.
Nope, this is completely untrue.
The above would work if changed to:
<div> <head>Level 1</head> <p>Paragraph 1.</p> <div>Block o' text.</div> </div> <div> <p> Paragraph 2.</p> </div>
You're still producing invalid markup. Try something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><title>Level 1</title></head> <body> <p>Level 1</p> <div> <p>Paragraph 1.</p> <div>Block o' text.</div> <p> Paragraph 2.</p> </div> </body> </html>
I fear that Mr. Desrosiers has made the classic error of confusing varieties of fruits, which is third only to "never become involved in a land war in Asia." and "never bet with a Sicilian when death is on the line." Mr. Hutchinson's code snippet was encoded using the TEI vocabulary of XML, not the XHTML vocabulary. In TEI the <head> tag is analogous to the HTML <h1> tag, and the HTML <head> tag is analogous to the TEI <teiHeader> tag. Apples and oranges. On the other hand, I don't see how Mr. Hutchinson's second example could validate if the first does not, particularly given the fact that DTD's are not structured in such a way to permit a validator to make that kind of a judgment ("if a <div> contains a <div> it must be the last element of the first <div>" or "if a <div> contains a <div> it may be preceded by a <p>, but not followed by one"). I'm not that great at deciphering DTDs, but I don't see anything in http://www.tei-c.org/P4X/DS.html which would cause me to believe that example 1 is not valid. In this particular case, I suspect a bug in the validator program. I mean, writing validators is hard, and I am aware of at least one bug in the W3C's online HTML validator. Supposedly, Xerces is a validating parser. Maybe I'll see if I can find the time to run the snippet through Xerces and see if (and where) it breaks.

Lee Passey wrote:
On the other hand, I don't see how Mr. Hutchinson's second example could validate if the first does not, particularly given the fact that DTD's are not structured in such a way to permit a validator to make that kind of a judgment ("if a <div> contains a <div> it must be the last element of the first <div>" or "if a <div> contains a <div> it may be preceded by a <p>, but not followed by one").
This simple declaration does exactly that: <!ELEMENT div (p*, div*)> "A div may contain zero or more p followed by zero or more div."
In this particular case, I suspect a bug in the validator program. I mean, writing validators is hard, and I am aware of at least one bug in the W3C's online HTML validator.
No bug. The TEI dtd is broken as designed.
Supposedly, Xerces is a validating parser. Maybe I'll see if I can find the time to run the snippet through Xerces and see if (and where) it breaks.
Get libxml2 from xmlsoft.org and use xmllint. -- Marcello Perathoner webmaster@gutenberg.org
participants (2)
-
Lee Passey
-
Marcello Perathoner