What is it that distinguishes the <state...> and <city...> tags from the <country...> tags? Is it strictly that the OP's code provides the shortcut close, "/>" for state and city but not for country?
Yes.
If <country...> had a shortcut close would it not need a </county> tag?
<foo x="y"/> and <foo x="y"></foo> are completely equivalent, so not only would it not need a </country> tag, it could not have a </country> tag. One can't close an element more than once.
your explanation doesn't seem consistent with beginner tuts
I presume you are referring to "all XML elements must have a closing tag".
That claim is true, but <foo/> serves as both the opening and closing tag of the element, so it satisfies the requirement of the presence of a closing tag.
why not use a shortcut close globally -- that is, on <world> and <country>
That would be impossible because the world and country elements have non-attribute children.
In fact, I'd say the city elements are misplaced in the OP's XML. The indenting indicates the OP wants them to be children of states, but he made them children of countries.
<country short="usa" name="united state of america">
<state short="CA" name="california"/>
<city short="SFO" name="San Franscisco"/>
<city short="EM" name="Emeryville"/>
<state short="FL" name="florida"/>
... More intermixed states and cities ...
</country>
means
<country short="usa" name="united state of america">
<state short="CA" name="california"></state>
<city short="SFO" name="San Franscisco"></city>
<city short="EM" name="Emeryville"></city>
<state short="FL" name="florida"/></state>
... More intermixed states and cities ...
</country>
but he surely wants
<country short="usa" name="united state of america">
<state short="CA" name="california">
<city short="SFO" name="San Franscisco"/>
<city short="EM" name="Emeryville"/>
</state>
<state short="FL" name="florida">
... More cities ...
</state>
... More states ...
</country>
the shortcut close on image is NOT required by 4.01 transitional (aka "loose").
That's not right.
| SGML | HTML5 HTML Serialisation | XML
|
---|
HTML4 | Other | XHTML1 strict | XHTML1 transitional | HTML5 | Any other XML schema
|
---|
strict | transitional
|
---|
<br> | Well-formed and Valid | [Varies] | Valid | Malformed
| <p> | Well-formed and Valid | Valid
| <div> | Well-formed but Invalid | Invalid
| <br/> | Malformed | Tolerated* | Well-formed and Valid
| <p/> | Invalid
| <div/> | Invalid
| <br></br> | Well-formed but Invalid | Invalid | Well-formed and Valid
| <p></p> | Well-formed and Valid | Valid
| <div></div> | Well-formed and Valid | Valid
|
Note that browsers are very forgiving and accept all kinds of malformed and invalid HTML.
As an aside, the table clearly highlights XHTML's advantage over HTML: simplicity. The cost, of course, is that XHTML is more wordy. (Like Java vs Perl?)
* — The HTML serialisation of HTML5 accepts "/" on elements that cannot have a closing tag (area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr). (ref)
The standards for 4.01 transitional and 4.01 strict differ on what's required
They differ on what constitutes a valid HTML or XHTML document (i.e. what elements and attributes are allowed), but they do not differ on what constitutes a well-formed HTML or XML documents (i.e. on what is valid syntax).
|