Dashboard > WSO2 ESB > ... > Quality Assurance > Custom XSLT and XQuery Files
  WSO2 ESB Log in | Register   View a printable version of the current page.  
  Custom XSLT and XQuery Files
Added by Evanthika Amarasiri , last edited by Evanthika Amarasiri on Dec 21, 2007
Labels: 
(None)

 XSLT files used for the service Calculator

 Transforming the request

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
    xmlns:m0="http://calc.math.com"
    exclude-result-prefixes="m0 fn">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="/">
  <xsl:apply-templates select="//m0:add" />
</xsl:template>
 
<xsl:template match="m0:add">

<m:add xmlns:m="http://calc.math.com">
        <m:x><xsl:value-of select="m0:x * 100"/></m:x>
        <m:y><xsl:value-of select="m0:y * 100"/></m:y>       
</m:add>

</xsl:template>
</xsl:stylesheet>

 Transforming the response

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
    xmlns:m0="http://calc.math.com"
    exclude-result-prefixes="m0 fn">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="/">
  <xsl:apply-templates select="//m0:return" />
</xsl:template>
 
<xsl:template match="m0:return">

<m:addResponse xmlns:m="http://calc.math.com">
    <m:return><xsl:value-of select="m0:return * 100"/></m:return>
</m:addResponse>

</xsl:template>
</xsl:stylesheet>

 XQUERY files used for the service Calculator

 Transforming the request

 <x><![CDATA[
  declare namespace m0="http://calc.math.com";
  declare namespace xs="http://www.w3.org/2001/XMLSchema";
  declare variable $x as xs:integer external;
  declare variable $y as xs:integer external;

  <m0:add xmlns:m0="http://calc.math.com">
    <m0:x>{$x+$x*10}</m0:x>
    <m0:y>{$y+$y*10}</m0:y>    
  </m0:add>
]]></x>

 Transforming the response

 <x><![CDATA[
  declare namespace m0="http://calc.math.com";
  declare namespace xs="http://www.w3.org/2001/XMLSchema";
  declare variable $return as xs:integer external;

  <m0:addResponse xmlns:m="http://calc.math.com">
      <m0:return>{$return+$return*10}</m0:return>
  </m0:addResponse>      
]]></x>

Powered by a free Atlassian Confluence Open Source Project License granted to WSO2 Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators