How can I turn elements that specify a flag in a bitmask to a bitmask? I have the following XML Schema:
How can I for example turn this XML
<Flags>
<Flag>1</Flag>
<Flag>3</Flag>
</Flags>
Into this output XML using XSLT?
<Bitmask>10</Bitmask>
(10 = 1010 binary - bit 1 and 3 are set)
In a procedual programming language I would simply do something like this:
var bitmask = 0;
foreach(var falg in flags) {
bitmask = bitmask + pow(2,flag);
}
But this is not possible in xslt because the xsl:variable is static. Is there another approach, or how can this be done?