This post was imported from my old Drupal blog. To see the full thing, including comments, it's best to visit the Internet Archive.
The problem: You’re using MSXML (and therefore XSLT 1.0). You’re outputting XHTML (and therefore using the
xml method). You want to output an empty
<a> element for an anchor, but want to make sure that you get a start tag and and end tag (
<a id="foo"></a>) rather than an empty element tag (
Is the only solution disable-output-escaping? No! MSXML outputs start and end tags if you create an element using literal result elements,
<xsl:element> with any instruction that could potentially produce content. So whereas
putting something innocuous inside, such as
<a id="foo"><xsl:value-of select="''" /></a>
- Of course with another XSLT processor, or XSLT 2.0, you would use an xhtml output method to make sure that empty element syntax was only used for elements that are declared to be
EMPTY, such as
- This trick might not work with other XSLT processors; certainly Saxon always outputs an empty element if the element is empty.
- And anyway, using empty
<a>elements for anchors is not good quality XHTML.