Hi All,
How to handle the '&' in data, while using the docx from dynamic template.
I am already using the toHtml() and expression rule for escaping xml characters but after that also '&' is converting into '&'
and
if I don't use toHtml() and expression rule for escaping xml characters, then i got the error in dynamic template as"The entity name must immediately follow the '&' in the entity reference.".
Please suggest.
Discussion posts and replies are publicly visible
anupriyak0002 - You can try to replace "&" to "&" in the XML.
What is the code for your "expression rule for escaping xml characters"? toHtml() already converts "&" to "&", and if your expression rule does the same thing (which is my guess), you're probably ending up with "&" which would render in your resulting Word file as literally "&" when you don't intend it to.
My overall recommendation would be to make sure the expression rule handles all text correctly, and get rid of toHtml() -- however one way or the other, you might need to make sure you're not doing things twice.
Try creating an expression rule with following definition keeping "ri!value" as text input and pass your XML in this rule before calling the smart service:
trim( reduce( fn!substitute, ri!value, merge( { "&", "<", ">", char( 34 ), char( 39 ) }, { "&", "<", ">", """, "'" } ) ))
reduce( substitute(_, _, _), ri!text, merge( { "&", "<", ">", """", "'" }, { "&", "<", ">", """, "'" } )),