【发布时间】:2017-05-26 14:59:22
【问题描述】:
有这个 xml sn-p:
<paragraph><bold>Test</bold> - This <italic>word</italic> should be <underline>underlined</underline> according to xml</paragraph>
如何在将使用过的标签替换为 HTML 中使用的标签时将此“段落”输出到 HTML 中?
我试过这个 XSLT sn-p 但它不会打印嵌套标签之外的文本,只打印粗体、斜体和下划线之间的文本。
<xsl:template match="p:paragraph">
<xsl:for-each select="./*">
<xsl:choose>
<xsl:when test="name(.)='bold'">
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:when test="name(.)='italic'">
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:when test="name(.)='underlined'">
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./text()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match="bold">
<p><b><xsl:value-of select="current()"/></b></p>
</xsl:template>
<xsl:template match="italic">
<p><i><xsl:value-of select="current()"/></i></p>
</xsl:template>
<xsl:template match="underline">
<p><u><xsl:value-of select="current()"/></u></p>
</xsl:template>
我怎样才能使模板按预期输出?
提前致谢
【问题讨论】: