We have an input XML message that contains an encoded string in an element. The requirement is that we want to create an output XML message based on the length of that string. The length of the expected output element is limited to 10 characters and there is no limit on the number of times that element can repeat.
Example:
For example, in the below message you can see that we have an element EncodedString which contains a string with the length of 100 characters. And in the output, we want to have the EncodedStringValue element 10 times because of the maximum limit of 10 characters per element declaration. Please note that in the actual scenario the limit of characters we can have may vary from 10.
Input XML
<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns="http://ws.apache.org/ns/synapse">
<MessageID>365</MessageID>
<EncodedString>PHJvb3Q6SW52b2ljZSB4bWxuczpyb290PSJ1cm46b2FzaXM6bmFtZXM6c3BlY2lmaWNhdGlvbjp1Ymw6c2NoZW1hOnhzZDpJbnZv</EncodedString>
</Message>
Expected Output XML
<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns="http://ws.apache.org/ns/synapse">
<MessageID>365</MessageID>
<EncodedStringValue>PHJvb3Q6SW</EncodedStringValue>
<EncodedStringValue>52b2ljZSB4</EncodedStringValue>
<EncodedStringValue>bWxuczpyb2</EncodedStringValue>
<EncodedStringValue>90PSJ1cm46</EncodedStringValue>
<EncodedStringValue>b2FzaXM6bm</EncodedStringValue>
<EncodedStringValue>FtZXM6c3Bl</EncodedStringValue>
<EncodedStringValue>Y2lmaWNhdG</EncodedStringValue>
<EncodedStringValue>lvbjp1Ymw6</EncodedStringValue>
<EncodedStringValue>c2NoZW1hOn</EncodedStringValue>
<EncodedStringValue>hzZDpJbnZv</EncodedStringValue>
</Message>
Question?
Is it possible to achieve the above-mentioned requirement by using XSLT? IF yes then how?