Subject: Re: Passing element nodes through string functions (WAS RE: [xsl] Preserving inline elements when using string functions) From: Tom Schutzer-Weissmann <xsl@xxxxxxxxxxxxxxxx> Date: Thu, 11 Sep 2003 15:03:55 +0000 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Passing element nodes through s, Brook Ellingwood | Thread | [xsl] REtrieving attributes with XP, Miguel Carvalho |
RE: [xsl] XMLFilter in a URIResolve, Andrew Welch | Date | RE: [xsl] how to pass parameters do, Wendell Piez |
Month |