小编use*_*518的帖子

使用基于param的XSLT更新元素的文本

我正在尝试做一些似乎应该非常简单的事情,但是我无法让它发挥作用,我似乎无法找到任何不涉及许多无关紧要的事情的例子.我想将特定xml标记的文本内容更新为特定值(作为参数传入,将从ant使用此XSLT).一个简单的例子:

我想改造

<foo>
  <bar>
    baz
  </bar>
</foo>
Run Code Online (Sandbox Code Playgroud)

<foo>
    <bar>
        something different
    </bar>
</foo>
Run Code Online (Sandbox Code Playgroud)

这是我试过的样式表,它只产生标签,根本没有文字

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- identity transformation, to keep everything unchanged except for the stuff we want to change -->
    <!-- Whenever you match any node or any attribute -->
    <xsl:template match="node()|@*">
        <!-- Copy the current node -->
        <xsl:copy>
            <!-- Including any attributes it has and any child nodes -->
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <!-- change the text of the bar node, in the real template …
Run Code Online (Sandbox Code Playgroud)

xslt

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

xslt ×1