The Content-type HTTP header and/or meta element are what browsers use to
determine if a document is interpreted as HTML, XHTML, or something else. For
various reasons (mainly IE 6, 7, 8, and 9), I wouldn't recommend serving XHTML
(application/xhtml+xml) to web browsers. I don't see any advantages to it and I
think it introduces significant risk. The DOM and CSS selectors are slightly
different with XML compared to HTML served as text/html. For example, I'm not
sure any of the popular JavaScript frameworks explicitly supports running as
XHTML. In more of a web service scenario, where the client is known to accept
XHTML, I’d recommend using application /xhtml+xml. However, that’s not the case
for today’s browsers.
Irrespective of the root element namespace or the DOCTYPE, I would recommend
serving pages that you intend to be consumed by today's browsers as
"text/html". The DOCTYPE, on the other hand, is what browsers use to toggle
between rendering modes--the older "quirks" mode for backward compatibility and
the new standards mode. This affects the HTML DOM in JavaScript as well as
various CSS properties. I would strongly recommend always using a DOCTYPE to
trigger standards mode. The actual contents of DOCTYPE declaration is
meaningless; the fact that it's there is what triggers standards mode. (For
example, HTML5 recommends the DOCTYPE, <!DOCTYPE html>.) As Geert has pointed
out below, there are special things that the serializer does in the name of
pragmatism for properly namespaced XHTML.
Here's the template that I typically use:
(
xdmp:set-response-content-type('text/html;charset=utf-8'),
'<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Welcome to MarkLogic Server</title>
...
</head>
...
</html>
)
Justin
Justin Makeig
Product Manager
Mark Logic Corporation
999 Skyway Road
Suite 200
San Carlos, CA 94070
+1 650 655 2387 Phone
[email protected]<mailto:[email protected]>
www.marklogic.com<http://www.marklogic.com>
<http://www.marklogic.com/><http://www.marklogic.com/>
This e-mail and any accompanying attachments are confidential. The information
is intended solely for the use of the individual to whom it is addressed. Any
review, disclosure, copying, distribution, or use of this e-mail communication
by others is strictly prohibited. If you are not the intended recipient, please
notify us immediately by returning this message to the sender and delete all
copies. Thank you for your cooperation.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Geert Josten
Sent: Friday, September 11, 2009 5:33 AM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Marklogic formatting of empty XHTMLelements
> > The serializer won't collapse empty div, script, and
> textarea elements if they're in the XHTML namespace.
> > Hopefully this helps. Please let me know if you have
> further questions or concerns.
>
> Is that enough? I know that in the past, I've had trouble
> with empty <em/> tags being misinterpreted by browsers.
It looks like it works for any empty element in that namespace:
<x />,
<x xmlns="http://www.w3.org/1999/xhtml" />
==>
<x/>
<x xmlns="http://www.w3.org/1999/xhtml"></x>
The problem is actually that we tend to set the response type to 'text/html',
while we are actually outputting XHTML. The HTML standard doesn't allow this />
shortened notation of empty elements and browsers tend to ignore the / in them,
thinking it is actually a start tag instead of an empty tag.
The alternative might be to set the response content-type to
'application/xhtml+xml', but you never know what kind of browser (version)
someone is using. I think this is the safest approach..
Kind regards,
Geert
Drs. G.P.H. Josten
Consultant
http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - is afkomstig van
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit
bericht kunnen geen rechten worden ontleend.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general