On Wednesday 10 Sep 2003 18:35, Brook Ellingwood wrote:
...
Secondly, I'm revisiting this problem that David provided a solution for,
and I've found case where it breaks down. If the last line (set off by
) contains a <link> followed by unlinked text, the string after the
</link> is dropped. Basically, the recursive loop is stopping one recursion
too soon. I've tried a few ways of including the substring in the
<xsl:otherwise> escape from the loop, but haven't gotten it right, and I'm
not sure that I'm on the right track. I'd appreciate any insight.
<xsl:value-of
select="substring-before(key('x',generate-id(.))[last()],' ')"/>
-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If the last node returned by the key doesn't contain a newline (this is the
case for the very last div), then you won't get any of it at all.
So just include this special case...
<xsl:if test="position() = last()">
<xsl:value-of
select="key('x',generate-id(.))[last()]"/>
</xsl:if>
or sort out the source...
perl -pi.bak -e
'$go = 1 if (/<text>/);
s/(.*<text>|^)(.*?)($|<\/text>)/$1<div>$2<\/div>$3/
if $go; s/<div>\W*<\/div>//; $go = 0 if (/<\/text>/);' source.xml
hth
Tom SW
--
"Life goes on. More than is lawful." - Karl Kraus.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list