I would probably parse the text first to create xml nodes:
Something like this:
<xsl:stylesheet version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="xml">
<xsl:call-template name="toXml"><xsl:with-param name="values" select="values" /></xsl:call-template>
</xsl:variable>
<p>
<xsl:for-each select="msxsl:node-set($xml)/value">
<xsl:value-of select="concat(y, '#xa0;#xa0;', x, '#xa0;#xa0;', z)" /> <br />
</xsl:for-each>
</p>
<p>
<xsl:for-each select="msxsl:node-set($xml)/value/x">
<xsl:value-of select="concat(., '#xa0;#xa0;')" />
</xsl:for-each>
<br />
<xsl:for-each select="msxsl:node-set($xml)/value/y">
<xsl:value-of select="concat(., '#xa0;#xa0;')" />
</xsl:for-each>
<br />
<xsl:for-each select="msxsl:node-set($xml)/value/z">
<xsl:value-of select="concat(., '#xa0;#xa0;')" />
</xsl:for-each>
</p>
</xsl:template>
<xsl:template name="toXml">
<xsl:param name="values" />
<xsl:variable name="val1" select="substring-before(substring-after($values, ' '), ' ')" />
<xsl:variable name="next1" select="substring-after($values, $val1)" />
<xsl:variable name="val2" select="substring-before(substring-after($next1, ' '), ' ')" />
<xsl:variable name="next2" select="substring-after($next1, $val2)" />
<xsl:variable name="valtemp" select="substring-before(substring-after($next2, ' '), ' ')" />
<xsl:variable name="val3">
<xsl:choose>
<xsl:when test="string-length($valtemp) > 0">
<xsl:value-of select="$valtemp" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after($next2, ' ')" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<value>
<x><xsl:value-of select="$val1" /></x>
<y><xsl:value-of select="$val2" /></y>
<z><xsl:value-of select="$val3" /></z>
</value>
<xsl:variable name="next3" select="substring-after($next2, $val3)" />
<xsl:if test="string-length($next3) > 0">
<xsl:call-template name="toXml"><xsl:with-param name="values" select="$next3" /></xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Cheers
Bryan
|