|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Passing element nodes through string functions (WAS RE:
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








