Link to home
Start Free TrialLog in
Avatar of rdytmire
rdytmire

asked on

How to AND two hex numbers in XSLT and test the result?

I'd like to select a set of nodes based on an ItemState bitmask  this number is an integer and I need to test if this integer has certain bits set.

My XPath would look something like /root/itemRecord[ItemStateMask AND 0x40000000 == 0x40000000]

If applied against this document, both records should be returned.
<root>
  <itemRecord>
    <ItemStateMask>1073741824</ItemStateMask>
  </itemRecord>
  <itemRecord>
    <ItemStateMask>1073741826</ItemStateMask>
  </itemRecord>
</root>

What is the correct syntax to do a select like this?
Avatar of kmartin7
kmartin7
Flag of United States of America image

Just to help my confusion, how/why does the second value "1073741826" get returned as a matching value?
Avatar of rdytmire
rdytmire

ASKER

Ok..the ItemStateMask value is a Hex value presented as an int.

So:


1073741826 = 0x40000002
1073741824 = 0x40000000

I want anything that can mask with: 0x40000000

So... 0x40000002 & 0x40000000 = 0x40000000 so it should match.

My issue is how to do the & operation on two bit masked values inside a XPATH query...


ASKER CERTIFIED SOLUTION
Avatar of - -
- -
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well...that sucks...gonna have to work this a bit...