AnsweredAssumed Answered

Use "Apply XSL Transformation" and the value of the complete XSL obtained from a context variable

Question asked by on Sep 13, 2016
Latest reply on Sep 21, 2016 by



I'm using CA API Gateway 9.0.


We need to use "Apply XSL Transformation" to apply a transformation with XSLT and XML, and get the resulting string.
The problem we have is that our XSLT is dynamic, so we wanted to use a context variable that will store the full value of XSLT, the context variable would like to use in "Apply XSL Transformation" (in "Configured in advance" -> "XSLT Stylesheet").
However, this policy does not allow the use of context variable full mode indicating the error: "Unable to save: The XSL is missing or invalid. Content is not allowed in prolog.". If only the first label set of XSLT and then the rest of XSLT with a context variable, does not return error, but it's like not obtain the value of the context variable.
How could perform the transformation using the XSLT full value that is stored in a variable context?


I've got a possible solution to my problem (although it may not be very optimal).


To understand the solution, I present my first goal:
I will create an API Rest in CA Gateway API. This API will make a request (SOAP) to a web service and return an XML where one of his label has the value of a XSLT and another label is the string of XML data to perform the transformation with the XSLT . The idea is to parse and get both XSLT and XML in context variables and use it with "Apply XSL Transformation". But the problem is I can not use the context variable with the string of XSLT within "Apply XSL Transformation".


I think the solution is:
Store the XSLT cache with "Store to Cache". Create a new API whose objective is to obtain the value of cache XSLT and return it in the response. Then "Apply XSL Transformation" put the url of the new API, where Stylesheet Location is set to "Monitor URL for lastest value". (In the url I pass a parameter to indicate the value of "Cache entry key" and the new API would get it).


Although not the most optimal, this is the only solution I could implement and, in principle, for my case work.
Do you know a more optimal solution or solution to use a context variable with the value of the XSLT in the transformation policy?