使用 wordml 在 XSLT 中添加回车符



我正在使用XSLT(1.0(通过WordML生成Word文档。我有不同的表,在其中一列中,我需要添加由回车符分隔的值。

即:我需要的不是Lot1Lot2Lot3,而是:

Lot1
Lot2
Lot3

我已经搜索了所有相关主题,但找不到任何可以解决我问题的解决方案。我尝试在<xsl:text>中使用<w:br/><xsl:text></xsl:text>或十进制代码&#10/&#13,但没有奏效,因为我仍然在同一行中看到结果。

.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>

样式表:

...
<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>

我没有使用模板,而是直接在样式表中调用for-each并使用<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> 

最新更新