I wrote:
it's a grouping problem (positional grouping in Mike's terminoligy)
you want to group all child nodes before or after text nodes containing
cr ie text()[contains(.,' ')] you need to work at the level of nodes
not of the entire content of your bodytext element.
See Jeni's site on grouping techniques.
David
I suppose this is probably more helpful...
div.xml
========
<page>
<bodytext>This is the <link url="zzz">link</link>
This is another line</bodytext>
</page>
div.xsl
========
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="x" match="bodytext/node()"
use="generate-id((..|preceding-sibling::text()[contains(.,' ')][1])[last()])"/>
<xsl:template match="page">
<html>
<head>
<title>testing...</title>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="link">
<a href="{(_at_)url}">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="bodytext">
<body>
<xsl:for-each select=".|text()[contains(.,' ')]">
<div>
<xsl:value-of
select="substring-after(self::text(),' ')"/>
<xsl:apply-templates
select="key('x',generate-id(.))[position()<last()]"/>
</div>
<xsl:value-of
select="substring-before(key('x',generate-id(.))[last()],' ')"/>
</xsl:for-each>
</body>
</xsl:template>
</xsl:stylesheet>
$ saxon div.xml div.xsl
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
<title>testing...</title>
</head>
<body>
<div>This is the <a href="zzz">link</a></div>
<div> This is another line</div>
</body>
</html>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list