【发布时间】:2019-01-29 08:54:47
【问题描述】:
我需要将具有以下属性的所有标签转换为代码块标签
<span style="font-family:courier new,courier,monospace;">
<span class="mt-font-courier-new">
【问题讨论】:
标签: html xml attributes xslt-1.0
我需要将具有以下属性的所有标签转换为代码块标签
<span style="font-family:courier new,courier,monospace;">
<span class="mt-font-courier-new">
【问题讨论】:
标签: html xml attributes xslt-1.0
您需要定义一个特定的模板来处理这种情况:
<xsl:apply templates="*" />
<xsl:template match="span[contains(@style, 'courier')]|span[contains(@style, 'courier')]|span[contains(@class, 'courier')]">
<codeblock>
<xsl:apply-templates />
</codeblock>
</xsl:template>
您当然可以使用精确值定义选择器,或者通过包含使用模糊匹配来获取这些标签。
【讨论】:
现在它工作正常..感谢您的回复:)
通过使用此代码:
<xsl:template match="span[contains(@style, 'font-family:courier new,courier,monospace;')]|span[contains(@class, 'mt-font-courier-new')]">
<codeblock>
<xsl:apply-templates />
</codeblock>
</xsl:template>
【讨论】: