I am working on creating REST API
's in IBM API
connect. our requirement is to get the backend URL's from a property file which is present on the datapower
gateway server and then invoke the back-end service in the API's.
In API assembly I have written the XSLT
code to open the file and read the data from the file, but the xslt
is returning an empty response.
XSLT
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:func="http://exslt.org/functions"
xmlns:apim="http://www.ibm.com/apimanagement"
extension-element-prefixes="dp func apim"
exclude-result-prefixes="dp func apim">
<!-- Cotains the APIM functions -->
<xsl:import href="local:///isp/policy/apim.custom.xsl"/>
<xsl:template match="/">
<xsl:variable name="FileContent">
<dp:url-open target="'https://localhost:9090/dp'" response="xml" data-type="filename">local:///policy/propertyfiles/URLs.xml
</dp:url-open>
</xsl:variable>
<xsl:variable name="policy-props" select="apim:policyProperties()"/>
<xsl:variable name="catalog" select="apim:getContext('env.path')"/>
<outputXml>
<data><xsl:copy-of select="$FileContent" /></data>
<catalog><xsl:value-of select="$catalog" /></catalog>
<xsl:for-each select="$FileContent/catalogs/catalog">
<xsl:variable name="ReferencedID" select="@name"/>
<xsl:choose>
<xsl:when test="$ReferencedID = $catalog">
<backend_url><xsl:value-of select="$FileContent/response/catalogs/catalog/backend_url" /></backend_url>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</outputXml>
</xsl:template>
</xsl:stylesheet>
I am expecting to see the data from the file in the xslt
response . But I see the below response which is missing the data from the file.
Body:
<?xml version="1.0" encoding="UTF-8"?>
<outputXml>
<data/>
<catalog>sb</catalog>
</outputXml>