Vikram Srinivasan
Vikram Srinivasan

Reputation: 187

How to Traverse to the Child Node and modify it in SOA BPEL/XSLT

I need to know how i can Modify the below in Oracle SOA BPEL/XSLT Version12c. I have the below xsl in a properly defined variable based on the schema

<?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>

I need to change the tax rate just for country AUS like below

<?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>

Can anyone help me on how to just change a child field value in oracle BPEl or XSLT

Upvotes: 0

Views: 167

Answers (1)

John Ernst
John Ernst

Reputation: 1235

There are many ways to do this. But, this works.

  <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>

Upvotes: 1

Related Questions