0

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

  • You haven't shown any XSLT code, nor have you explained whether you want to use XSLT to construct HTML or XML or plain text output. And with HTML or XML output I would expect any ampersand to be output as `&`. So consider to post minimal but complete samples of XSLT and input and desired output versus current output to allow us to reproduce the problem. – Martin Honnen Apr 07 '18 at 08:18
  • Hello, I am new to XSLT and unaware of full range of its possibilities. So I was asking if can use xslt in this situation. Since it is for only specific fields, I will probably have to stick with javascript to convert all special characters to its respective HTML. Thank You for your tip. – sandeep kairamkonda Apr 09 '18 at 12:38

1 Answers1

1

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.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Thank you for your input. You got it right. Sorry I did not provide the whole context. I figured it out what you suggested, but it still wouldn't work because of cast iron tool limitations. – sandeep kairamkonda Apr 17 '18 at 18:19