IBM Cast Iron studio unable to convert '&' to '&'

76 views Asked by At

Hello I am constructing a URI from two different strings coming from a source.

String1 = 12345&67890
String2 = 78326832

URI = /api?invoice=String1&supplier=String2

After using concat function available in studio, this is the final URI.

/api?invoice=12345&67890&supplier=78326832

(Get request fails because 67890 is taken as query)

Expected output is

/api?invoice=12345&67890&supplier=78326832

how do I achieve this, Can i use xslt to convert symbols to its HTML entity characters

1

There are 1 answers

1
Michael Kay On

Your expected output /api?invoice=12345&67890&supplier=78326832 is rather bizarre: there's no context where it makes sense to escape some ampersands (at the XML/HTML level) and leave others unescaped.

I think that what you really want is to use URI escaping (not XML escaping) for the first ampersand, that is you want /api?invoice=12345%2667890&supplier=78326832. If you're building the URI using XSLT 2.0 you can achieve this by passing the strings through encode-for-uri() before you concatenate them into the URI.

But you've given so little information about the context of your processing that it's hard to be sure exactly what you want.