如何在XSL中保留带标记的评论文本?

时间:2015-02-04 05:50:09

标签: html xslt

HTML:

<p>The effect of GCs on brown adipose growth and function is unknown and may contribute to the negative energy balance observed clinically.</p>
<!--<jid>JOE</jid><aid>140538</aid>-->
<p>Clinical cases of glucocorticoid (GC) excess are characterized by increased fat mass and obesity through the accumulation of white adipocytes.</p>

输出:

<para>The effect of GCs on brown adipose growth and function is unknown and may contribute to the negative energy balance observed clinically.</para>
&lt;jid&gt;JOE&lt;/jid&gt;&lt;aid&gt;140538&lt;/aid&gt;
<para>Clinical cases of glucocorticoid (GC) excess are characterized by increased fat mass and obesity through the accumulation of white adipocytes.</para>

XSL:

<xsl:template match="comment()">
  <xsl:value-of select="."/>
</xsl:template>

预期输出:

<para>The effect of GCs on brown adipose growth and function is unknown and may contribute to the negative energy balance observed clinically.</para>
<jid>JOE</jid><aid>140538</aid>
<para>Clinical cases of glucocorticoid (GC) excess are characterized by increased fat mass and obesity through the accumulation of white adipocytes.</para>

标签将作为实体更改。但是,我想在输出中保持相同的评论。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

使用disable-output-escaping

<xsl:template match="comment()">
  <xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>