<xsl:for-each>
これは、プッシュ指向で、 、<xsl:if>
、またはself::
軸を必要としない単純なソリューションです。
この XSLT の場合:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="/*">
<document>
<xsl:apply-templates />
</document>
</xsl:template>
<xsl:template match="run/text()">
<para>
<xsl:value-of select="normalize-space()" />
</para>
</xsl:template>
</xsl:stylesheet>
...提供された XML に適用されます。
<par>
<run>Line one<break/>
Line two<break/>
</run>
<run>Another para of text<break/>
</run>
<run>3rd para but no break</run>
</par>
...必要な結果が生成されます。
<document>
<para>Line one</para>
<para>Line two</para>
<para>Another para of text</para>
<para>3rd para but no break</para>
</document>