0

I don't want to in the output document to write out the element attribute if the value is missing or is an empty string. How to do that? That's in a biztalk mapping.

marko
  • 10,684
  • 17
  • 71
  • 92

2 Answers2

8

To suppress an element in the destination, use a value mapping functoid.

  1. connect the element in question to a LOGICAL EXISTENCE functoid.
  2. connect the LOGICAL EXISTENCE functoid to a LOGICAL AND functoid.
  3. connect the element functoid to a NOT EQUALS functoid.
  4. In the NOT EQUALS functoid, set the Condition2 to BLANK.
  5. connect the NOT EQUALS functoid to the LOGICAL AND functoid.
  6. connect the LOGICAL AND functoid to the VALUE MAP functoid.
  7. connect the element to the VALUE MAP functoid.
  8. connect the VALUE MAP functoid to the destination element.

Do these steps in order. The screen shot below should help:

sample map

HTH

slugster
  • 49,403
  • 14
  • 95
  • 145
TJ Amas
  • 1,291
  • 13
  • 19
  • 1
    I just usually just use the > functoid and compare if it is > than a single space. Then you have one logical functoid instead of 3. – NealWalters Mar 18 '15 at 15:21
1

If you prefer doing the XSLT yourself: (I'm checking for missing element, empty value, and xsi:nil - delete accordingly if not applicable)

<xsl:choose>
    <xsl:when test="not(s0:inElement) 
                    or s0:inElement[normalize-space(.) = ''] 
                    or string(s0:inElement/@xsi:nil) = 'true'">
        ... Default here, e.g. leave this blank, 
            ... or if you want nil then <ns1:outElement xsi:nil="true"/>
    </xsl:when>
    <xsl:otherwise>
        <ns1:outElement>
            <xsl:value-of select="s0:inElement/text()" />
        </ns1:outElement>
    </xsl:otherwise>
</xsl:choose>
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • the xslt solution looks nice. – marko Oct 21 '11 at 04:24
  • Have a look here to see how to convert a visual map to XSLT http://stackoverflow.com/questions/3716608/biztalk-2010-mapping-an-xsd-with-a-lot-of-elements-with-the-same-name/3718014#3718014 – StuartLC Oct 21 '11 at 06:49