By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,869 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,869 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Gordon - Adelphia wrote:
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/j...004060501.html
it validates with http://validator.w3.org:
http://validator.w3.org/check?uri=ht...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.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.