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.
Asked
Active
Viewed 1.2k times
2 Answers
8
To suppress an element in the destination, use a value mapping functoid.
- connect the element in question to a
LOGICAL EXISTENCE
functoid. - connect the
LOGICAL EXISTENCE
functoid to aLOGICAL AND
functoid. - connect the element functoid to a
NOT EQUALS
functoid. - In the
NOT EQUALS
functoid, set the Condition2 to BLANK. - connect the
NOT EQUALS
functoid to theLOGICAL AND
functoid. - connect the
LOGICAL AND
functoid to theVALUE MAP
functoid. - connect the element to the
VALUE MAP
functoid. - connect the
VALUE MAP
functoid to the destination element.
Do these steps in order. The screen shot below should help:
HTH
-
1I 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
-
-
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