Is it possible to do a variable substitution for a value for an XML that is enclosed in a JSON object?
My setup is:
{
"language": "en-US",
"demoXml": "<General><Name>"ABC"</Name><Address>"123 abc"</Address><Language>en-US</Language></General>"
}
I want to do variable substitution for the Language
key in the XML. Instead of hard-coding en-US
in the XML, I want to substitute it for the Language
variable. Is that possible?
2
Answers
At the JavaScript level, you could use a template literal:
At the XML level, you could use an entity reference.
See Can I use variables in XML files?
The JSON you’ve shown us isn’t well formed: the quotes around "ABC" and "123 abc" need to be either omitted, or escaped as
"
.If we ignore that problem, the following XSLT 3.0 transformation should do the job:
(Not tested).