This does the right thing with a response type of text/html too. For web apps,
text/html tends to be a lot safer then application/xhtml+xml (as Geert pointed
out). So this does the right thing when run against an app server by putting a
closing tag on the xhtml element:
xquery version "1.0-ml";
xdmp:set-response-content-type("text/html"),
<x />,
<x xmlns="http://www.w3.org/1999/xhtml" />
returns (you will have to view source to see it):
<x/>
<x xmlns="http://www.w3.org/1999/xhtml"></x>
-Danny
-----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