How to convert JSON to XML using xslt?
Hi All, How can I convert the below JSON input request to XML format using XSLT I have tried with this XSLT from here https://www.quora.com/Is-there-a-way-to-convert-JSON-to-JSONX-without-using-IBM-DataPower but I didn't get desired output and it's throwing an error:"illegal character { at offset 0" in Datapower. My input request: { "SMS": [{ "to": "+966874939494", "Message": "<subject+message> " }, { "to": "+96687499490", "Message": "<subject+message>" } ] } My Expected Output: <?xml version="1.0" encoding="UTF-8"?> <sendReq> <MsgRqHdr> <RqUID>SR_123</RqUID> <SCId>SF12</SCId> <FuncId>36</FuncId> <UsrId>S12</UsrId> <Dt>2020-05-26T15:12:13</Dt> <Service>SMS</Service> </MsgRqHdr> <Body> <Com> <Specific> <Type>SMS</Type> </Specific> <CValue> <Char> <Name>ID</Name> </Char> <Value>966560329031</Value> </CValue> <CValue> <Char> <Name>Event</Name> </Char> <Value>subject&messagetext</Value> </CValue> <CValue> <Char> <Name>EventParam</Name> </Char> <Value>English</Value> </CValue> </Com> </Body> Can someone help on this please ? I never even tried Gateway script to give a try.3.1KViews0likes2CommentsXSLT to route single reuest to multiple endpoints based on URI
Hi, I want to route to specific endpoints if the incoming URI matches otherwise reject. I want to route to both of the above endpoints if the incoming URI matches with "/Location" or /Main.How should I write OR condition here ? Here is my xslt which I tried: Error: The below stylesheet is giving invalid URI error. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dp="http://www.datapower.com/extensions" xmlns:regexp="http://exslt.org/regular-expressions" extension-element-prefixes="dp regexp" exclude-result-prefixes="dp regexp"> <xsl:template match="/"> <xsl:variable name="uri_in" select="dp:variable('var://service/URI')"/> <xsl:variable name="serviceMapFileName" select="concat('local:///GATEWAY/Config/','service_map.xml')"/> <xsl:variable name="serviceMapTable" select="document($serviceMapFileName)" /> <dp:set-local-variable name="'var://local/valid_uri'" value="'N'" /> <xsl:for-each select="$serviceMapTable/servicelist/service"> <xsl:choose> <!-- Test if we have a match in the incoming URI and the service data map table. --> <xsl:when test="contains($uri_in, @Location)"> <xsl:message dp:priority="debug"> <xsl:value-of select="concat('name:', @name, ' id:', @Location, ' uri:', $uri_in)"/> </xsl:message> <dp:set-variable name="'var://service/routing-url'" value="concat('http://10.14.147.112:', @port,$uri_in)" /> <dp:set-variable name="'var://context/LoggingContext/service_name'" value="@name"/> <dp:set-local-variable name="'var://local/valid_uri'" value="'Y'" /> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:for-each> <xsl:if test="not(string(dp:local-variable('var://local/valid_uri')) = 'Y')"> <dp:reject>Not a valid incoming uri to XI50 !!!</dp:reject> </xsl:if> </xsl:template> </xsl:stylesheet My service_map.xml file in the backend : <servicelist> <service name="MPG_Retailer" id="/Location" port="4188"/> <service name="MPG_Partner" id="/Main" port="9988"/> </servicelist>1.1KViews0likes0Comments