dsmithy said:
Hi,
Regarding XSLT empty element tags, why does the xsl:stylesheet tag and
the xsl:template tag not have the characteristic self-closing front
slash,
Because they are not empty elements. They each have an end-tag; at the
end of the stylesheet and the end of the template respectively. Look
closely at an example.
while the xsl
utput tag does have the front slash?
Because it's an empty element.
BTW the word is just "slash", not "front slash". Or perhaps "forward
slash" if you are talking to Windows users who might confuse it with a
backslash.
Is there something that differentiates these tags that explains the
difference that I'm missing?
Yes, see the XML FAQ, question C.12 "Does XML let me make up my own
tags?", the last two paragraphs of the comment at the end by Bob
DuCharme (
http://xml.silmaril.ie/authors/makeup/).
Is there a general rule that predicts
when to include the ending front-slash and when not to?
Yes, read the XML Specification, section 3.1 "Start-Tags, End-Tags, and
Empty-Element Tags", subsection "Tags for Empty Elements", production
[44] (
http://www.w3.org/TR/2008/REC-xml-20081126/#d0e2480).
When an element is empty, you can use the /> (Null End-Tag) syntax. You
can also use a full end-tag instead, if you wish, so <foo bar="blort"/>
is the same thing as <foo bar="blort"></foo> for all practical purposes.
They are functionally identical, but some users restrict the NET format
to those element types which have been declared EMPTY in the DTD or
Schema (and can thus *never* have any content, by design); and use the
fully-qualified form with end-tag for those element types which *might*
contain subelements or character data (that is, they are allowed to by
the DTD or Schema), but they just don't happen to do so on this
occasion. Largely a distinction without a difference, unless you need
interoperability with SGML.
///Peter