Remove Empty Nodes XSL

Added here for my own personal cut ‘n’ paste reuse. Drop all empty nodes from an outbound message. Compile the attached into a BizTalk map using the custom XSLT override BizTalk mapper functionality and then call with the streaming transform pipeline component here. The send port order of operation means you outbound maps on your send port will be executed before the pipeline.

<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance">
  <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>
Advertisements
This entry was posted in BizTalk Server. Bookmark the permalink.

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