如何在某些情况下插入标签

时间:2019-04-22 06:54:54

标签: xslt-1.0 xslt-2.0

我的xml输入如下:-

<CatchWordPara>&#8212; aaaaa &#8212; <HiddenData>+</HiddenData>bbbbb &#8212; ccccc<HiddenData> &#8212; + ddddd &#8212; #eeeee#</HiddenData> &#8212; <HiddenData>#</HiddenData>fffff</CatchWordPara>

我的必需输出是:-

<SNItalic>aaaaa</SNItalic>
<CR>bbbbb &#8212; ccccc</CR>
<CR>ddddd &#8212; eeeee &#8212; fffff</CR>

使用以下代码:-

<xsl:template match="ShortNoteContinuePara">
<xsl:for-each select="for $s in CatchWordPara/tokenize(., '&#8212;') return normalize-space($s)">
<xsl:element name="SNItalic">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:template>

0 个答案:

没有答案