[xsl] Applying lists outside of paragraphs

Subject: [xsl] Applying lists outside of paragraphs
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Wed, 20 Sep 2006 09:53:51 -0800
Hi List,

Thanks in advance for the help. I'd like to blame this one on Monday,
except for the fact that it isn't...

I'm attempting to apply-templates to my paragraph elements and then
apply-templates to my list elements as the list elements are currently
embedded in the paragraph elements.

INPUT

<?xml version="1.0"?>
<para.appl>Blah Blah <term>foo</term> to <term>bar</term> for
	<term>foo</term>, Blah Blah:
	<list.appl>
		<listitem.appl>Bullet 1</listitem.appl>
		<listitem.appl>Bullet 2 <term refid="wtr-tm">bar</term></listitem.appl>
	</list.appl>
</para.appl>


XSL


<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/">
	<xsl:apply-templates/>
</xsl:template>

<!-- This is the weird Part -->
<xsl:template match="para.appl">
<p><xsl:apply-templates select="*[not(descendant-or-self::list.appl)]"/></p>
<xsl:apply-templates select="list.appl"/>
</xsl:template>

<xsl:template match="list.appl">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>

<xsl:template match="listitem.appl">
<li><xsl:apply-templates/></li>
</xsl:template>

<xsl:template match="term">
<em><xsl:apply-templates/></em>
</xsl:template>

</xsl:stylesheet>


OUTPUT


<p><em>foo</em><em>bar</em><em>foo</em></p><ul>
		<li>Bullet 1</li>
		<li>Bullet 2 <em>bar</em></li>
	</ul>


DESIRED OUTPUT


<p>Blah Blah <em>foo</em> to <em>bar</em> for
	<em>foo</em>, Blah Blah:</p>
	<ul>
		<li>Bullet 1</li>
		<li>Bullet 2 <em>bar</em></li>
	</ul>


I can't quite figure out why <xsl:apply-templates select="*[not(descendant-or-self::list.appl)]"/> does not want to apply the default text() template. I've also tried no axis, child::, descendant:: and even self:: but none give the desired output... Any ideas? I'm using Saxon 8.7.1

Thanks in advance for the help

Spencer

Current Thread