[xsl] Empty Tags not closed properly

Subject: [xsl] Empty Tags not closed properly
From: Andreas Knote <andreas.knote@xxxxxxxxxxxxxx>
Date: Sun, 5 Dec 2010 11:39:39 +0100

I'm experiencing an annoying problem when transforming a document
using Saxonb-9.1 (I've not found a way to use the newer versions with
Ant, is there any?).

Let's say i'd like to apply a template to a node set and wrap the
result with an <ul> element (or any other):

 <xsl:apply-templates select="m:node"/>

It works fine, except that if there is no "m:node"-Element to be
found, the <ul> is not closed immediately, but only at the very end of
the resulting document (thus making it correct xhtml again, by chance
probably), destroying the output.

A possible workaround is:

<xsl:if test="m:node">
  <xsl:apply-templates select="m:node"/>

But i don't see why that should be obligatory.

I'm using xslt 2.0, saxonb-9.1, ant;

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 version="2.0" xmlns="http://www.w3.org/1999/xhtml";
<xsl:output name="handbuch-format" method="xml" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.1//EN" />

Thank you very much,
Andreas Knote

Current Thread