如何在xsl 1.0中编写以下内容
<xsl:template match="bulletin1 | bulletin2" name="tokenize">
<xsl:param name="separator" select="','"/>
<xsl:for-each select="tokenize(.,$separator)">
<td align="center" style="padding: 0em 0em 0.1em; text-align: left; color: rgb(0, 0, 0); line-height: 1.3em; font-family: Georgia, Times, serif; font-size: 14px; font-weight: normal;" valign="top" width="30%">
• <xsl:value-of select="normalize-space(.)"/><br /></td>
</xsl:for-each>
</xsl:template>
答案 0 :(得分:0)
There are many solutions already out there. See comments! Exactly for your example:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template name="split" match="bulletin1 | bulletin2">
<xsl:param name="input" select="."/>
<xsl:param name="seperator" select="','"/>
<xsl:if test="string-length($input) > 0">
<td align="center" style="padding: 0em 0em 0.1em; text-align: left; color: rgb(0, 0, 0); line-height: 1.3em; font-family: Georgia, Times, serif; font-size: 14px; font-weight: normal;" valign="top" width="30%">
• <xsl:value-of select="substring-before(concat(normalize-space($input), $seperator), $seperator)"/><br /></td>
<xsl:call-template name="split">
<xsl:with-param name="input" select="substring-after($input, $seperator)"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
for sample-xml like:
<document>
<bulletin1>abc,def</bulletin1>
<bulletin2>1,2,3</bulletin2>
</document>