Windows Live Agents: XML Normalization II


In my last WLA post I talked about normalizing xmls to be able to handle complex structures. We learned how splitting the fields in multiple xmls we could do simple querys and get the wanted data.

But what about after having this data? How can we cross it to obtain some manageable info?

The solution I use is very simple if you know the existence of the MakeHash() function.

This function accepts one or two parameters and (among other things), if you call it with the same list object in both parameters, it will cycle through all the list elements and remove repeated ones. For example, if we have a list called MYLIST with the values 1,1,2,3, MakeHash(MYLIST,MYLIST) will return a list with the values 1,2,3.

In this example, we have two simple functions that retrieve values using simple querys:

GetIDsFromTable1(1) returns 1,2,3

GetIDsFromTable2(1) returns 1,3,4

We can easily build a function that returns both results without repeating values:

function GetIDsFromTables(REGISTERID)
RESULTS = ""
IDS = GetIDsFromTable1(REGISTERID)
for value ID in IDS
insert last in RESULTS ID
IDS = GetIDsFromTable2(REGISTERID)
for value ID in IDS
insert last in RESULTS ID
RESULTS = MakeHash(RESULTS,RESULTS)
return RESULTS

So, calling GetIDsFromTables(1) will return 1,2,3,4 :)

Windows Live Agents: XML Normalization II published @ . Author: