英文:
BizTalk inline XSLT in mapping
问题
Input schema有一个字段<Partycode Value="Agent" />。基于这个节点,我需要生成一个目标节点。目标节点是单一的模式。如果partycode是Agent,我想要一个值为Fname的目标节点。
如果partycode不是代理商,我希望目标节点没有任何值。
<Participatent></Participatent>在模式<ParticipantRole >中也没有限制,但代理商的值只有一次<participant>部分。
在目标中不是无限的。
场景1输入模式
<ns0:Schema xmlns:ns0="urn:Test:esb:one:services:create:rq:1.0">
<Participants>
<ParticipantDetails>
<Participant>
<ParticipantRoleIs>
<ParticipantRole Value="" />
</ParticipantRoleIs>
<FirstName>FirstName_0</FirstName>
</Participant>
<Participant>
<ParticipantRoleIs>
<ParticipantRole Value="Agent" />
</ParticipantRoleIs>
<FirstName>Agentname1</FirstName>
</Participant>
</ParticipantDetails>
</Participants>
</ns0:Schema>
期望的结果
<ns0:CreateClaim xmlns:ns0="http://Host_service_proj.Oubound_Test1">
<Agent>Agentname1</Agent>
</ns0:CreateClaim>
场景2输入模式
<ns0:Schema xmlns:ns0="urn:Test:esb:one:services:create:rq:1.0">
<Participants>
<ParticipantDetails>
<Participant>
<ParticipantRoleIs>
<ParticipantRole Value="" />
</ParticipantRoleIs>
<FirstName>FirstName_0</FirstName>
</Participant>
</ParticipantDetails>
</Participants>
</ns0:Schema>
期望的结果
<ns0:CreateClaim xmlns:ns0="http://Host_service_proj.Oubound_Test1">
<Agent></Agent>
</ns0:CreateClaim>
我正在寻找此映射的XSLT。我尝试在内联XSLT模板中使用脚本函数
<xsl:template name="MyXsltConcatTemplate2">
<Agent>
<xsl:value-of select="/*[local-name()='Schema' and namespace-uri()='http://Host_service_proj.Schema_test']/*[local-name()='Participatent' and namespace-uri()='']/*[local-name()='ParticipantDetails' and namespace-uri()='']/*[local-name()='Participant' and namespace-uri()='']/*[local-name()='Parturolecodes' and namespace-uri()='']/*[local-name()='PartyRole' and namespace-uri()=''][/@Value='Agent']/*[local-name()='FIRSTname' and namespace-uri()='']" />
</Agent>
</xsl:template>
但没有得到预期的结果。有人可以帮助吗?
英文:
Input schema have field <Partycode Value="Agent" />. Based on the this node I need to generate one destination node. Destination is single schema. If partycode is Agent I want destination node with value of Fname.
If partycode is not agent I want destination node without any value.
<Participatent></Participatent> unbounded in the schema <ParticipantRole > also unbound but agent value will one in only onetime only one <participant> section.
In destination is not unbounded
Scenario 1 Inputschema
<ns0:Schema xmlns:ns0="urn:Test:esb:one:services:create:rq:1.0">
<Participants>
<ParticipantDetails>
<Participant>
<ParticipantRoleIs>
<ParticipantRole Value="" />
</ParticipantRoleIs>
<FirstName>FirstName_0</FirstName>
</Participant>
<Participant>
<ParticipantRoleIs>
<ParticipantRole Value="Agent" />
</ParticipantRoleIs>
<FirstName>Agentname1</FirstName>
</Participant>
</ParticipantDetails>
</Participants>
</ns0:Schema>
Expected result
<ns0:CreateClaim xmlns:ns0="http://Host_service_proj.Oubound_Test1">
<Agent>Agentname1</Agent>
</ns0:CreateClaim>
Scenario 2 Inputschema
<ns0:Schema xmlns:ns0="urn:Test:esb:one:services:create:rq:1.0">
<Participants>
<ParticipantDetails>
<Participant>
<ParticipantRoleIs>
<ParticipantRole Value="" />
</ParticipantRoleIs>
<FirstName>FirstName_0</FirstName>
</Participant>
</ParticipantDetails>
</Participants>
</ns0:Schema>
Expected result
<ns0:CreateClaim xmlns:ns0="http://Host_service_proj.Oubound_Test1">
<Agent></Agent>
</ns0:CreateClaim>
I am looking for the xslt for this mapping .
I tried in scripting functod with inline xslt template
<xsl:template name="MyXsltConcatTemplate2">
<Agent>
<xsl:value-of select="/*[local-name()='Schema' and namespace-uri()='http://Host_service_proj.Schema_test']/*[local-name()='Participatent' and namespace-uri()='']/*[local-name()='ParticipantDetails' and namespace-uri()='']/*[local-name()='Participant' and namespace-uri()='']/*[local-name()='Parturolecodes' and namespace-uri()='']/*[local-name()='PartyRole' and namespace-uri()=''][/@Value='Agent']/*[local-name()='FIRSTname' and namespace-uri()='']" />
</Agent>
</xsl:template>
But not getting expected result. Can anybody help here
答案1
得分: 1
对于XSLT 1.0,这可能适用于您。
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:element name="ns0:CreateClaim" namespace="'http://Host_service_proj.Oubound_Test1'">
<xsl:element name="Agent">
<xsl:value-of
select="/*/*/*/Participant[ParticipantRoleIs/
ParticipantRole/@Value = 'Agent']
/FirstName[1]" />
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
英文:
For XSLT 1.0, this may work you.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/" >
<xsl:element name="ns0:CreateClaim" namespace="'http://Host_service_proj.Oubound_Test1'">
<xsl:element name="Agent" >
<xsl:value-of
select="/*/*/*/Participant[ParticipantRoleIs/
ParticipantRole/@Value = 'Agent']
/FirstName[1]" />
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
答案2
得分: 0
以下是您提供的文本的中文翻译:
您提到了“输入模式”,但如果我理解正确,您展示了两个不同的输入实例。
以下是XSLT3.0中的代码,它提供了您从两个给定的输入中请求的输出。我看到BizTalk确实支持XSLT3.0,但这可能取决于您使用的BizTalk版本。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
xmlns:in="urn:Test:esb:one:services:create:rq:1.0"
xmlns:out="http://Host_service_proj.Oubound_Test1"
expand-text="yes">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:output indent="yes" />
<xsl:variable name="out" as="xs:string" select="'http://Host_service_proj.Oubound_Test1'" />
<xsl:template match="/" >
<xsl:element name="ns0:CreateClaim" namespace="{$out}">
<xsl:namespace name="ns0" select="$out" />
<Agent>{/*/*/*/Participant[ParticipantRoleIs/ParticipantRole/@Value eq 'Agent']/FirstName[1]}</Agent>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
英文:
You mention "input schemas" but, if I understand correctly, you are showing two different input instances.
The following in XSLT3.0 gives the outputs that you requested from the two given inputs. I see that BizTalk does support XSLT3.0 but that probably depends upon the version of BizTalk that you are using.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
xmlns:in="urn:Test:esb:one:services:create:rq:1.0"
xmlns:out="http://Host_service_proj.Oubound_Test1"
expand-text="yes">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:output indent="yes" />
<xsl:variable name="out" as="xs:string" select="'http://Host_service_proj.Oubound_Test1'" />
<xsl:template match="/" >
<xsl:element name="ns0:CreateClaim" namespace="{$out}">
<xsl:namespace name="ns0" select="$out" />
<Agent>{/*/*/*/Participant[ParticipantRoleIs/ParticipantRole/@Value eq 'Agent']/FirstName[1]}</Agent>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论