[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Create a bit mask ?

Subject: Create a bit mask ?
From: Saba <saba_emailme-xslt@xxxxxxxxx>
Date: Tue, 9 Nov 2004 13:54:09 -0800 (PST)
bit mask
I need to convert a number of elements into a single
element with a bit mask as its value. Here is a some
sample source XML snippet:

<Rule Name="Rule1">
	<Tag Name="Tag1"/>
	<Tag Name="Tag2"/>
</Rule>
<Rule Name="Rule2">
	<Tag Name="Tag1"/>
	<Tag Name="Tag3"/>
</Rule>

<Tags>
	<Tag Name="Tag1">
		<Id>0</Id>
	</Tag>
	<Tag Name="Tag2">
		<Id>1</Id>
	</Tag>
	<Tag Name="Tag3">
		<Id>2</Id>
	</Tag>
</Tags>


I need to convert this into:

<Rule Name="Rule1">
	<TagMap>-4</TagMap>
</Rule>
<Rule Name="Rule2">
	<TagMap>-6</TagMap>
</Rule>

The value in TagMap is a 32 bit bit-mask which
contains a 0 if the Tag applies to the rule and a 1 if
it does not. The bit position for a tag is determined
by the Tag's ID value (Starting from the right most
bit)

So the map for Rule1 is -4 which is
11111111111111111111111111111100 in binary. The two
zeros correspond to Tag1 (Id 0) and Tag2 (Id 1).
Map value for Rule2 is -6 which is 
11111111111111111111111111111010 corresponding to Tag1
(Id 0) and Tag3 (Id 2).

Can anyone help with this? I feel handicapped without
a processing loop construct and being able to redefine
the value of a variable! I am limited to using XSLT
1.0

Thanks in advance.
-Saba

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.