Xquery: Element to Attribute Mapping - remove empty attribute tags
794954Apr 1 2011 — edited Apr 7 2011Hi,
I have a requirement to map source schema xml elements to target schema xml element attributes
i have done it like below
<Spd minimumvalue = "{ xs:decimal(data($Test/*:A)) }"
maximumvalue = "{ xs:decimal(data($Test/*:B)) }"
averagevalue = "{ xs:decimal(data($Test/*:C)) }">
Where A,B,C are the source schema elements.
So once the transformation is done the output looks like this
<Spd mimimumvalue="1" maxmiumvalue="" averagevalue="3"/>
Now i got to remove the attribute which has null value.
the output should look like this
<Spd mimimumvalue="1" averagevalue="3"/>
I tried using exists function and implemented it. But then if i have more than 2/3 attributes in the outout xsd then i need to have many if conditions.
Is there any other alternative for this.
Please suggest. Appreciate your help.