[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
Hello,

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):

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

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">
 <ul>
  <xsl:apply-templates select="m:node"/>
 </ul>
</xsl:if>

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";
xmlns:m="http://www.uni-augsburg.de/2010/Modulhandbuch";
 exclude-result-prefixes="m">
	
<xsl:output name="handbuch-format" method="xml" indent="yes"
encoding="UTF-8"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
doctype-public="-//W3C//DTD XHTML 1.1//EN" />
	

Thank you very much,
Andreas Knote

Current Thread