Friday, December 29, 2006

XML Notepad 2007

Microsoft released an editor for XML files, you can download it here.

Handy features include:
- Tree View synchronized with Node Text View for quick editing of node names and values.
- Incremental search (Ctrl+I) in both tree and text views, so as you type it navigates to matching nodes.
- Cut/copy/paste with full namespace support.
- Drag/drop support for easy manipulation of the tree, even across different instances of XML - Notepad and from the file system.
- Infinite undo/redo for all edit operations.
- In place popup multi-line editing of large text node values.
- Configurable fonts and colors via the options dialog.
- Full find/replace dialog with support for regex and XPath.
- Good performance on large XML documents, loading a 3mb document in about one second.
- Instant XML schema validation while you edit with errors and warnings shown in the task list window.
- Intellisense based on expected elements and attributes and enumerated simple type values.
- Support for custom editors for date, dateTime and time datatypes and other types like color.
- Handy nudge tool bar buttons for quick movement of nodes up and down the tree.
- Inplace HTML viewer for processing xml-stylesheet processing instructions.
- Built-in XML Diff tool. New features included in this version:
- Added keyboard accelerators for find again (F3) and reverse find (SHIFT+F3).
- Added support for loading IXmlBuilder and IXmlEditor implementations from different assemblies using new vs:assembly attribute.
- Made source code localizable by moving all error messages and dialog strings to .resx files.
- Added a default XSL transform.

New icons, a play on the Vista "Notepad" icons. Bug Fixes included in this version:
- Fixed install on Windows Vista machines using Windows Installer XML 3.0.
- Performance of expand node when validating.
- Fixed bug where changed schemas and transforms were not being re-loaded.
- Fixed spurious warnings about file being changed on disk.
- Fixed handling of very long text nodes.
- Fixed round trip of DTD content in tags.
- Fixed validation of elements with xsi:type attributes.
- Scroll bar not updating when node expanded/collapsed in some cases.
- Tree view needs horizontal scrollbar.
- When XML Notepad is minimized and file changes on disk, the file reload prompt is confusing. - Notepad should be restored first.
- XSL output window should pick up new xsl-transform based on input document.
- Fixed unhandled exception when closing a group of XML notepad windows.
- Added registration of "Edit" action for .xml file extension.
- Move source code to CodePlex.

Passed 70-235

Last week I passed the 70-235 exam. The day after that my collegue Bas de Gier passed as well.
Today 2 other collegues (Suresh Booms and Edwin Vriethof) took the exam as well and passed! Congratulations to all!

Besides project experience and many hours of self study, the BizTalk 2006 Recipes book by Apress helped me a lot to get at the level to pass the exam.

Friday, December 22, 2006

Interesting book coming up

Pro WCF: Practical Microsoft SOA Implementation
http://www.apress.com/book/bookDisplay.html?bID=10185

Friday, December 08, 2006

Requested registry access is not allowed

At the project I am working on I mainly use the Event Log to write progress statements from my orchestrations. On my develop-machine I ran into the error message 'Requested registry access is not allowed'.

It appeared that the user account under which the processing host runs, did not have enough authorisations to access the Event Log.

This can be fixed by giving that user account full control to a certain Registry Key.
To achieve this you must start the Registry Editor (regedit.exe) and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog. Right click on the node and click 'Permissions...'.
Next add the user account under which the processing host runs and give this user full control.
Close the dialog and the Registry Editor and finally restart the processing host.

You should now be able to write to the Event Log.

Monday, October 23, 2006

Failed to open BAM Excel workbook file: Old format or invalid type library

While trying to deploy a BAM workbook I created with Excel 2002, I received the following error message:


Since I was using an older version of Excel (2002) I thought that installing the 2003-version would fix my problem. Unfortunately it did not...

After some Googleing I found the blog from Don Glover, a Programming Writer for the BAM feature of BizTalk Server. He states that localization was the problem:

"BAM is made up of a number of separate components, SQL, web services, custom tools, and more. In order for each of the components to operate together effectively, they must all be set to the same locale/culture. In addition, your system and user locale/culture should match those set for BAM."

In my case it was enough to change my 'Regional options' from Dutch to English (US).

After firing the deployment command again, all went well.

Thanks Don!

Friday, July 07, 2006

BizTalk 2006 R2

Microsoft has introduced BizTalk 2006 R2. This product refresh includes a number of interesting features and enhancements to improve compatibility with Windows Vista and Microsoft Office 2007. Let’s have a look.

· Microsoft EDI Solution for BizTalk 2006
Microsoft’s EDI Solution for BizTalk adds full featured EDI capabilities to BizTalk 2006 with over 6000 schemas that include HIPAA, X12, and EDIFACT support.
Microsoft is highly committed to the B2B space with a dedicated team focusing on B2B messaging solutions integrated with the BizTalk Architecture. This EDI solution joins a group of solutions delivered with BizTalk 2006 including HIPAA, HL7, SWIFT, RosettaNet, cXML, and xCBL.
Microsoft’s goal is to drive Customer value by:
• Reducing TCO of managing B2B relationships
• Increase agility in establishing new B2B relationships
• Improve the timeliness and effectiveness of B2B decision making
Find more info at:
Microsoft EDI Solution Infosheet

· Microsoft RFID
The Microsoft RFID Infrastructure Services in BizTalk 2006 R2 provide device abstraction and manageability to RFID-based solutions. An integrated engine for rich data filtering, enrichment, and transformation allows for sophisticated applications for different automation scenarios. Application developers can also integrate with advance technologies such the as the Business Rules Engine, Windows Workflow Foundation, and Windows Communication Framework to create state-of-the-art business end-to-end systems.
Find more info at:
BizTalk 2006 R2 - RFID Support

· BizTalk Adapter for Windows Communication Foundation (WCF)
The BizTalk WCF (Windows Communication Foundation) Adapters align BizTalk with Microsoft’s Web Services strategy by exposing WCF channels to BizTalk processes.

The BizTalk R2 will contain the following WCF Adapters
· WsHttp Adapter – provides the WS-* standards support over HTTP transport. WCF-WsHttp adapter provides a transport/protocol stack implementation compatible with other next generation Web Services (platforms that also implement the same Web Services Architecture standards). It provides full access to SOAP security, reliability, and transaction features. This adapter uses the HTTP or HTTPS transport, and messages have a text or Message Transmission Optimization Mechanism (MTOM) encoding
· NetTcp Adapter – provides the WS-* standards support over TCP transport. WCF-NetTcp adapter provides efficient communication in a .NET to-.NET environment. It provides full access to SOAP security, reliability and transactions features. This adapter uses the TCP transport and messages have binary encoding.
· WCF-NetMsmq Adapter – provides queued messaging using MSMQ transport. WCF-NetMsmq adapter provides queued communication in a .NET-to-.NET environment. It uses MSMQ transport, and messages have a binary encoding
· WCF-BasicHttp – compatible with first generation web services. WCF-BasicHttp adapter provides a transport/protocol stack implementation compatible with first-generation Web Services. This adapter uses the HTTP or HTTPS transport, and messages have a text encoding.
· WCF-NetNamedPipe – provides cross process messaging using NamedPipes transport. WCF-NetNamedPipe adapter provides efficient cross-process communication in a .NET-to-.NET environment. This adapter provides full access to SOAP reliability and transaction features. The adapter uses the named pipe transport and messages have a binary encoding. This adapter cannot be used in cross-machine communication.
· WCF-Custom – provides customization for using WCF components (bindings, behaviors and binding elements). WCF-Custom adapter is used to enable usage of WCF extensibility components in BizTalk Server. The adapter enables complete flexibility of the WCF framework. It allows users to select and configure a WCF binding for the receive location/send port. It allows users to set the endpoint behaviors and security settings.
· WCF-CustomIsolated – provides customizations for using WCF components (bindings, behaviors and binding elements) and using the HTTP transport. WCF-CustomIsolated adapter is used to enable usage of WCF extensibility components in BizTalk Server, but out of proc in IIS. The adapter enables complete flexibility of the WCF framework. It allows users to select and configure a WCF binding for the receive location/send port. It allows users to set the endpoint behaviors and security settings. This adapter should only be used by transports than can be hosted in IIS.
Find more info at:
BizTalk WCF Adapters

· R2 Adapter Framework for .NET 3.0
The framework provides a common basis for building integration adapters that can be consumed by a variety of client applications (BizTalk, Office, .Net, etc) and usage scenarios via .NET 3.0 (formally WinFX). The Adapter Framework aligns the adapters strategy with Microsoft’s Web Services strategy by exposing integration adapters as WCF (Windows Communication Foundation) channels.
Find more info at:
R2 Adapter Framework for .NET 3.0

· R2 Line of Business (LOB) Adapters for .NET 3.0
The WCF LOB adapters deliver application, database and transport adapters to customers, implementing a common Adapter Framework, which in turn is built on top of the Windows Communication Framework (SAP, Siebel, Oracle DB, and TIBCO RV).
An adapter is fundamentally a module that bridges a client program and an external system, exposing well-defined and standardized interfaces over various programming models to the client program while internally mapping them to proprietary interfaces and protocols supported by the external system.
Application adapters provide an interface to Line-of-Business (LOB) systems like SAP, Siebel, Oracle Financials, PeopleSoft and JD Edwards. Database adapters provide an interface to database systems like Oracle, SQL Server, Sybase and DB2. Transport adapters provide an interface to transport protocols like HTTP and FTP and message-oriented middleware (MOM) like Tibco, Websphere MQ and MSMQ.
The R2 LOB Adapters deliver application, database and transport adapters by implementing a common Adapter Framework, which in turn is built on top of the Windows Communication Framework (WCF). Technically the R2 LOB adapters are exposed as WCF transport channels to clients, enabling connectivity, metadata exchange and business data exchange with external systems.
The R2 LOB adapters make line-of-business applications, databases and messaging platforms visible and interoperable with standard business processes, workflows and .NET applications They promote reusability and “plug ‘n play” across disparate applications. Different programming models can be built on top of the WCF adapter framework giving client programs the choice of programming models based on business needs. ADO.NET, WCF proxy programming and WCF channel (message-level) programming are a few programming models. The adapter framework eases adapter development in terms of providing simplified abstractions that handle common infrastructure and plumbing aspects of adapter building besides providing common runtime services. This enables adapter writers to focus on business logic required to interface with and surface external system functionality. It also empowers partners to develop custom adapters. The choice of WCF is essentially inline with Microsoft’s next generation communication framework optimized for the web services enabled world. It automatically web service enables external systems that are being adapted using R2 LOB adapters.

· BAM interceptors for Windows Workflow Foundation (WF) and WCF

How do I Participate in the BizTalk R2 TAP?
If you are interested in participating in the BTS 2006 R2 TAP please review the Program Description and submit a completed
BizTalk 2006 R2 Nomination Form and a TAP Program Manager will contact you. Once you have been accepted in to the TAP you will be able to download all R2 beta builds.
Nomination forms will be reviewed and BTS 2006 R2 TAP participants will be selected by July 31st, 2006.

What is a TAP (Technology Adoption Program)?
The BizTalk Server 2006 R2 Technology Adoption Program (TAP) is an “early adopter” program intended to validate the quality of the new features included in BTS 2006 R2 as well as give Customers and Partners early access to these features in order to validate functionality and quality prior to release.

In order to provide the best support possible during BTS 2006 R2 TAP we will be limiting the number of customers that we accept into this program so that we can maintain the highest possible quality for our participants.

· Program Participation
Registration for the BTS 2006 R2 TAP program is available by invitation of Microsoft account team members or by submitting a completed Nomination form that is available on the BizTalk Server 2006 R2 TAP website welcome page (also available in Downloads section)

Customers are then selected based on acceptance criteria as follows:
· A funded project that incorporates BizTalk Server 2006 R2 features
· The ability to commit the resources required to design and implement a solution using BizTalk Server 2006 R2 features
· The ability to release the solution to production 6 weeks prior to BizTalk Server 2006 R2 releases
· Provide high-quality feedback on BizTalk Server 2006 R2 features
· Ability to attend regularly scheduled calls (bi-weekly)
· Potential to participate in a Lab Engagement in Redmond, WA

All BizTalk Server 2006 customers are eligible to participate in this Technology Adoption Program and we are interested in your participation if you meet the criteria listed above.

Customers and Partners who enjoy being on the cutting edge of technology and who can benefit from these new features will find value in taking part in this TAP program.

· Program Structure
Nomination - Customers can nominate themselves on the BizTalk Server 2006 R2 Connect website by completing the TAP Nomination Form found on the welcome page (also available in Downloads section). The BTS R2 TAP Team will review all Nomination forms that we receive and will contact candidates as their Nominations are accepted/rejected.

Note that a Premier Support Agreement is required for participation on projects going into production.

Engagement - After being accepted into BizTalk Server 2006 R2 TAP, the TAP Team will work with TAP Participants to review architecture, test, and project plans. During this time most of the documentation and legal paperwork is signed. In addition, the TAP Participant’s expectations of the program are clearly documented and provides a means to clearly evaluate success.

Development / Test – Selected builds will be delivered to TAP Participants for testing and development. Issues brought by TAP Participants are handled by a trained Support Specialist and members of the Product Team. In some cases, developers or testers of a specific feature will work with a TAP Participants to ensure that technical issues are resolved accurately and timely.
Production Roll-Out – TAP Participants should plan on deploying their BTS 2006 R2 project to production no later than 6 weeks prior to the scheduled RTM date and be prepared to sign-off on production worthiness 2 weeks prior to RTM.

For customers that have a premier support agreement, support resources are available “7x24.”

Post-Mortem - When the program draws to a close, your feedback regarding the program in which you took part is critical to our ability to continually improve future programs.

Sunday, April 09, 2006

BizTalk's mapper allows drag and drop replace

I learned a little trick the other day about the mapper which I have never seen documented. It works for BizTalk 2004 and also 2006.

Have you ever had to change a functoid and gone thru the task of dragging the new functoid onto the grid and then reconnecting all of the lines, then having to check to make sure you got them all in order?

Well, what I realized quite by accident is that you can actually just drag the new functoid over the one you want to replace and all your links will maintain themselves. The old functoid will disappear and be replaced by the new one.

Of course there is a limitation when you have different maximum inputs, etc, but for the most part this works with everything else.

Thursday, March 16, 2006

You can evaluate dates using the
Cumulative Maximum Functoid

Dates you say? Stop the press! Hoist the mizenmast!

I had a situation where there was a node whose max occurs is unbounded and I needed to extract a single node from it to map to a destination node whose max occurs is one.

The problem was that I had to choose the node to map with the highest (newest) date:
<root>
<data>
<testdate>01-01-2000<testdate>
<testdata>a<testdata>
</data>
<data>
<testdate>01-01-2002<testdate>
<testdata>c<testdata>
</data>
<data>
<testdate>01-01-2001<testdate>
<testdata>b<testdata>
</data>
</root>

In the case above, I want the node with the highest <testval>, or 01-01-2002, therefore I want to map <testdata>c<testdata> to the destination node.

This can actually be done.

What I did was convert my date to ticks in a scripting functoid:

public string toTicks(string param1)
{
DateTime dt = DateTime.Parse(param1);
return dt.Ticks.ToString();
}

Afterwards I connected the scripting functoid to the cumulative max functoid.

Then I evaluate the output of the scripting functoid with the cumulative max functoid with an Equals functoid.

This should work for any set of repeating dates.

Monday, February 27, 2006

One or more instances of the orchestration still exist

Lately I tried to redeploy a BizTalk 2006 solution from Visual Studio 2005. Unfortunately I was confronted with the following error message “Could not change the bindings for orchestration '.', Version=1.0.0.0,Culture=neutral, PublicKeyToken=c380e04620d206e8' as one or more instances of the orchestration still exist”.
When I tried to Unenlist and delete the Orchestration from the BizTalk Administration tool, I received the same error.

I found out that I had a few suspended instances. These instances need to be terminated before you can undeploy/redeploy the orchestration.

Terminating instances can be done in several manners:
- the polite manner: by terminating the instances using the BizTalk Administration Tool
- the not so polite manner: by using a Stored Procedure to clean up the MessageBox

Removing instances using the BizTalk Administration Tool
In the BizTalk Administration Group click in the left pane on ‘BizTalk Group [Name of Computer/Name of Management database]’. In the right pane the ‘Group Overview’ appears. Click on the tab page ‘New query’ to create a query that searches for the suspended instances. In the ‘Query Expression’ grid the first Search field is already selected, namely ‘Search For’, also the ‘Equals’ operator is already filled in in the second field. All we have to do in the ‘Value’-field is search for suspended instances. And… lucky us: when we open the dropdown box we see that ‘Suspended Service Instances’ is one of the values we can choose! Next, we run the query by hitting the button with the label 'Run Query'. The grid ‘Query results’ now contains all suspended instances found. All we need to do is select all suspended instances, right click on the selection and choose ‘Terminate Instances’. The BizTalk Administration Tool asks for confirmation and removes the instances. When you rerun the query, the instances will be removed and the orchestration can be undeployed/redeployed. So far for the polite manner.

Removing instances using a Stored Procedure
The less polite manner to remove suspended instances is by running a Stored Procedure which will clean up the MessageBox. Attention: this is NOT a recommended procedure on production environments!
Open the SQL Server Management Studio and connect to the database server. In the left pane expand the server-node and the Databases-node. Next, click on the MessageBox-database (BizTalkMsgDb) and hit the ‘New Query’-button in the toolbar. In the right pane you can enter SQL commands. Since you selected the MessageBox-database in the left pane, the commands are executed against that database. Now type: 'exec bts_CleanupMsgbox 0' (without the quotes) and hit the ‘! Execute’-button in the toolbar. All suspended instances will now be removed. You can now undeploy/redeploy the orchestration.

New contributor on board

Hi all,

My name is Lex Hegt and from now on I will try to do regular postings on this blog as well. Just like Isaac and Randal I work for The Vision Web. On this blog I want to document/share problems and solutions I run into.

Please feel free to react on my postings!

Lex

Wednesday, February 08, 2006

XSLT performance when mapping large documents in BizTalk

Recently I had to map a document with many thousand rows. I could not split the document because before I could split it, the document’s nodes had to be sorted.

With such large files you generally test it using a small subset to avoid waiting for maps to complete, I built an XSLT which worked great, I thought.

When you use a select filter such as "not(KeyValue=preceding-sibling::row/ KeyValue)" you end up with a huge performance hit the larger the document gets. My map went from 2 seconds for 50 rows to 10 minutes for a few thousand.

How to improve performance when you have large XML files to map that you can’t split? Try using xsl:key instead, which builds an index of keys from which you can much more efficiently select.

Here is a sample XSLT that demonstrates how to use the xsl:key:


<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ns0="http://Conversion.schemas">

    <xsl:output method="xml" indent="no" />

    <xsl:key name="NumberKey" match="/*[local-name()='top' and namespace-uri()='http://biztalk/Conversion.schemas']/*[local-name()='row' and namespace-uri()='']"

        use="keyValue" />

    <xsl:template match="/">

        <ns0:Rows>

            <xsl:for-each select="/*[local-name()='top' and namespace-uri()='http://biztalk/Conversion.schemas']/*[local-name()='row' and namespace-uri()='' and generate-id(.) = generate-id(key('NumberKey', keyValue)[1])]">

                <xsl:variable name="current_Number" select="keyValue" />

                <Data>

                    <keyValue>

                        <xsl:value-of select="$current_Number" />

                    </keyValue>

                    <xsl:for-each select="//row[keyValue=$current_Number]">

                        <Part>

                            <PartID>

                                <xsl:value-of select="nr_data" />

                            </PartID>

                        </Part>

                    </xsl:for-each>

                </Data>

            </xsl:for-each>

        </ns0:Rows>

    </xsl:template>

</xsl:stylesheet>

Monday, January 23, 2006

Customizing the WSDL generated by the
‘BizTalk Webservice Publishing Wizard’

Exposing BizTalk interfaces as webservices is very easy using the ‘BizTalk Webservice Publishing Tool’. In almost all cases this tool generates a correct functioning web service which does not need any code modification.

However, there are situations where tweaking the code of the generated web service is necessary. Recently I needed two different BizTalk interfaces to expose the exact same WSDL. Because the two interfaces had different names for namespaces and artifacts, the generated webservices and WSDL were not the same.

You can solve this by using the SoapExtensionReflector. The BizTalk Webservice Publishing Wizard generates a class called ‘WsdlExtensions.cs’ for every webservice that is generated. By including this file in the generated VS.Net webservice project and adding the type in the 'soapExtensionReflectorTypes' section of the web.config (see header comments of
WsdlExtensions.cs), you’re able to control the generated WSDL for the webservice.

By default this file is generated with code for XML schema replacement in the WSDL, but you can use this to change other parts. For example, to override the SOAP service name, you can use:

public override void ReflectMethod()

{

    ProtocolReflector reflector = this.ReflectionContext;

    reflector.Service.Name = "MyNewServiceName";

}




After recompiling the web service the service name in the WSDL is changed to the new value.

Tuesday, January 10, 2006

Biztalk Host Manager 2004


Since Isaac is publishing post after post I thought it is time for me to also post something.

I developed a useful tool, called the Biztalk Host Manager (BTSHostManager), which we use in our development team to be able to quickly stop, start and especially restart BTS host instances.

Because all our developers found it a helpful tool we thought we would make it available for download.

Some features:
- It monitors background service state change of host instances (not by default, use options to enable) .
- It works for Biztalk 2004 and 2006.

- A seperate Biztalk 2006 version (compiled against 2.0 framework) will be available soon.
- This is not the final release version. We are still testing it, so please mail me any bugs you find.

Thursday, January 05, 2006

Mapping complex conditions in BizTalk with XSLT

Recently I found myself in a situation where I needed to evaluate a set of complex conditions that I could not use the Business Rules Engine for. The BizTalk mapper was able to achieve the conditionality by chaining a series of about 21 functoids together but this became very unmanageable especially since I was combining false statements to see if both were false, then returning a true to an “And” functoid (&) which evaluated another branch as true and passed a result to the node in the destination schema, you get the idea.

An easier way is to plug in XSLT. There are disadvantages to doing this, the main one being its maintainability and transparency but when faced with the daunting set of functoids described above, it looked a decent option.

The XSLT function that I used was the <xsl:choose> statement, inside the statement was a set of conditions which, if true, would return a value/values to the destination schema. In the last part of the statement was the <xsl:otherwise> condition which could set values if the conditions presented were not valid and you had a default you wanted to present in that event.

<xsl:variable name="var:vAnnuity" select="count(/*[local-name()='InternalSupport' and namespace-uri()='http://internal_support']/*[local-name()='LoanPartItems' and namespace-uri()='' and Method='Annuity'])" />

<xsl:variable name="var:vLinear" select="count(/*[local-name()='InternalSupport' and namespace-uri()='http://internal_support']/*[local-name()='LoanPartItems' and namespace-uri()='' and Method='Linear'])" />

<xsl:variable name="var:vTotalCount" select="count(/*[local-name()='InternalSupport' and namespace-uri()='http://internal_support']/*[local-name()='PartItems' and namespace-uri()=''])" />

<xsl:variable name="var:vHasValidEndowment" select="count(/*[local-name()='InternalSupport' and namespace-uri()='http://internal_support']/*[local-name()='LoanPartItems' and namespace-uri()='' and isValid ='true'])" />

<xsl:variable name="var:vHasValidId" select="count(/*[local-name()='InternalSupport' and namespace-uri()='http://internal_support']/*[local-name()='Ready' and HasValidId ='true'])" />

<xsl:element name="LeningSoort">

    <xsl:choose>

        <xsl:when test="$var:vAnnuity = $var:vTotalCount">

            <xsl:value-of select="1" />

        </xsl:when>

        <xsl:when test="$var:vLinear = $var:vTotalCount">

            <xsl:value-of select="2" />

        </xsl:when>

        <xsl:when test="($var:vHasValidEndowment = $var:vTotalCount) and ($var:vHasValidId = $var:vTotalCount)">

            <xsl:value-of select="3" />

        </xsl:when>

        <xsl:otherwise>

            <xsl:value-of select="4" />

        </xsl:otherwise>

    </xsl:choose>

</xsl:element>




Of course each specific case requires different XSLT, but this should provide a framework of how to do this within a functoid.

To set up the XSLT:

• Create XSLT similar to the one above which meets your needs
• Drop a scripting functoid on your map
• Connect the output parameter to the node you want to create
• Note: do no include any input parameters, the XSLT is setup already to look them up
• Open the scripting functoid’s, click the (…) inside “Configure Functoid Script”
• Under “Script type” choose “Inline XSLT”
• Paste your XSLT snippet in the text box

Tuesday, January 03, 2006

Remove empty nodes in BizTalk by using XSLT

If you have ever had a map which begins to look unmanageable with tons of value mappings or extra functoids to simply manage empty nodes you don’t want in your output then you should consider using an XSLT mapping to clean the document up for you.

This involves actually making 2 mappings instead of one, but the upside is faster development with a nominal performance cost. Instead of adding functoids, testing and retesting the output, let the mapper generate the empty nodded and then add an extra mapping step with the following XSLT embedded in it:


<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl="@@ YOUR NAMESPACE @@" version="1.0" xmlns:ns0="http://Stater.Isvcs.Iface.BO.GetLoanData.ElfV2">

    <xsl:output method="xml" indent="yes" />

    <xsl:template match="node()">

        <xsl:if test="count(descendant::text()[string-length(normalize-space(.))>0]|@*)">

            <xsl:copy>

                <xsl:apply-templates select="@*|node()" />

            </xsl:copy>

        </xsl:if>

    </xsl:template>

    <xsl:template match="@*">

        <xsl:copy />

    </xsl:template>

    <xsl:template match="text()">

        <xsl:value-of select="normalize-space(.)" />

    </xsl:template>

</xsl:stylesheet>




Save this snippet (or download it here) into your project (open the XSLT and change the namespace!) then create a new map. Make your source and destination schemas the same and in the map properties add your XSLT in the “Custom XSLT path” setting. Place the new map after the “dirty” map; the output should give you an XML document free of extra nodes and a map free of extra functoids.

Of course, if you are doing a strictly messaging based implementation then you are out of luck unless you chain ports together but within an orchestration using XSLT to remove empty nodes might work well for you.

Monday, January 02, 2006

Blogging about BizTalk? Then this is a
must have tool

I’ve found a tool recently that will make blogging about BizTalk easier. It’s been around for a while but if you are like me and have never heard of it before, CopySourceAsHtml is very useful.

If you have been in the situation of wanting to post a code or XSLT snippet onto your blog and found yourself writing HTML to make it look like it does in Visual Studio (or resort to screen shots) then fret no more, CopySourceAsHtml will take anything that you can open in VS (source code related) and convert it to HTML for you.

The tool is written by Colin Coller and can be downloaded on the CopySourceAsHtml homepage. In addition, Colin has a blog which updates progress on the tool. I read that a VS 2005 version is soon to be ready.

A couple of tips when using it:

  • After installing you should be able to open any C# source code page, highlight and right click a code snippet and see a new “Copy as HTML” item on the menu. But, if for example you want to copy XSLT, the item doesn’t show up. Use the edit menu instead.
  • When you copy something as HTML, under general, uncheck the “Number lines from:” box unless you really want them and also check the “Embed styles” box since blog tools/some browsers wont recognize the style sheet that gets created. Embeding the style makes it a simpler operation.