I’m trying to use the Apigee Edge environment to do some XSL transforms. I have an XML file coming in as a request, and I’ve added an XSL Transform policy in the PostFlow of the Proxy Endpoint I built. Unfortunately, no matter what I write in the XSLT file, the XML is not transformed. I’ve read the help page on Apigee’s site regarding the policy, but there are no tips about how to use the develop and trace tools specifically, so I’m sure there must be something I’m missing.
Here is the the XML request:
<STOCKQUOTE ROWCOUNT="1"> <RESULT> <ROW> <ASK>54.280</ASK> <BID>54.270</BID> <CHANGE>-0.360</CHANGE> <DIVIDEND>0.160</DIVIDEND> <EPS>1.725</EPS> <HIGH>54.390</HIGH> <LASTPRICE>54.260</LASTPRICE> <LOW>53.680</LOW> <OPEN>53.870</OPEN> <PCHANGE>-0.659</PCHANGE> <PE>14.000</PE> <PREVIOUSCLOSE>54.620</PREVIOUSCLOSE> <YEARHIGH>54.750</YEARHIGH> <YEARLOW>35.385</YEARLOW> <YIELD>1.172</YIELD> </ROW> </RESULT> <STATUS>No Error</STATUS> <STATUSCODE>0</STATUSCODE> </STOCKQUOTE>
Here is the XSL Transform (written in the Apigee client):
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="ROW/*[not(name()='LASTPRICE')]"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="LASTPRICE"> <TRADE> <xsl:value-of select="."/> </TRADE> </xsl:template> </xsl:stylesheet>
In Visual Studio, this transform simply changes the attribute <LASTPRICE></LASTPRICE> to <TRADE></TRADE>.
Here is the response from the trace tool (the LASTPRICE attribute has not been changed):
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE STOCKQUOTE PUBLIC '-//W3C//DTD StockQuote 1.5//EN' 'http://www.irxml.org/dtd/stockquote_1.5.dtd'><STOCKQUOTE ROWCOUNT='1'><RESULT><ROW><ASK>54.230</ASK><BID>54.220</BID><CHANGE>-0.394</CHANGE><DIVIDEND>0.160</DIVIDEND><EPS>1.725</EPS><HIGH>54.390</HIGH><LASTPRICE>54.226</LASTPRICE>.....
Solved! Go to Solution.
Hi @Therese Marchant, please try using this sample proxy (attached) that I have created. You can import it as an API Bundle
I sent the following xml request
<STOCKQUOTE ROWCOUNT="1"> <RESULT> <ROW> <ASK>54.280</ASK> <BID>54.270</BID> <CHANGE>-0.360</CHANGE> <DIVIDEND>0.160</DIVIDEND> <EPS>1.725</EPS> <HIGH>54.390</HIGH> <LASTPRICE>54.260</LASTPRICE> <LOW>53.680</LOW> <OPEN>53.870</OPEN> <PCHANGE>-0.659</PCHANGE> <PE>14.000</PE> <PREVIOUSCLOSE>54.620</PREVIOUSCLOSE> <YEARHIGH>54.750</YEARHIGH> <YEARLOW>35.385</YEARLOW> <YIELD>1.172</YIELD> </ROW> </RESULT> <STATUS>No Error</STATUS> <STATUSCODE>0</STATUSCODE> </STOCKQUOTE>
and received the following xml response.
<?xml version="1.0" encoding="UTF-8"?> <STOCKQUOTE ROWCOUNT="1"> <RESULT> <ROW> <ASK>54.280</ASK> <BID>54.270</BID> <CHANGE>-0.360</CHANGE> <DIVIDEND>0.160</DIVIDEND> <EPS>1.725</EPS> <HIGH>54.390</HIGH> <TRADE>54.260</TRADE> <LOW>53.680</LOW> <OPEN>53.870</OPEN> <PCHANGE>-0.659</PCHANGE> <PE>14.000</PE> <PREVIOUSCLOSE>54.620</PREVIOUSCLOSE> <YEARHIGH>54.750</YEARHIGH> <YEARLOW>35.385</YEARLOW> <YIELD>1.172</YIELD> </ROW> </RESULT> <STATUS>No Error</STATUS> <STATUSCODE>0</STATUSCODE> </STOCKQUOTE>
Let me know if this does what you want.
@Therese Marchant can you post a sample xml request file and your xslt file? Also curious to see what you see on the output of the trace tool.
Question has been edited!
I am pretty new to apigee environment and after reading this post still don't know how to upload an xml file as a request and get a transformed xml in response. I imported the API bundle that you provided and tried to import an xml using trace tool, however, I was not successful.
Thanks for your help.
Hi @Therese Marchant, please try using this sample proxy (attached) that I have created. You can import it as an API Bundle
I sent the following xml request
<STOCKQUOTE ROWCOUNT="1"> <RESULT> <ROW> <ASK>54.280</ASK> <BID>54.270</BID> <CHANGE>-0.360</CHANGE> <DIVIDEND>0.160</DIVIDEND> <EPS>1.725</EPS> <HIGH>54.390</HIGH> <LASTPRICE>54.260</LASTPRICE> <LOW>53.680</LOW> <OPEN>53.870</OPEN> <PCHANGE>-0.659</PCHANGE> <PE>14.000</PE> <PREVIOUSCLOSE>54.620</PREVIOUSCLOSE> <YEARHIGH>54.750</YEARHIGH> <YEARLOW>35.385</YEARLOW> <YIELD>1.172</YIELD> </ROW> </RESULT> <STATUS>No Error</STATUS> <STATUSCODE>0</STATUSCODE> </STOCKQUOTE>
and received the following xml response.
<?xml version="1.0" encoding="UTF-8"?> <STOCKQUOTE ROWCOUNT="1"> <RESULT> <ROW> <ASK>54.280</ASK> <BID>54.270</BID> <CHANGE>-0.360</CHANGE> <DIVIDEND>0.160</DIVIDEND> <EPS>1.725</EPS> <HIGH>54.390</HIGH> <TRADE>54.260</TRADE> <LOW>53.680</LOW> <OPEN>53.870</OPEN> <PCHANGE>-0.659</PCHANGE> <PE>14.000</PE> <PREVIOUSCLOSE>54.620</PREVIOUSCLOSE> <YEARHIGH>54.750</YEARHIGH> <YEARLOW>35.385</YEARLOW> <YIELD>1.172</YIELD> </ROW> </RESULT> <STATUS>No Error</STATUS> <STATUSCODE>0</STATUSCODE> </STOCKQUOTE>
Let me know if this does what you want.
Are you using our virtual cloud (on-premises) solution, or an enterprise organization, or a developer (free) organization?
Some things to keep in mind: