View Full Version : Minimal valid document
03-09-2004, 03:40 AM
It's amazing how compact SGML can be made compared to XML...
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Is that last one valid? I thought you could only use the <p/> or <title/> closing method when the element was EMPTY in the dtd?
03-09-2004, 10:01 PM
03-10-2004, 12:07 AM
In XML there is NO difference between <element/> and <element></element> whatsoever. In SGML there is, but that's because in SGML an empty element is considered self-terminating.
Is there any browser difference? Obviously tagsoup browsers would interpret it as non-closing but what about XML reading browsers? Actually, does IE interpret <element /> as XML-closed or just SGML-self closing?
03-10-2004, 06:40 PM
These aren't validating for me (and it's not due to the double 2nd opening body tag instead of the closing in the XHTML example). Only certain tags are allowed to close as <element />. But don't forget about XHTML 1.1:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<title> New Document </title>
Which is better though? XHTML 1.0 Strict is good, but 1.1 (I don't think there's any variations of it) is a bit more strict I think.
03-10-2004, 06:49 PM
The last example (the XHTML strict one) is not well-formed and thus not valid. The second <body> tag should be rather a closing </body> tag.
EDIT: Posts crossed. Did some more tests.
03-10-2004, 07:12 PM
curious: WHAT'S THE POINT HERE PEOPLE..
just to show the minimal amount you need for a valid document? like? whoopee? i'm confused..
03-10-2004, 09:28 PM
Gee, calm down. I just missed that slash, it's fixed now.
It was a comparison between the languages - XML is clearly larger and more verbose than SGML. On the other hand, it's unambigous and easily readable. Have a look at <http://www.virtuelvis.com/download/162/evilml.html> for an example of a really obfuscated SGML document - valid HTML4.01, of course.
03-10-2004, 09:49 PM
Originally posted by liorean
XML is clearly larger and more verbose than SGML.
XML is just a cut down version of SGML anyway... so what do you expect? (All XML is SGML etc)
Besides, a minimal XML document would be more like this:
03-10-2004, 09:50 PM
'me: Ie interprets it as tagsoup. XHTML and XML browser interpret it as a terminated element. Only DocZilla in SGML mode interprets it as SGML opening tag, followed by the character '>'.
Tails: You need a block level element within the body for it to validate. And as I said, XML doesn't do any difference between <element/> and <element></element> - no matter what the DTD says. The reason I can say this is the case? Why, canonical XML does a conversion from <element/> to <element></element> in the working source code.
Note this excerpt:
Except for limitations regarding a few unusual cases, if two documents have the same canonical form, then the two documents are logically equivalent within the given application context.
DougBTX: Not quite. Until SGML was amended, some legal XML was illegal SGML. Anyway, what we were discussing was HTML/XHTML, not XML/SGML.
03-10-2004, 10:08 PM
Originally posted by liorean
And as I said, XML doesn't do any difference between <element/> and <element></element> - no matter what the DTD says. The reson I can say this is the case?
That's right; remember that any thing you can do with one piece of XML you should be able to do with anyother piece of XML. An XML phraser doesn't need to know about the XHTML DTD just becuse the XML it it reading happens to be XHTML.
03-10-2004, 10:53 PM
Well, the thing is that XML and XHTML govern different things. XML governs syntax and general format, while XHTML governs what elements and attributes are allowed, and where. The XML parsing comes in before the XHTML recognition, which means that in effect if the XML is well formed it is then checked for XHTML recognition - or validity checking for user agents that does that.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.