This documentation is for WSO2 Enterprise Integrator version 6.1.1 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Double click on the API and click the following link in the Properties tab.
  2. Click Create & point to a new resource... link.
  3. Enter the following details to create the empty XSL file in which you enter the stylesheet, in the Registry.
  4. Double-click the stylesheet file in the Project Explorer, and add the following stylesheet as the content of the XSL file.

    Code Block
    languagexml
    titlediscountPayment.xsl
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:m0="http://services.samples" version="2.0" exclude-result-prefixes="m0 fn">
       <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
       <xsl:template match="/">
          <Payment>
             <xsl:for-each select="//order/lunch[contains(drinkName, 'Coffee')]">
                <discount>
                   <xsl:value-of select="drinkPrice" />
                </discount>
             </xsl:for-each>
          </Payment>
       </xsl:template>
    </xsl:stylesheet>

Pass the following XML payload using SOAP UI.

Info

You pass this payload into the XSLT mediator specifying a certain drinkName as a parameter to the style sheet. For example, the following payload passes the drinkName as 'Coffee'. The style sheet traverses through the incoming payload and finds the <lunch> elements, which contains 'Coffee' as drinkName. When it finds matching ectries, it adds the prices of those elements under a new <Payment> element. Therefore, when the message flow comes out of XSLT mediator, the payload changes the <Payment> entry, where it contains the drinkPrice values of matching elements.

Tip

You can get the URI of the REST API from the Management Console as shown below.

Image Added

Code Block
languagexml
<order>
<lunch>
<meal> Rice and Curry </meal>
<mealPrice> USD 10 </mealPrice>
<drinkName> Dark Coffee </drinkName>
<drinkPrice> USD 1.8 </drinkPrice>
</lunch>
<lunch>
<meal> Sandwiches </meal>
<mealPrice> USD 4 </mealPrice>
<drinkName> Milk Shake </drinkName>
<drinkPrice> USD 2.6 </drinkPrice>
</lunch>
<lunch>
<meal> Chicken Burger </meal>
<mealPrice> USD 5 </mealPrice>
<drinkName> Iced Coffee </drinkName>
<drinkPrice> USD 1.5 </drinkPrice>
</lunch>
<lunch>
<meal> Noodles </meal>
<mealPrice> USD 8 </mealPrice>
<drinkName> Bottled Water </drinkName>
<drinkPrice> USD 2.5 </drinkPrice>
</lunch>
</order>

...