I am novice to Worklight. I was trying XSL transformation using:
transformation : { type : "xslFile", xslFile : "filtered.xsl", }
But for some reason if adapter fails to get response(status code != 200). Then it dumps the whole XSL in "errors". So is it possible to do transformation of the response only if status code == 200?
Thanks in advance.
There are two ways you can solve this issue 1) in the adapter JavaScript you can check the returned status code
function getStoriesFiltered() {
var input = {
method : 'get',
returnedContentType : 'xml',
path : 'rss/edition.rss',
transformation : {
type : 'xslFile',
xslFile : 'filtered.xsl'
}
};
var response = WL.Server.invokeHttp(input);
if (response.statusCode !== 200) {
return {'statusCode' : 'something went wrong'};
}
return response;
}
Or you can check it in the adapter xsl with a <xsl:if>
element depending on what is returned from your backend.