I have an existing data set that utilizes an integer to store multiple values; the legacy front end did a simple bitwise check (e.g. in C#: iValues & 16 == 16) to see if
XSLT is Turing-complete, see for example here or here, hence it can be done. But I have used XSLT only one or two times and can give no solution.
UPDATE
I just read a tutorial again and found a solution using the following fact. bitset(x, n) returns true, if the n-th bit of x is set, false otherwise.
bitset(x, n) := floor(x / 2^n) mod 2 == 1
The following XSLT
Number
Bit 3
Bit 2
Bit 1
Bit 0
1
0
1
0
1
0
1
0
will turn this XML
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
into a HTML document with a table showing the bits of the numbers.
Number | Bit 3 | Bit 2 | Bit 1 | Bit 0
---------------------------------------
0 | 0 | 0 | 0 | 0
1 | 0 | 0 | 0 | 1
2 | 0 | 0 | 1 | 0
3 | 0 | 0 | 1 | 1
4 | 0 | 1 | 0 | 0
5 | 0 | 1 | 0 | 1
6 | 0 | 1 | 1 | 0
7 | 0 | 1 | 1 | 1
8 | 1 | 0 | 0 | 0
9 | 1 | 0 | 0 | 1
10 | 1 | 0 | 1 | 0
11 | 1 | 0 | 1 | 1
12 | 1 | 1 | 0 | 0
13 | 1 | 1 | 0 | 1
14 | 1 | 1 | 1 | 0
15 | 1 | 1 | 1 | 1
This is neither elegant nor nice in any way and there are probably much simpler solution, but it works. And given that it is my first contact with XSLT, I am quite satisfied.