Reputation: 197
There is a requirement where we need to use dynamic tag names in XML along with namespace. I am storing the tagname in a variable and trying to use with namespace.
%dw 1.0
%output application/XML encoding= "UTF-8"
%namespace opt vision.soap.ogc
%var tag = flowVars.tag
---
{
opt#tag : 'something'
}
The output I am expecting is to be the tagname I have stored in variable along with namespace, However the actual output is just appending the string 'tag' with namespace. Is there a way to do it?
Upvotes: 0
Views: 599
Reputation: 628
Please try this
%dw 1.0
%output application/XML encoding= "UTF-8"
%namespace opt vision.soap.ogc
%var tag = "a"
---
{
opt#"$(tag)" : 'something'
}
Output
<?xml version='1.0' encoding='UTF-8'?>
<opt:a xmlns:opt="vision.soap.ogc">something</opt:a>
Upvotes: 2