1<?xml version="1.0"?>
2
3<!-- string flipper -->
4
5<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
6
7  <xsl:output encoding="utf-8"/>
8
9<xsl:template name="textflipper">
10  <xsl:param name="instring" select='""'/>
11
12  <xsl:variable name="firstword" select='substring-before($instring," ")'/>
13
14  <xsl:choose>
15    <xsl:when test="string-length($firstword) > 0">
16      <xsl:call-template name="textflipper">
17        <xsl:with-param name="instring" select="substring($instring,string-length($firstword)+2)"/>
18      </xsl:call-template>
19      <xsl:text> </xsl:text>
20      <xsl:value-of select="$firstword"/>
21    </xsl:when>
22    <xsl:otherwise>
23      <xsl:value-of select="$instring"/>
24    </xsl:otherwise>
25  </xsl:choose>
26</xsl:template>
27
28<xsl:template match="text()">
29  <xsl:call-template name="textflipper">
30    <xsl:with-param name="instring" select="normalize-space(.)"/>
31  </xsl:call-template>
32</xsl:template>
33
34</xsl:stylesheet>
35
36