Jeff Lynch [MVP]

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
BizTalk Server 2006: Conditional Output Node Magic!

I've decide to update and repost several BizTalk development tips after getting quite a few email questions on mapping. Please keep those questions coming!

One issue that always comes up when creating output nodes conditionally is how to determine the position or LineNumber of the nodes conditionally created. Normally, this is done by connecting the Iteration functoid (which uses the XSLT position() function to determine which input node is currently being processed) from the inbound looping structure to a field in the outbound schema. This will create a LineNumber value for each conditionally created node such as 1, 4, 7, 10, etc. Unfortunately, what we want is the position() of the output node being conditionally created so that our LineNumber values are in sequence such as 1, 2, 3, 4, etc.


Figure 1. Counting Line Items

Once again, the answer is to turn to the Scripting functoid and write some simple Inline C# code to accomplish this. One thing to note is that Inline scripts are also useful for declaring global variables that can be accessed from any number of scripts in your map. In the map shown above, I used this idea to create a System.Text.StringBuilder object called LineItem that would act as a text counter. Since the LineItem variable is global, it is only updated when the CurrentLine method is called.


Figure 2. Inline C#

This script uses the StringBuilder.Append method to add one character to the LineItem object each time an output node is conditionally created and uses the StringBuilder.Length property to return the LineNumber value in the outbound document.

I used to think that there were more elegant solutions available but after using this for over two years, I'm not so sure. This was a quick and easy way to solve the problem and shows just how flexible mapping can be in BizTalk Server 2006.

Technorati Tags: ,


Posted 08-11-2006 7:44 AM by Jeff Lynch
Filed under:

[Advertisement]

Comments

TrackBack wrote http://technorati.com/tag/biztalk
on 08-13-2006 5:54 PM
Leonid Ganeline wrote re: BizTalk Server 2006: Conditional Output Node Magic!
on 10-17-2006 3:52 PM

I've tried using the plain int Counter. It works fine. It's kinda redundant work with this text counter.

Thanks for your very useful articles! Very-very!

Ashwani wrote re: BizTalk Server 2006: Conditional Output Node Magic!
on 05-02-2007 3:57 PM

Awesome trick!! was facing same kind of issue in my mappings. A great help.

Jeff Lynch wrote re: BizTalk Server 2006: Conditional Output Node Magic!
on 05-02-2007 4:14 PM

Glad you found it useful.

Jeff

Jeff Lynch's XSLT Map "Trick" Question | keyongtech wrote Jeff Lynch's XSLT Map "Trick" Question | keyongtech
on 01-22-2009 2:55 AM

Pingback from  Jeff Lynch's XSLT Map "Trick" Question | keyongtech

Tramadol 180. wrote Tramadol.
on 05-28-2009 5:54 PM

Tramadol 93. Cheap tramadol. Taking tramadol while pregnant. Tramadol fda. Tramadol. Side effects tramadol.

Amoxicillin with no prescription. wrote Amoxicillin false positive for cocaine.
on 06-02-2009 7:40 PM

Amoxicillin. Amoxicillin and clavulanate potassium indications. Amoxicillin pregnancy. Amoxicillin no prescription. Amoxicillin soar throat. Amoxicillin yeast infection.

Buy soma watson brand 180 tablets. wrote Buy soma bloghoster.
on 06-05-2009 7:41 PM

Buy soma www scantips com buy soma online. Buy soma online. Buy soma watson brand online 150 tablets.

Hydrocodone. wrote Hydrocodone.
on 06-07-2009 8:08 PM

Hydrocodone. How long does hydrocodone stay in your system. Hydrocodone and side effects.

Vicodin overdose. wrote How to get vicodin without a perscription.
on 06-10-2009 7:45 PM

Vicodin interaction with metropolol. Vicodin. Vicodin detox. Buy vicodin.

Percocet 93-490 10 mg. wrote How long does percocet stay in your system.
on 06-12-2009 7:02 PM

Can you snort percocet. Buy percocet online. Percocet vs vicodon. Buy percocet online without office visit.

on 06-13-2009 10:27 AM

Adderall xr side effects. Adderall without a prescription. Adderall abuse. Ordering adderall. Adderall dosage instructions. Mexican pharmacies adderall. Adderall.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?