My input data is json and output is xml. While mapping, I have set max length of few output fields and then when I convert the final document to XML String, I have selected encoded =true to escape special character. This could increase the length of my fields in xml as & will become & (4 more characters). I tried to again convert xml into node and selected encoding=UTF-8 and isXML=true but when I convert xml node to document, it does not escape special character and & becomes & again. I also tried using xslt but my xml structure is complex and I want to avoid it. Kindly provide any suggestion how can I escape special character and ensure that the length of field do not cross max length
an encodeded character is still considered a single character in my opinion.
So you should not worry about the max length w.r.t. encoded characters.
Length validation should be done before encoding or after decoding the special characters.