A: 
  <xsl:template name="AttributeOptional">
    <xsl:param name="value"/>
    <xsl:param name="attr"/>
    <xsl:if test="$value != ''">
      <xsl:attribute name="{$attr}">
        <xsl:value-of select="$value"/>
      </xsl:attribute>
    </xsl:if>
  </xsl:template>

Running this script in BizTalk results in "Exception from HRESULT: 0x80070002)"

Just me in "guess mode":

There are at least two reasons there might be an error with this code:

  1. The supplied value of $attr is not a valid XML name (e.g. 12345).

  2. The attribute is produced but the previously produced node is not an element (e.g. what is produced is <someElement> sometext then this attribute).

Dimitre Novatchev
Dimitre, It seems that I misdiagnosed the root cause for the issue I am having. Im going to some more testing and will get back to you. My apologies!
amok