开发者

BizTalk 2009 XSLT and Attribute Value Templates

开发者 https://www.devze.com 2023-01-01 23:27 出处:网络
I\'m trying to make use of the attribute value type in a BizTalk XSL transformation to dynamically set attributes or other element names.

I'm trying to make use of the attribute value type in a BizTalk XSL transformation to dynamically set attributes or other element names.

The following code is an example of an XSL template to add an attribute optionally:

<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>

Problem:

Running this script in BizTalk causes the follo开发者_运维知识库wing exception:

"Exception from HRESULT: 0x80070002)"

One alternative I thought about was to call a msxsl:script function to do the same thing, but I can not handle the XSL output context from inside the function.

An ideas?


  <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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号