Penguin

Differences between version 2 and predecessor to the previous major change of WellFormed.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Thursday, August 21, 2003 1:17:37 pm by AristotlePagaltzis Revert
Older page: version 1 Last edited on Thursday, August 21, 2003 12:09:47 pm by StuartYeates Revert
@@ -1,31 +1,30 @@
-An [XML] document is [WellFormed] if it parses correctly. The main issue that causes [XML] not to be [WellFormed] is tag ordering . For example the following is [WellFormed]
+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
  
- ...  
- <a >  
- this is well formed </b >  
- <c > this is well formed too </c >  
- </a >  
- ..
+ <p >A paragraph <em ><strong >here </em ></strong >.  
+ <p>And another one there
  
-while this is not: 
+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
  
- ...  
- <a >  
- this is well formed <b >  
- <c > this is well formed too  
- </a >  
- ...  
+ <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. 
  
-The tag pattern:  
+If you want non-nesting overlapping ranges you cannot use something like  
  
  <a> ... <b> ... </a> ... </b> 
  
-is not WellFormed in either [SGML] or [XML], if you want non-nesting overlapping ranges such as this you need something like:  
+but should use something like 
  
  <a id="1"/> ... <b id="2"/> ... <a id="1"/> ... <b id="2"/> 
  
-then you can reconstruct either of the tags as necessary. 
+instead, and then you can reconstruct either of the tags as necessary.  
+  
+;: ''I disagree strongly with that practice. You are undercutting the purpose of [XML] by flattening the markup. Instead, you should use attributes to your advantage.''  
+  
+ <foo type="a" partof="1"> ... </foo> <foo type="a" partof="1" partof="2"> ... </foo> <foo type="b" partof="1"> ... </foo>  
+  
+;: ''Yes, it's bulkier. Try in some way to process markup written with both approaches using [XSLT] and you'll notice the difference. %%% --AristotlePagaltzis''  
+  
  
 [WellFormed] [XML] differs from [Valid] [XML] in that [Valid] [XML] has been (or could be) checked against a [Schema] or [DTD].