Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Posts Tagged "xml"

BizTalk mapping patterns: Remove Empty Nodes

Dan Field

Some recipients of BizTalk messages (such as the SQL Server adapter and some SOAP web services) will run into problems if there’s an empty node in the message, such as:
In this example, we’d really just want to have Keeper in there and get rid of the rest (to avoid other services from throwing exceptions on those empty/valueless nodes).
There are mapping patterns to address this, generally using a Value Mapping functoid with a Logical functoid. For example, you might have a Logical Existence or Logical String as the first parameter (see this blog for an example) to prevent an empty value from being mapped to the destinatino node. With a Table Looping functoid, you can achieve this for an entire table by having the first column be gated (see the Remarks section of the Table Looping refernece: MSDN).  This technique works well,…

Using XSLT in .Net

jraymunt

So you’ve finished writing your new XSLT file using your favorite XML/XSLT editing tool. Great. Now for the next problem, you’ve been given the task to transform thousands of XML documents using your new XSLT file. Great… There’s no way we can transform all of these documents by hand. At this point we should be thinking about automating this process in the fastest and most efficient way possible. This scenario may sound familiar to some of us. Luckily, .Net provides us with such options.
For this example we’ll be serializing an XML file and transforming it using .Net’s XSLT processor. The process is very simple, and requires very little code.

Load the XML File into memory using the XmlReader class.
var reader = XmlReader.Create(xmlFileLocation);

Create a StreamWriter object which will be used to write the transformation to a file.
var textWriter = new StreamWriter(outputFileLocation);

Create an…

\\\