Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
WellFormed
Edit
PageHistory
Diff
Info
LikePages
You are viewing an old revision of this page.
View the current version
.
An [XML] document is [WellFormed] if it parses correctly. This means mainly that all tags must be closed, that they must be nested correctly, and that all attribute values must be quoted. This is not valid: <p>A paragraph <em><strong>here</em></strong>. <p>And another one there. The paragraph tags are not closed, and the nesting for the emphasis and strong tags is wrong. To be WellFormed, this piece of the document has to be written like so: <p>A paragraph <strong><em>here</em></strong>.</p> <p>And another one there.</p> In the second fragment, neither the <b> nor the <c> tag are closed. Unlike [SGML], [XML] does not allow tags to be automatically closed when the enclosing tag is closed. This is the reason why the <p> tag in [HTML]/[XHTML] gives people grief---in [HTML] you only need to put in the opened tags while in [XHTML] you need to put in both the opening and the closing tag. If you want non-nesting overlapping ranges you cannot use something like <a> ... <b> ... </a> ... </b> but should use something like <a id="1"/> ... <b id="2"/> ... <a id="1"/> ... <b id="2"/> instead, and then you can reconstruct either of the tags as necessary. This flattened form also allows certain kinds of diff-like reasoning which are much more difficult on trees. An alternative to this, which avoids flattening the markup, is to do: <foo type="a" partof="1"> ... </foo> <foo type="a" partof="1" partof="2"> ... </foo> <foo type="b" partof="1"> ... </foo> This is bulkier (especially when there are a very large number of overlapping structures) but much easier to process with [XSLT]. The choice between these is the subject of a minor ReligiousWar. [StuartYeates] is in favour of the former, [AristotlePagaltzis] in favour of the latter. The whole problem was solved in [SGML] using the CONCUR feature, which appears never to have been implemented. [WellFormed] [XML] differs from [Valid] [XML] in that [Valid] [XML] has been (or could be) checked against a [Schema] or [DTD].
3 pages link to
WellFormed
:
XHTML
Valid
XML