代码之家  ›  专栏  ›  技术社区  ›  BefittingTheorem

xsl:let raw html通过

  •  7
  • BefittingTheorem  · 技术社区  · 16 年前

    我正在做一个xsl转换。我正在转换的xml有一个包含html的节点。

    <xml>
        <text>
            <p><b>Hello</b><em>There</em></p>
        </text>
    </xml>
    

    应用转换:

    <xsl:template match="text">
        <div class="{name()} input">
            <xsl:value-of select="."/>
        </div>
    </xsl:template>
    

    我得到输出:

    <div class="text input">
        Hello There
    </div>
    

    但我希望html保持原样:

    <div class="text input">
        <p><b>Hello</b><em>There</em></p>
    </div>
    

    替代 . 随着 节点() 函数给出相同的结果。

    有没有一种方法可以让html通过未修改的转换?

    1 回复  |  直到 16 年前
        1
  •  11
  •   Gabriele Petrioli    16 年前

    看一看 xsl:copy-of

    它应该满足你的需要。

    <xsl:copy-of select="." />
    

    上面将选择整个当前节点,因此在您的情况下 <text> 本身也将包括在内。

    使用以下选项选择当前..

    <xsl:copy-of select="child::node()" />