You need to be logged in to post in the forums. If you do not have an account, please sign up first.
Few questions about XHTML and Opera
1. Is there any difference for Opera if document is saved as document.htm, document.html, document.xhtml, document.xml or document.abc? I've tested document.abc and it opens without any problems, but is there any situation when extension is important?2. What is the difference between application/xhtml+xml and application/xml? I've tried to use Google on "difference between application/xhtml+xml and application/xml", but there isn't any direct answer. OK, I understand that application/xml is some kind of more "purer" or "radical" XML, but what is the precise difference?
3. The following example is based on the example from the book HTML & CSS: The Complete Reference, Fifth Edition. The element are the same, I just changed the content of the document to make it more simple (according to the book, this is valid XHTML, or more precisely XHTML 5 document):
<?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>The most simple XHTML document</title> </head> <body> The most simple XHTML document. </body> </html>
Is the above example served as application/xhtml+xml or application/xml?
Originally posted by RAVENGRUPA:
1. Is there any difference for Opera if document is saved as document.htm, document.html, document.xhtml, document.xml or document.abc? I've tested document.abc and it opens without any problems, but is there any situation when extension is important?
.xhtml will be parsed as XHTML and .xml will be parsed as XML (i.e. either tree view if no style info present or otherwise rendered). Anyway, what happens on your HDD will probably be different from what happens on a server.
Originally posted by RAVENGRUPA:
2. What is the difference between application/xhtml+xml and application/xml? I've tried to use Google on "difference between application/xhtml+xml and application/xml", but there isn't any direct answer. OK, I understand that application/xml is some kind of more "purer" or "radical" XML, but what is the precise difference?
application/xhtml+xml is XHTML and application/xml is XML. The difference is mostly that XHTML has defined semantics and display that might not be picked up if treated as XML. See this:
In general, 'application/xhtml+xml' should be used for XHTML Family documents, and the use of 'text/html' should be limited to HTML-compatible XHTML Family documents intended for delivery to user agents that do not explicitly state in their HTTP Accept header that they accept 'application/xhtml+xml' [HTTP]. The media types 'application/xml' and 'text/xml' may also be used, but whenever appropriate, 'application/xhtml+xml' or 'text/html' should be used rather than those generic XML media types.
http://www.w3.org/TR/xhtml-media-types/#intro
So the example should be served with application/xhtml+xml. However, you should also add a DTD.
22. May 2010, 16:03:22 (edited)
Originally posted by RAVENGRUPA:
2. What is the difference between application/xhtml+xml and application/xml?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script>
window.addEventListener("DOMContentLoaded", function() {
alert(document.body);
}, false);
</script>
</head>
<body>
</body>
</html>
Try served as application/xml (or .xml locally) and application/xhtml+xml (or .xhtml locall).
What you will see is that *in Opera*, document.body isn't defined for application/xml. This will be fixed in Opera eventually though. But, it 's currently a difference.
That aside, in browsers, given the exact same markup, application/xml and application/xhtml+xml should give you the exact same results and behavior. After all, it's just XML. What default styles/behavior you get depends on the namespaces you use for elements (like http://www.w3.org/1999/xhtml ). The doctype and linked dtd don't make a difference except for definition of entities and XML validation. See XML Load External Entities and XML Validate. But, note that XML validation won't work with XHTML 1.1 because the DTD is modular and fetching all the individual files referenced in the main dtd is denied for security reasons.
text/html (and .html and .htm locally) causes the browser to use its HTML parser (instead of an XML one) , which parses things in a very lax way with error handling etc. (and different rules than an XML parser would follow). In this case, the markup is treated as HTML no matter what it looks like. But, the presence of certain doctypes will put the browser in a rendering mode that follows the specs better.
Typically, with text/html in browsers, there's only one HTML parser and it handles all HTML markup (no matter what the markup looks like).
It is the combination of MIME type and XML namespace that makes it XHTML.
You could also use the MIME type text/xml, but it's not recommended due to the very odd rules concerning character encodings. (Which Opera don't comply with, fwiw.)
Forums » General Opera topics » Opera and cross-browser Web design