【问题标题】:Unable to remove duplicate values from XML, using XSLT 2.0无法使用 XSLT 2.0 从 XML 中删除重复值
【发布时间】:2017-12-06 12:25:38
【问题描述】:

我试过下面的解决方案

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

但这对我不起作用。因为我的 XML 有名称空间。我删除上述解决方案的命名空间工作正常。由于我有要求,我需要命名空间来调用下一个服务。

我正在尝试消除重复的&lt;com:identityNumber&gt;

<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>

【问题讨论】:

    标签: xml xslt xslt-2.0 soa


    【解决方案1】:

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

    【讨论】:

    • 我使用了 Prefix 结果是空白的。 -组>
    • @PrabhatSingh identityNumber 也在命名空间中。
    • @michael.hor257k 感谢指点 它对我有用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-20
    • 1970-01-01
    • 1970-01-01
    • 2015-11-16
    相关资源
    最近更新 更多