BizTalk 2009 XSLT and Attribute Value Templates

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

Read more here: http://www.w3.org/TR/xslt#dt-attribute-value-template

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>

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

An alternative I was thinking of was to call a msxsl:script function to do the same but i cannot get a handle on the XSL output context from within 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:

  • The supplied value of $attr is not a valid XML name (eg 12345 ).

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

  • 链接地址: http://www.djcxy.com/p/34330.html

    上一篇: XPATH选择其元素名称为xs:simpleType的子元素

    下一篇: BizTalk 2009 XSLT和属性值模板