xhtml <body> w/ text() nodes-- why?

  • Thread starter Gordon - Adelphia
  • Start date
G

Gordon - Adelphia

I have a question regarding xhtml. Why, why, why does the ELEMENT <body>
allow “unblocked” text. HTML does not (though, most browsers will
render). Xhtml (transitional) however allows text nodes (PCDATA).

All of HTML 4, xhtml – transitional, and xhtml-strict allow <div> to
contain “unblocked” text. Does anybody know why – I’m looking for the
philosophy behind allowing such.

I’m in the process of encapsulating xhtml mark-up in content marked xml.
The content mark-up describes technical “facts” – the descriptions are
encapsulations of “ideas” expressed in English. Those encapsulations use
most of the exposition tools available to authors: tables, images, …
most all things allowed in xhtml. Now, for a variety of reasons I do not
want text fragments just hanging – they need to be part of a paragraph
(<p>), a list, a table… Until I started on this project I never paid
close attention to the formal dtds defining xhtml/html variants – I just
always thought “unblocked text” was not allowed. If it were not, I would
be able to simply adopt large portions of those dtds in my dtd (and
easily convert existing html and portions thereof into my compendiums of
xml “wrappered” facts.

I’m hoping that if I could understand the reasoning rational for
allowing “unblocked” text in a div (or, on the extreme case in body), I
might see that I should not be worried about the same in my application.

Thanks for any insight you can supply.
Gordon
 
M

Martin Honnen

Gordon said:
I have a question regarding xhtml. Why, why, why does the ELEMENT <body>
allow “unblocked” text. HTML does not (though, most browsers will
render). Xhtml (transitional) however allows text nodes (PCDATA).

All of HTML 4, xhtml – transitional, and xhtml-strict allow <div> to
contain “unblocked” text. Does anybody know why – I’m looking for the
philosophy behind allowing such.

Looking at the HTML 4.01 transitional DTD at
http://www.w3.org/TR/html4/sgml/loosedtd.html
the BODY element is defined as
<!ELEMENT BODY O O (%flow;)* +(INS|DEL) -- document body -->
where flow is defined as
<!ENTITY % flow "%block; | %inline;">
and inline is defined as
<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; |
%formctrl;">
thus I think that with HTML 4.01 transitional it is valid to have text
nodes as child nodes of the BODY element. An example is at
http://home.arcor.de/martin.honnen/javascript/200406/test2004060501.html
it validates with http://validator.w3.org:
http://validator.w3.org/check?uri=h...+automatically)&doctype=Inline&ss=1&verbose=1

Looking at the HTML 4.01 strict DTD at
http://www.w3.org/TR/html4/sgml/dtd.html
the BODY element is defined as
<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->
thus with HTML 4.01 strict text nodes are not allowed as direct child
nodes of the BODY element.

Now looking at the definitions in XHTML 1.0 transitional at
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
the body element is defined as
<!ELEMENT body %Flow;>
and Flow is defined as
<!ENTITY % Flow "(#PCDATA | %block; | form | %inline; | %misc;)*">
while in XHTML 1.0 strict the body element is defined as
<!ELEMENT body %Block;>

I don't see where XHTML 1.0 transitional differs from HTML 4.01
transitional in regards to text nodes as direct child nodes of the body
element, both allow. Furthermore both XHTML 1.0 strict as well as HTML
4.01 strict both disallow text nodes as direct child nodes of the body
element.
Thus I don't see the problem with body you have outlined above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top