I have adjusted my code as per your suggestion:
<!-- Camp Address --><xsl:if test="count(address) > 0"><h2>Address:</h2><xsl:for-each select="/data/people"> <p><xsl:apply-templates select="address" /></p></xsl:for-each></xsl:if><xsl:template match="address"><xsl:copy-of select=".//text()|.//*" /></xsl:template>
But it still produce a one-line output like before. On the other hand, I did some code-hunting on the net, and I found one code here, about 'word warp and text replace templates for XSLT', that solved my problem, albeit much more complicated then what I've seen before.This is my solution based on the help of the site:
<xsl:variable name="CR" select="'
;'" />...<!-- Camp Address --><xsl:if test="count(address) = 1"><h2>Address:</h2><p class="address"><xsl:call-template name="address"> <xsl:with-param name="textaddress" select="/data/people/address" /></xsl:call-template></p></xsl:if><xsl:template name="address"><xsl:param name="textaddress" /><xsl:variable name="textlength" select="string-length($textaddress)" /><xsl:if test="$textlength > 0"> <xsl:choose> <xsl:when test="contains($textaddress,$CR)"> <xsl:variable name="linebeforefirstbreak" select="substring-before($textaddress,$CR)" /> <xsl:variable name="lineafterfirstbreak" select="substring-after($textaddress,$CR)" /> <xsl:if test="string-length($linebeforefirstbreak) > 0"> <xsl:value-of select="$linebeforefirstbreak" /><br /> </xsl:if> <xsl:if test="string-length($lineafterfirstbreak) > 0"> <xsl:call-template name="address"> <xsl:with-param name="textaddress" select="$lineafterfirstbreak" /> </xsl:call-template> </xsl:if> </xsl:when> <xsl:otherwise> <xsl:value-of select="$textaddress" /> </xsl:otherwise> </xsl:choose></xsl:if></xsl:template>
What do you think of it? Basically, it manually printed out the line by breaking it by the Carriage Return characters in the text (something similar to what I thought of earlier, but been unable to comprehend such advanced task).