You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

BizTalk映射Inline XSLT问题:无法生成空Agent节点的解决需求

解决XSLT无法生成空Agent节点的问题

修正后的Inline XSLT代码

<xsl:variable name="agentParticipant" select="Participatent/ParticipantDetails/Participant[Partycode/@Value = 'Agent']"/>
<Agent>
  <xsl:value-of select="$agentParticipant/FIRSTname/text()"/>
</Agent>

问题根源

原来的代码靠<xsl:for-each>遍历所有Participant,只有碰到Partycode/@Value="Agent"的节点才会输出<Agent>。场景2里没有符合条件的Participant,循环里的判断永远不生效,自然不会生成任何Agent节点,满足不了“没匹配时必须生成空节点”的要求。

逻辑说明

  1. 先用XPath定位所有符合Agent条件的Participant节点,存到agentParticipant变量里
  2. 直接生成<Agent>节点:
    • 要是找到匹配的节点,自动把对应FIRSTname的内容填进去
    • 要是没找到,$agentParticipant/FIRSTname/text()返回空值,最终生成<Agent></Agent>空节点
  3. 这种写法只会生成一个Agent节点,完全符合目标节点“有界”的要求(就算输入里有多个Agent类型的Participant,也只会取第一个的名字)

验证结果

  • 场景1:匹配到Agent节点,输出<Agent>Agentname1</Agent>,符合预期
  • 场景2:无匹配节点,输出<Agent></Agent>,符合预期

内容的提问来源于stack exchange,提问作者bigB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 15:27:40