Promoting an element value to root node attribute - how?

Greetings,

Can someone suggest the best way to create the sample output message from the sample input message? Both are shown below. The input message has a lot of "employee" elements. Only one will have a "title" attribute of "boss". I need to create an output message "bossname" attribute on the root element and assign it the value of the input "employee" element that has the "boss" designation in the input message. I also need to eliminate the "boss" element when creating the output message.

I don't know how to get started with this. Should I be doing this within BizTalk or outside BizTalk? Is there a functoid I can use? Any suggestion of a good practice would be appreciated.


Input message:

<root>
<employee title="worker">James</employee>
<employee title="boss">Suzi</employee>
<employee title="worker">Charlie</employee>
</root>

Output message:

<root bossname="Suzi">
<employee title="worker">James</employee>
<employee title="worker">Charlie</employee>
</root>


Thanks,
BCB


[1627 byte] By [BlackCatBone] at [2008-1-9]
# 1

Hi,

If you are using the BizTalk mapper, you could look at the Value Mapping functoids and using the Looping functoid for conditional looping. Both of thse are in the advanced functoids section, and there are samples in the docs.

Outside BizTalk, i would look at using an XSL transform. Visual Studio 2005 has powerful XSLT intellisense and debugging, so it should be fairly easy to solve it that way.

As to whether you should be doing it in BizTalk or not, if you are using BizTalk already, the mapper is a good place to do the transformation. If you are not already using BizTalk , it's probably an overkill to use it just to transform XML documents.

Regards,

Alan

AlanSmithMVP at 2007-10-2 > top of Msdn Tech,BizTalk Server,BizTalk R2 General...