Reputation: 45
I am using XSLT (1.0) to generate a Word Document using WordML. I have different tables and in one of the columns i need to add values separated by a carriage return.
I.e : instead of Lot1Lot2Lot3
, I need:
Lot1
Lot2
Lot3
I have searched all the related topics but I could not find any solution which could fix my issue. I have tried to use <w:br/>
or <xsl:text></xsl:text>
or the dec code 
/
 inside the <xsl:text>
but didn't work as I still see the result in the same line.
XML:
<Root>
<elemName>Test</elemName>
<elemDescription>Description</elemDescription>
<Items>
<Item1Flag>Y</Item1Flag>
<Item1Value>123213123</Item1Flag>
</Items>
<Items>
<Item1Flag>Y</Item1Flag>
<Item1Value>12223123</Item1Flag>
</Items>
<Items>
<Item1Flag>Y</Item1Flag>
<Item1Value>1232423</Item1Flag>
</Items>
</Root>
Stylesheet:
...
<w:t><xsl:call-template name="concatItems">
<xsl:with-param name="elements" select="Items[Item1Flag='Y']/Item1Value"/>
</xsl:call-template>
</w:t>
...
<!-- Template -->
<xsl:template name="concatItems">
<xsl:param name="elements"/>
<xsl:variable name="result">
<xsl:for-each select="$elements">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()"><w:br/></xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$result"/>
</xsl:template>
Upvotes: 0
Views: 116
Reputation: 45
Instead of using a template, I have called the for-each directly in the style sheet and use <w:br/>
.
<w:t>
<xsl:for-each select="Items[Item1Flag='Y']/Item1Value">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">
<w:br/>
</xsl:if>
</xsl:for-each>
</w:t>
Upvotes: 0