Empty Node Gotcha with the Business Rules Engine

I've been on a BizTalk 2006 R2 project where we are using the business rules engine to enrich some data coming from a call center.

The data comes in using the vendor's format and is mapped on the inbound port into a cannonical format to be used internally for processing. Because of the complexity of the vendor's schema, we used some inline XPATH statements in the map to transform the data.

When testing against the endpoint DB2 database, we discovered the database was failing to process the messages, even though everything appeared fine on the surface. After some investigation we discovered some hexidecimal characters in what were supposed to be empty nodes. The characters we saw were representative of a line break and a tab: #xD; and #xA;.

Tracing the steps back, we discovered this was appearing after the Business Rules Engine processed the document.

In a normal map, empty nodes are created as <empty>, but using XPATH we were deriving empty nodes that looked like <empty></empty>, and when this type of node went to the rules engine, it created line breaks.

We needed the empty nodes because the endpoint demanded all the nodes be present, so we had to make an adjustment to the XPATH statements to use something similar to:

<xsl:choose>
<xsl:when test="@@XPATH HERE@@">
<xsl:element name="Empty">
<xsl:value-of select="@@XPATH HERE@@"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="Empty"></xsl:element>
</xsl:otherwise>
</xsl:choose>


Where the choose/otherwise allowed us to create the type of empty node we were looking for.

So, if you find yourself extracting data from the rules engine and these unwanted characters appear, this is one way to solve it.

1 comment:

Anonymous said...

Nice post on extracting data, simple and too the point :), For simple stuff i use python to get or simplify data, data extraction can be a time consuming process but for other projects that include documents, the web, or files i tried http://www.extractingdata.com which worked great, they build quick custom screen scrapers, extracting data, and data parsing programs