BizTalk Server Tutorial

BizTalk Server Concepts and Common Errors

BizTalk 2013 Issue: White space cannot be stripped from input documents that have already been loaded. Provide the input document as an XmlReader instead.

I noted this issue with BizTalk 2013 map. There is a BizTalk 2010 Application which uses XSLT to strip off empty elements. This XSLT uses <xsl:strip-space elements=”*”/>  element.

Here is the XSLT which works fine in BizTalk 2010.

<xsl:stylesheet version=”1.0″
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”&gt;
<xsl:output omit-xml-declaration=”yes” indent=”yes”/>
<xsl:strip-space elements=”*”/>
<xsl:template match=”node()|@*”>
<xsl:copy>
<xsl:apply-templates select=”node()|@*”/>
</xsl:copy>
</xsl:template>
<xsl:template match=”*[not(*) and not(text()[normalize-space()]) and not(@*)]”/>
</xsl:stylesheet>

 However this XSLT will fail in 2013 with an error

“XSL transform error: Unable to write output instance to the following file. Exception has been thrown by the target of an invocation. White space cannot be stripped from input documents that have already been loaded. Provide the input document as an XmlReader instead.”

Reason for this is simple – BizTalk 2013 uses Compiled XSL Transform class.  Solution for this is to another XSLT which does not use xsl:strip-space element which is posted here.

<xsl:output omit-xml-declaration=”yes” 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>

Hope this helps.

– Shiv

June 1, 2014 - Posted by | Maps | , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: