[英]Conditional BizTalk mapping for equivalent nodes
我试图在LoopingNode
上进行某种循环的BizTalk映射,如果Cond1
为false,则创建Type1
。 如果Cond1
为true,则创建Type2
。 它看起来像这样:
输入:
root
- LoopingNode
- id (string)
- Cond1 (bool)
输出:
root
- TargetNode
<Equivalent>
- Type1
- id (string)
- Type2
- id (string)
输出应该看起来像这样
<root>
<TargetNode type="Type2" id="a" />
<TargetNode type="Type1" id="q" />
</root>
我已尝试使用2个表循环,第1列作为门,但这不起作用。 我最近的尝试是用cond作为条件进行值映射。 生成的xslt变为:
<xsl:attribute name="xsi:type">
<xsl:value-of select="'ns0:Type1'" />
</xsl:attribute>
<xsl:if test="string($var:v6)='true'">
<xsl:variable name="var:v7" select="string(s1:Id/text())" />
<xsl:attribute name="id">
<xsl:value-of select="$var:v7" />
</xsl:attribute>
</xsl:if>
<xsl:attribute name="xsi:type">
<xsl:value-of select="'ns0:Type2'" />
</xsl:attribute>
<xsl:if test="string($var:v6)='false'">
<xsl:variable name="var:v10" select="string(s1:Id/text())" />
<xsl:attribute name="id">
<xsl:value-of select="$var:v10" />
</xsl:attribute>
</xsl:if>
由于xsl:if
仅包含id-tag而不包含<xsl:attribute name="xsi:type">
标记,因此该值始终为Type2
因为它是xslt中的最后一个。
我宁愿有一个非自定义的xslt解决方案,但也许这是不可能的。 真正的问题比这复杂得多(大约20多个属性,3个等价类型和2个条件)。 但解决方案可能应该是相同的。
任何想法如何在等效节点上进行条件循环?
更新:这是一个与我的问题对应的架构(xsd):
<?xml version="1.0" encoding="utf-16"?>
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="http://demo.com/schema/" targetNamespace="http://demo.com/schema/" xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="root" type ="Root">
</xs:element>
<xs:complexType name="Root">
<xs:sequence>
<xs:element name="TargetNode" type="TargetNode" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="TargetNode" abstract="true">
<xs:attribute name="id" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="Type1">
<xs:complexContent>
<xs:extension base="TargetNode">
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="Type2">
<xs:complexContent>
<xs:extension base="TargetNode">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
你正在寻找条件循环。 地图应该有:
id
节点之间的直接链接 LoopingNode
到TargetNode
循环functoid Cond1
进行条件循环并输出到Type1
和Type2
看起来像这样:
那些逻辑functoid有这样的配置:
如果使用equals而不是equals,则两者都可以具有相同的配置 - 或者使用两个equals并在其中一个中将Condition2设置为false。
您可以在MSDN上阅读有关条件循环的更多信息。
基于此XML输入:
<ns0:Root xmlns:ns0="http://BizTalk_Server_Project1.Schema1">
<LoopingNode Cond1="true" id="id_0"/>
<LoopingNode Cond1="true" id="id_1"/>
<LoopingNode Cond1="false" id="id_2"/>
<LoopingNode Cond1="true" id="id_3"/>
</ns0:Root>
我得到这个输出:
<?xml version="1.0"?>
<ns0:root xmlns:ns0="http://demo.com/schema/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:TargetNode id="id_0" xsi:type="ns0:Type1"/>
<ns0:TargetNode id="id_1" xsi:type="ns0:Type1"/>
<ns0:TargetNode id="id_2" xsi:type="ns0:Type2"/>
<ns0:TargetNode id="id_3" xsi:type="ns0:Type1"/>
</ns0:root>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.