首页 文章

BizTalk 2009 XSLT和属性值模板

提问于
浏览
1

我正在尝试在BizTalk XSL转换中使用attribute value类型来动态设置属性或其他元素名称 .

以下代码是可选的添加属性的XSL模板示例:

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

在BizTalk中运行此脚本会导致以下异常:

“HRESULT异常:0x80070002)”

我想到的另一个选择是调用 msxsl:script 函数来做同样的事情,但是我无法从函数内部处理XSL输出上下文 .

一个想法?

1 回答

  • 1

    <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:属性>
    </ XSL:如果>
    </ XSL:模板>
    在BizTalk中运行此脚本导致“从HRESULT异常:0x80070002”

    Just me in "guess mode “:

    There are at least two reasons 此代码可能有错误:

    • $attr 的提供值不是有效的XML名称(例如 12345 ) .

    • 生成属性但是先前生成的节点不是元素(例如,生成的是 <someElement> sometext 然后是该属性) .

相关问题