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: Changing the Outbound Namespace Prefix

I've decided to revise and repost this after seeing a question about this in the microsoft.public.biztalk.general newsgroup.

I've run into an interesting requirement to make sure my outbound xml file uses a specific namespace prefix. Since the BizTalk mapper always generates xml documents with the "ns0" prefix I wasn't quite sure how to accomplish this and posted my question to the microsoft.public.biztalk.general newsgroup. It turns out to be very straight-forward to accomplish.

Step 1: Map as you normally would using the mapper tool.

Step 2: Validate your map and open the xslt generated by BizTalk Server 2004 in your favorite text editor. This file can usually be found in the  "\temp\_mapdata" folder.

Step 3: Replace all instances of the namespace prefix "ns0" with the prefix you require (in my case "pidx") as shown below.

Step 4: Save this xml file as an .xslt file and include it (or add it) into your BizTalk project.

Step 5: Create a new map using the same source and destination schemas you used in Step 1 but use the external xslt you generated by setting the “Custom XSLT Path” property on your new map.

The results are shown in the figure below. No default namespace prefix ("ns0") here!

The link below explains how to use external xslt in your maps.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdk/htm/ebiz_prog_map_xrkh.asp

Take Away: There is always more than one way to skin a cat! In BTS2006 it may not be obvious how to do something a little unusual.

Technorati Tags: ,


Posted 08-09-2006 11:58 AM by Jeff Lynch
Filed under:

[Advertisement]

Comments

Bryan Corazza wrote re: BizTalk Server 2004 - Changing the Outbound Namespace Prefix
on 07-25-2005 9:17 PM
Jeff, That's slick. I've always handled those in custom classes or xslt outside of BizTalk. Very handy.
DonXML wrote re: BizTalk Server 2006: Changing the Outbound Namespace Prefix
on 08-09-2006 9:29 PM
I guess the bigger question is why would you care?  The prefix just a short cut to refer to the namespace, and developers should never care what prefix is used for an XML document.  Semantically, pidx:Invoice and ns0:Invoice are the same thing (assuming that both pidx and ns0 map to the same namespace).
Jeff Lynch wrote re: BizTalk Server 2006: Changing the Outbound Namespace Prefix
on 08-10-2006 9:47 AM
Don,

I agree technically, except that our trading partners REQUIRE that both the namespace and prefix exactly match what they expect. I suspect that their Unix based "integration" software is not altogether standards compliant when it comes to XML. When the trading partner in question is one of our largest customers doing millions in B2B transactions, we generally make every attempt to comply with their wishes. It still beats having to process custom EDI flat-file formats!

Thanks for reading and commenting!

Jeff
DonXML wrote re: BizTalk Server 2006: Changing the Outbound Namespace Prefix
on 08-10-2006 8:59 PM
Jeff, yep, I totally agree about doing what your trading partners require.  It is a shame that in 2006 some big shops still can't get simple XML right.  Sounds like they are using RegEx to parse the XML instead of a real XML Parser (it isn't like I haven't seen that before).
Richard wrote re: BizTalk Server 2006: Changing the Outbound Namespace Prefix
on 10-05-2007 7:33 PM
Thanks for this, i've spent all day trying to sort this. My issue stems from using infopath and sharepoint with biztalk. If you want to access the columns in an infopath form inside your sharepoint library, then creating an instance of a document from the XSD file creates a namespace pattern that must be in an incoming document or the column data will not appear in your sharepoint library. As my biztalk mapper creates my xml instance and I pass this into the library via the WSS adapter for sharepoint my namespace is always ns0. Sharepoint will accept the file and allow it to be opened in either forms services or info path client, but it will not show column data unless the namespace tag matches. This tag never matches if you have biztalk promoted properties in your xml schema. Thanks for the help!
InfoPath 2007 Scenarios With BizTalk Server 2006 R2 « Richard Seroter’s Architecture Musings wrote InfoPath 2007 Scenarios With BizTalk Server 2006 R2 « Richard Seroter’s Architecture Musings
on 12-05-2007 1:20 PM

Pingback from  InfoPath 2007 Scenarios With BizTalk Server 2006 R2 « Richard Seroter’s Architecture Musings

Scott Banwart’s Blog » Blog Archive » Sharepoint 2007 and XML Namespace Prefixes wrote Scott Banwart’s Blog » Blog Archive » Sharepoint 2007 and XML Namespace Prefixes
on 03-05-2008 9:06 AM
Pingback from Scott Banwart’s Blog » Blog Archive » Sharepoint 2007 and XML Namespace Prefixes
Pauline Johnson wrote re: BizTalk Server 2006: Changing the Outbound Namespace Prefix
on 03-14-2008 8:37 AM
Great solution but what if I do not want a prefix on each node of my output document?
Jeff Lynch wrote re: BizTalk Server 2006: Changing the Outbound Namespace Prefix
on 03-22-2008 3:56 PM

Pauline,

You can set the elementFormDefault attribute in your schema to "unqualified" to accomplish this.

Jeff

Tiago Oliveira wrote Replace namespace prefix pipeline component
on 11-27-2008 7:24 PM

  In some biztalk integrations with legacy systems, there are message specifications that requires

Why would they claim this? Namespace issue | keyongtech wrote Why would they claim this? Namespace issue | keyongtech
on 01-22-2009 4:12 AM

Pingback from  Why would they claim this? Namespace issue | keyongtech

Add a Comment

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