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

Subject: Re: Passing element nodes through string functions (WAS RE: Preserving inline elements when using string functions)
From: Tom Schutzer-Weissmann <xsl@xxxxxxxxxxxxxxxx>
Date: Thu, 11 Sep 2003 15:03:55 +0000
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
> &#10;) 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()],'&#10;')"/>
-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.