SOA BPEL/XSLT中如何遍历子节点并修改

问题描述

我需要知道如何在 Oracle SOA BPEL/XSLT 中修改以下内容 版本 12c。我在基于架构正确定义的变量中有以下 xsl

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book>
    <country>America</country>        
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>
      <cost>50</cost>
      <tax>50</tax>
    </price>
  </book>
  <book>
    <country>Aus</country>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>
      <cost>100</cost>
      <tax>10</tax>
    </price>
  </book>
</bookstore>

我需要更改 AUS 国家/地区的税率,如下所示

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>
  <book>
    <country>Aus</country>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>
      <cost>100</cost>
      <tax>50</tax>
    </price>
  </book>
</bookstore>

任何人都可以帮助我如何更改 oracle BPEl 或 XSLT 中的子字段值

解决方法

有很多方法可以做到这一点。但是,这是有效的。

  <xsl:template match="book[country = 'Aus']/price/tax">
    <xsl:copy>
      <xsl:value-of select="50"/>
    </xsl:copy>
  </xsl:template>

  <!-- Identity -->
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>