在apigee中使用Java Script更改策略序列的流程?

时间:2014-02-17 11:41:50

标签: apigee

如果我希望XSLTransform-1策略仅在URL具有" tennis"关键字在其中,如何在apigee中使用Java Script策略来实现?

网址:http://shaleen-test.apigee.net/v1/espn--api/tennis/athletes/296? apikey = rgnmd3naaw2qwv79fdtjgz77

政策:的XslTransform-1

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xsltransform-1">
    <DisplayName>XSLTransform-1</DisplayName>
    <FaultRules/>
    <Properties/>
    <Source>response</Source>
    <ResourceURL>xsl://xsltransform-1</ResourceURL>
    <Parameters ignoreUnresolvedVariables="true"/>
  <OutputVariable>abc</OutputVariable>
</XSL>

XSL文件:xsltransform-1

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">

 <xsl:template match="/"> 


  <html>
  <body>
    <h1>PROFILE OF PLAYERS</h1> 
    <h2> <xsl:value-of select="Root/sports/name" /> </h2>
    <h3>Report Details</h3>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>PLAYER ID</th>
        <th>FIRST NAME</th>
        <th>LAST NAME</th>
         <th>FULL NAME</th>
         <th>SHORT NAME</th>
      </tr>


      <xsl:for-each select="Root/sports/leagues/athletes">
      <tr>


        <td><xsl:value-of select="id" /></td>
        <td><xsl:value-of select="firstName" /></td> 
        <td><xsl:value-of select="lastName" /></td> 
        <td><xsl:value-of select="fullName" /></td> 
        <td><xsl:value-of select="shortName" /></td>



        <!--<td><xsl:value-of select="Root/sports/leagues/athletes/id" /></td>
        <td><xsl:value-of select="Root/sports/leagues/athletes/firstName" /></td> 
        <td><xsl:value-of select="Root/sports/leagues/athletes/lastName" /></td> 
        <td><xsl:value-of select="Root/sports/leagues/athletes/fullName" /></td> 
        <td><xsl:value-of select="Root/sports/leagues/athletes/shortName" /></td>-->
      </tr>
    </xsl:for-each>

    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

1 个答案:

答案 0 :(得分:0)

这可以通过条件执行XSLT来实现。您可以使用提取变量从请求路径中提取特定值。如果该变量的值为'tennis',则可以执行XSLT策略。

您是否有任何特定原因需要从Javascript控制流量?