XSLT根据键值XSLT1.0对xml元素进行分组

XSLT根据键值XSLT1.0对xml元素进行分组,xslt,biztalk,Xslt,Biztalk,我将在BizTalk中收到如下所示的CRM响应XML <ns0:RetrieveMultipleResponse xmlns:ns0="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns3="http://schemas.microsoft.com/xrm/2011/Me

我将在BizTalk中收到如下所示的CRM响应XML

<ns0:RetrieveMultipleResponse xmlns:ns0="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns3="http://schemas.microsoft.com/xrm/2011/Metadata" xmlns:ns5="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:ns4="http://schemas.microsoft.com/xrm/2011/Contracts">
<ns0:RetrieveMultipleResult>
    <ns4:Entities>
      <ns4:Entity>
        <b:Attributes xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
            <b:KeyValuePairOfstringanyType>
            <c:key>ccx_datevaccineinfostatementpresented</c:key>
            <c:value i:type="d:dateTime" xmlns:d="http://www.w3.org/2001/XMLSchema">2012-08-14T04:00:00Z</c:value>
          </b:KeyValuePairOfstringanyType>
          <b:KeyValuePairOfstringanyType>
            <c:key>ccx_administeredamount</c:key>
            <c:value i:type="d:decimal" xmlns:d="http://www.w3.org/2001/XMLSchema">0.75000000</c:value>
          </b:KeyValuePairOfstringanyType>
          <b:KeyValuePairOfstringanyType>
            <c:key>ccx_immunizationid</c:key>
            <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">826c2b0e-a349-e411-866c-00155d1e1f77</c:value>
          </b:KeyValuePairOfstringanyType>
     </b:Attributes>
  </ns4:Entity>
   <ns4:Entity>
        <b:Attributes xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
            <b:KeyValuePairOfstringanyType>
            <c:key>ccx_datevaccineinfostatementpresented</c:key>
            <c:value i:type="d:dateTime" xmlns:d="http://www.w3.org/2001/XMLSchema">2012-08-14T04:00:00Z</c:value>
          </b:KeyValuePairOfstringanyType>
          <b:KeyValuePairOfstringanyType>
            <c:key>ccx_administeredamount</c:key>
            <c:value i:type="d:decimal" xmlns:d="http://www.w3.org/2001/XMLSchema">0.25000</c:value>
          </b:KeyValuePairOfstringanyType>
          <b:KeyValuePairOfstringanyType>
            <c:key>ccx_immunizationid</c:key>
            <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">766c2b0e-a349-e411-866c-00155d1e1f77</c:value>
          </b:KeyValuePairOfstringanyType>
     </b:Attributes>
  </ns4:Entity>
<ns4:Entity>
        <b:Attributes xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
            <b:KeyValuePairOfstringanyType>
            <c:key>ccx_datevaccineinfostatementpresented</c:key>
            <c:value i:type="d:dateTime" xmlns:d="http://www.w3.org/2001/XMLSchema">2012-08-14T04:00:00Z</c:value>
          </b:KeyValuePairOfstringanyType>
          <b:KeyValuePairOfstringanyType>
            <c:key>ccx_administeredamount</c:key>
            <c:value i:type="d:decimal" xmlns:d="http://www.w3.org/2001/XMLSchema">0.7500000000</c:value>
          </b:KeyValuePairOfstringanyType>
          <b:KeyValuePairOfstringanyType>
            <c:key>ccx_immunizationid</c:key>
            <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">826c2b0e-a349-e411-866c-00155d1e1f77</c:value>
          </b:KeyValuePairOfstringanyType>
     </b:Attributes>
  </ns4:Entity>
</Entities>

ccx_datevaccineinfostatementpresented
2012-08-14T04:00:00Z
ccx_管理安装
0.75000000
ccx_免疫ID
826c2b0e-a349-e411-866c-00155d1e1f77
ccx_datevaccineinfostatementpresented
2012-08-14T04:00:00Z
ccx_管理安装
0.25000
ccx_免疫ID
766c2b0e-a349-e411-866c-00155d1e1f77
ccx_datevaccineinfostatementpresented
2012-08-14T04:00:00Z
ccx_管理安装
0.7500000000
ccx_免疫ID
826c2b0e-a349-e411-866c-00155d1e1f77
我必须根据ccx_immunizationid值计算不同的实体,如果两个实体具有相同的免疫ID,我还必须对字段进行分组。如果xml文件(不带名称空间)和字段为
2323
,我可以使用以下方法

<xsl:template match="//Entity/Attributes[not(./ccx_immunizationid= preceding::ccx_immunizationid)]">

但在这里,我必须寻找关键的“ccx_免疫ID”及其值


我正在BizTalk map中使用自定义xslt。

不太清楚“字段分组”是什么意思-也许您可以添加一个转换所需输出的示例。在任何情况下,如果元素不符合预期顺序,您当前的方法可能会失败。您需要在ccx_immunizationid上创建xslt密钥。旁注:您是否只需要删除重复项?或者您是否得到过guid相同但其他值不同的实例?查看并查看其中的链接,了解如何使用xsl:keys对组节点进行分组。