无法使用XSLT 2.0从XML中删除重复值

时间:2017-07-03 09:29:14

标签: xml xslt xslt-2.0 soa

我试过下面的解决方案

<xsl:for-each-group select="/esbMsg/rqData/customer" group-by="identityNumber">
         <xsl:sequence select="."/>
       </xsl:for-each-group>

但这不适合我。因为我的XML有名称空间。我删除上面的解决方案工作正常。正如我所要求的,我需要命名空间来调用下一个服务。

我正在尝试消除重复的<com:identityNumber>

<tns:esbMsg xmlns:leadapi="http://schemas.xyz.co.in/esb/api/sales/opportunity/v1"
            xmlns:comp="http://schemas.xyz.co.in/esb/eo/resilience/compliance/v1"
            xmlns:ns2="http://schemas.xyz.co.in/esb/eo/misc/content/v1"
            xmlns:appo="http://schemas.xyz.co.in/esb/eo/communication/appointment/v1"
            xmlns:asset="http://schemas.xyz.co.in/esb/eo/accounts/asset/v1"
            xmlns:ns1="http://schemas.xyz.co.in/esb/eo/sales/lead/v1"
            xmlns:ns3="http://schemas.xyz.co.in/esb/eo/accounts/application/v1"
            xmlns:com="http://schemas.xyz.co.in/esb/eo/common/v1"
            xmlns:tns="http://schemas.xyz.co.in/esb/eo/parties/customer/v1">
   <tns:rqData>
      <tns:customer>
         <tns:id>22812</tns:id>
         <tns:cif/>
         <com:personName>
            <com:fullName>LEN 1301 Legal repre</com:fullName>
         </com:personName>
         <com:identityDoc>
            <com:identityType>IIC</com:identityType>
            <com:identityNumber>2017061119892016</com:identityNumber>
         </com:identityDoc>
         <tns:currentAddress>
            <com:addressLine1/>
         </tns:currentAddress>
         <com:trailer>
            <com:createdBy>rm</com:createdBy>
         </com:trailer>
      </tns:customer>
      <tns:customer>
         <tns:id>22813</tns:id>
         <tns:cif/>
            <tns:identityNumber>383983983983</tns:identityNumber>
         <com:personName>
            <com:fullName>LEN 1301 Capita Contributor </com:fullName>
         </com:personName>
         <com:identityDoc>
            <com:identityType>IIC</com:identityType>
            <com:identityNumber>383983983983</com:identityNumber>
         </com:identityDoc>
         <tns:currentAddress>
            <com:addressLine1/>
         </tns:currentAddress>
         <com:trailer>
            <com:createdBy>rm</com:createdBy>
         </com:trailer>
      </tns:customer>
      <tns:customer>
         <tns:id>22814</tns:id>
         <tns:cif/>
         <tns:identityNumber>2017061119892016</tns:identityNumber>
         <com:personName>
            <com:fullName>LEN 1301 Collateral</com:fullName>
         </com:personName>
         <com:identityDoc>
            <com:identityType>IIC</com:identityType>
            <com:identityNumber>2017061119892016</com:identityNumber>
         </com:identityDoc>
         <tns:currentAddress>
            <com:addressLine1/>
         </tns:currentAddress>
         <com:trailer>
            <com:createdBy>rm</com:createdBy>
         </com:trailer>
      </tns:customer>
      <tns:customer>
         <tns:id>20005</tns:id>
         <tns:cif/>
         <tns:identityNumber>2017061119892016</tns:identityNumber>
         <com:personName>
            <com:fullName>LEN 1301 main cust</com:fullName>
         </com:personName>
          <com:identityDoc>
            <com:identityType>IIC</com:identityType>
            <com:identityNumber>2017061119892016</com:identityNumber>
         </com:identityDoc>
         <tns:currentAddress>
            <com:addressLine1>hanoi</com:addressLine1>
         </tns:currentAddress>
         <com:trailer>
            <com:createdBy>rm</com:createdBy>
         </com:trailer>
      </tns:customer>
   </tns:rqData>
</tns:esbMsg>

1 个答案:

答案 0 :(得分:1)

源文档中的元素位于各种名称空间中,您在路径表达式中完全忽略了这些名称空间。您需要在路径表达式中使用带前缀的名称,并将名称空间前缀绑定到正确的名称空间。