[xsl] Selecting last text() from fragment of unknown depth?

Subject: [xsl] Selecting last text() from fragment of unknown depth?
From: "Adam Desaulniers" <avalonsunsplashtech@xxxxxxxxxxx>
Date: Sat, 05 Feb 2005 08:19:32 -0800
With this template

<xsl:template match="submission.excerpt//node()/@*|submission.excerpt//node()">
<xsl:copy><xsl:apply-templates select="./@*|./node()" /></xsl:copy>
</xsl:template>


have I made it impossible to also transform (inline) the last occurring textnode beneath submission.excerpt/node()?

So far all my recursion attempts (looking for node()[last()][self::text()] at each level) have yielded 3 variations: *only* the last text(), everything *except* the last text(), or the whole thing and then the last text() appended again.

<xsl:choose>
<xsl:when test="./node()[last()][self::text()]">
	<xsl:copy>
		<xsl:apply-templates select="./@*|./node()[position() != last()]" />
		<xsl:value-of select="./node()[last()]" />...
	</xsl:copy>
</xsl:when>
<xsl:otherwise>
	<!-- look again next level, etc -->
</xsl:otherwise>
</xsl:choose>

It's meant to take an XHTML string (truncated from db then made well-formed again by PHP5's loadHTML method) and replace the end of the last text() -- after the last occuring space character -- with an ellipsis, which I've now heard 3x is 'impossible' in XSLT 1.0 but it's not official till I've heard it here.

Undying gratitude,
-Adam.

_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft. SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN. Premium right now and get the first two months FREE*.


Current Thread