删除xslt中重复的字符串



我需要删除字符串的重复条目或合并复杂类型元素的内容。我想将其更改为以下格式::

<?xml version="1.0" encoding="UTF-8"?>
<EMailData>
<property name="EVENTINFO">
 <property name="City">
    <value>City1111</value>
 </property>
 <property name="Country">
    <value>Country1112</value>
 </property>
 <property name="Zip">
    <value>Zip1113</value>
 </property>
 <property name="Household">
    <row>
       <property name="HouseholdNumber">
          <value>HouseholdNumber1173</value>
       </property>
       <property name="HouseholdName">
          <value>HouseholdName1174</value>
       </property>
       <property name="HouseholdStatus">
          <value>HouseholdStatus1175</value>
       </property>
       <property name="HouseholdPrimaryContactID">
          <value>HouseholdPrimaryContactID1176</value>
       </property>
    </row>
    <row> // **Second occurance as new row and not new element itself**
       <!-- Values -->
    </row> 
 </property>
 <property name="FFStatus">
 <row>
  <!-- Values -->
 </row>
  <row>
  <--values-->
  </row>
  </property>
  ....

如何在xslt中执行此操作。

我试着用translate()。但我被卡住了,因为我只需要从第二次出现的字符串中删除。

编辑

整个输入文件

            <?xml version="1.0" encoding="UTF-8"?>
        <EMailData>
           <property name="EVENTINFO">
              <property name="PersonInfo">
                 <property name="PersonID">
                    <value>PersonID1092</value>
                 </property>
                 <property name="EmailAddress">
                    <value>EmailAddress1093</value>
                 </property>
                 <property name="Household">
                    <row>
                       <property name="HouseholdNumber">
                          <value>HouseholdNumber1173</value>
                       </property>
                       <property name="HouseholdName">
                          <value>HouseholdName1174</value>
                       </property>
                       <property name="HouseholdStatus">
                          <value>HouseholdStatus1175</value>
                       </property>
                       <property name="HouseholdPrimaryContactID">
                          <value>HouseholdPrimaryContactID1176</value>
                       </property>
                    </row>
                 </property>
                 <property name="Household">
                    <row>
                       <property name="HouseholdNumber">
                          <value>HouseholdNumber1177</value>
                       </property>
                       <property name="HouseholdName">
                          <value>HouseholdName1178</value>
                       </property>
                       <property name="HouseholdStatus">
                          <value>HouseholdStatus1179</value>
                       </property>
                       <property name="HouseholdPrimaryContactID">
                          <value>HouseholdPrimaryContactID1180</value>
                       </property>
                    </row>
                 </property>
                 <property name="FFStatus">
                    <row>
                       <property name="FFCount">
                          <value>FFCount1187</value>
                       </property>
                       <property name="FFCycleStartDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="FFSubclassName">
                          <value>FFSubclassName1188</value>
                       </property>
                    </row>
                 </property>
                 <property name="FFStatus">
                    <row>
                       <property name="FFCount">
                          <value>FFCount1189</value>
                       </property>
                       <property name="FFCycleStartDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="FFSubclassName">
                          <value>FFSubclassName1190</value>
                       </property>
                    </row>
                 </property>
                 <property name="Offers">
                    <row>
                       <property name="OfferCode">
                          <value>OfferCode1191</value>
                       </property>
                       <property name="IsPALSReward">
                          <value>IsPALSReward1192</value>
                       </property>
                       <property name="ExpirationDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="OfferDescription">
                          <value>OfferDescription1193</value>
                       </property>
                       <property name="OfferTitle">
                          <value>OfferTitle1194</value>
                       </property>
                    </row>
                 </property>
                 <property name="Offers">
                    <row>
                       <property name="OfferCode">
                          <value>OfferCode1202</value>
                       </property>
                       <property name="IsPALSReward">
                          <value>IsPALSReward1203</value>
                       </property>
                       <property name="ExpirationDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="OfferDescription">
                          <value>OfferDescription1204</value>
                       </property>
                       <property name="OfferTitle">
                          <value>OfferTitle1205</value>
                       </property>
                       <property name="OfferType">
                          <value>OfferType1206</value>
                       </property>
                    </row>
                 </property>
                 <property name="Order">
                    <row>
                       <property name="OrderID">
                          <value>OrderID1224</value>
                       </property>
                       <property name="CustomerOrderNumber">
                          <value>CustomerOrderNumber1225</value>
                       </property>
                       <property name="OrderType">
                          <value/>
                       </property>
                       <property name="Currency">
                          <value>Currency1226</value>
                       </property>
                       <property name="OrderName">
                          <value/>
                       </property>
                       <property name="OrderFrequency">
                          <value>OrderFrequency1227</value>
                       </property>
                       <property name="IsRepeatDeliveryOrder">
                          <value>IsRepeatDeliveryOrder1228</value>
                       </property>
                       <property name="ProjectedShipmentDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="NextShipmentDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="Total">
                          <value>1229</value>
                       </property>
                    </row>
                 </property>
                 <property name="Order">
                    <row>
                       <property name="OrderID">
                          <value>OrderID1259</value>
                       </property>
                       <property name="CustomerOrderNumber">
                          <value>CustomerOrderNumber1260</value>
                       </property>
                       <property name="OrderType">
                          <value/>
                       </property>
                       <property name="Currency">
                          <value>Currency1261</value>
                       </property>
                       <property name="OrderName">
                          <value/>
                       </property>
                       <property name="OrderFrequency">
                          <value>OrderFrequency1262</value>
                       </property>
                       <property name="IsRepeatDeliveryOrder">
                          <value>IsRepeatDeliveryOrder1263</value>
                       </property>
                       <property name="ProjectedShipmentDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="NextShipmentDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="Total">
                          <value>1264</value>
                       </property>
                       <property name="Subtotal">
                          <value>1265</value>
                       </property>
                       <property name="SalesTax">
                          <value>1266</value>
                       </property>
                       <property name="ShippingAmount">
                          <value>1267</value>
                       </property>
                       <property name="ShippingDiscount">
                          <value>1268</value>
                       </property>
                       <property name="OtherDiscount">
                          <value>1269</value>
                       </property>
                       <property name="TotalDiscount">
                          <value>1270</value>
                       </property>
                       <property name="Surcharge">
                          <value>1271</value>
                       </property>
                       <property name="TimePlaced">
                          <value>TimePlaced1272</value>
                       </property>
                       <property name="OrderURL">
                          <value>OrderURL1273</value>
                       </property>
                       <property name="ShippingAddressLine1">
                          <value>ShippingAddressLine11274</value>
                       </property>
                       <property name="ShippingAddressLine2">
                          <value>ShippingAddressLine21275</value>
                       </property>
                       <property name="ShippingState">
                          <value>ShippingState1276</value>
                       </property>
                       <property name="ShippingCity">
                          <value>ShippingCity1277</value>
                       </property>
                       <property name="ShippingCountry">
                          <value>ShippingCountry1278</value>
                       </property>
                       <property name="ShippingZip">
                          <value>ShippingZip1279</value>
                       </property>
                       <property name="ShippingZipExtension">
                          <value>ShippingZipExtension1280</value>
                       </property>
                       <property name="PurchaseStoreNumber">
                          <value>PurchaseStoreNumber1281</value>
                       </property>
                       <property name="PurchaseStoreName">
                          <value>PurchaseStoreName1282</value>
                       </property>
                       <property name="PurchaseStoreMainPhoneNumber">
                          <value>PurchaseStoreMainPhoneNumber1283</value>
                       </property>
                       <property name="PurchaseStoreAddress1">
                          <value>PurchaseStoreAddress11284</value>
                       </property>
                       <property name="PurchaseStoreAddress2">
                          <value>PurchaseStoreAddress21285</value>
                       </property>
                       <property name="PurchaseStoreAddress3">
                          <value>PurchaseStoreAddress31286</value>
                       </property>
                       <property name="PurchaseStoreCity">
                          <value>PurchaseStoreCity1287</value>
                       </property>
                       <property name="PurchaseStoreState">
                          <value>PurchaseStoreState1288</value>
                       </property>
                       <property name="PurchaseStoreCountry">
                          <value>PurchaseStoreCountry1289</value>
                       </property>
                       <property name="PurchaseStoreZip">
                          <value>PurchaseStoreZip1290</value>
                       </property>
                       <property name="PurchaseStoreZipExtension">
                          <value>PurchaseStoreZipExtension1291</value>
                       </property>
                       <property name="PurchaseStoreZoneName">
                          <value>PurchaseStoreZoneName1292</value>
                       </property>
                       <property name="PurchaseStoreDistrictName">
                          <value>PurchaseStoreDistrictName1293</value>
                       </property>
                       <property name="OrderTender">
                          <value/>
                       </property>
                       <property name="OrderTender">
                          <value/>
                       </property>
                       <property name="OrderTender">
                          <value/>
                       </property>
                       <property name="OrderDetail">
                          <value/>
                       </property>
                       <property name="OrderDetail">
                          <value/>
                       </property>
                       <property name="OrderDetail">
                          <value/>
                       </property>
                    </row>
                 </property>
                 <property name="Order">
                    <row>
                       <property name="OrderID">
                          <value>OrderID1294</value>
                       </property>
                       <property name="CustomerOrderNumber">
                          <value>CustomerOrderNumber1295</value>
                       </property>
                       <property name="OrderType">
                          <value/>
                       </property>
                       <property name="Currency">
                          <value>Currency1296</value>
                       </property>
                       <property name="OrderName">
                          <value/>
                       </property>
                       <property name="OrderFrequency">
                          <value>OrderFrequency1297</value>
                       </property>
                       <property name="IsRepeatDeliveryOrder">
                          <value>IsRepeatDeliveryOrder1298</value>
                       </property>
                       <property name="ProjectedShipmentDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="NextShipmentDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="Total">
                          <value>1299</value>
                       </property>
                    </row>
                 </property>
                 <property name="Pet">
                    <row>
                       <property name="PetID">
                          <value>PetID1329</value>
                       </property>
                       <property name="PetName">
                          <value>PetName1330</value>
                       </property>
                       <property name="PetType">
                          <value>PetType1331</value>
                       </property>
                       <property name="ActiveFlag">
                          <value>ActiveFlag1332</value>
                       </property>
                       <property name="DateCreated">
                          <value>2015-02-05</value>
                       </property>
                       <property name="DateModified">
                          <value>2015-02-05</value>
                       </property>
                       <property name="BreedName">
                          <value>BreedName1333</value>
                       </property>
                       <property name="DateOfBirth">
                          <value>2015-02-05</value>
                       </property>
                       <property name="Gender">
                          <value>Gender1334</value>
                       </property>
                       <property name="NextGroomDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="PreferredStylist">
                          <value>PreferredStylist1335</value>
                       </property>
                       <property name="RabiesExpiration">
                          <value>2015-02-05</value>
                       </property>
                       <property name="RabiesVerifyBy">
                          <value>RabiesVerifyBy1336</value>
                       </property>
                    </row>
                 </property>
                 <property name="Pet">
                    <row>
                       <property name="PetID">
                          <value>PetID1345</value>
                       </property>
                       <property name="PetName">
                          <value>PetName1346</value>
                       </property>
                       <property name="PetType">
                          <value>PetType1347</value>
                       </property>
                       <property name="ActiveFlag">
                          <value>ActiveFlag1348</value>
                       </property>
                       <property name="DateCreated">
                          <value>2015-02-05</value>
                       </property>
                       <property name="DateModified">
                          <value>2015-02-05</value>
                       </property>
                       <property name="BreedName">
                          <value>BreedName1349</value>
                       </property>
                       <property name="DateOfBirth">
                          <value>2015-02-05</value>
                       </property>
                       <property name="Gender">
                          <value>Gender1350</value>
                       </property>
                       <property name="NextGroomDate">
                          <value>2015-02-05</value>
                       </property>
                       <property name="PreferredStylist">
                          <value>PreferredStylist1351</value>
                       </property>
                       <property name="RabiesExpiration">
                          <value>2015-02-05</value>
                       </property>
                       <property name="RabiesVerifyBy">
                          <value>RabiesVerifyBy1352</value>
                       </property>
                    </row>
                 </property>
                 <property name="Appointment">
                    <row>
                       <property name="AppointmentId">
                          <value>AppointmentId1353</value>
                       </property>
                       <property name="DepartmentName">
                          <value>DepartmentName1354</value>
                       </property>
                       <property name="ClientFirstName">
                          <value>ClientFirstName1355</value>
                       </property>
                       <property name="ClientLastName">
                          <value>ClientLastName1356</value>
                       </property>
                       <property name="PetName">
                          <value>PetName1357</value>
                       </property>
                       <property name="IsCanceled">
                          <value>IsCanceled1358</value>
                       </property>
                       <property name="StatusConditionId">
                          <value>StatusConditionId1359</value>
                       </property>
                       <property name="IsNoShow">
                          <value>IsNoShow1360</value>
                       </property>
                       <property name="AppointmentStatus">
                          <value>AppointmentStatus1361</value>
                       </property>
                       <property name="ResourceFirstName">
                          <value>ResourceFirstName1362</value>
                       </property>
                       <property name="ResourceLastName">
                          <value>ResourceLastName1363</value>
                       </property>
                       <property name="Duration">
                          <value>Duration1364</value>
                       </property>
                       <property name="DropOffTime">
                          <value>2015-02-05</value>
                       </property>
                       <property name="PickUpTime">
                          <value>2015-02-05</value>
                       </property>
                       <property name="LowEstimate">
                          <value>1365</value>
                       </property>
                       <property name="HighEstimate">
                          <value>1366</value>
                       </property>
                       <property name="SKU">
                          <value>SKU1367</value>
                       </property>
                       <property name="AppointmentStoreNumber">
                          <value>AppointmentStoreNumber1368</value>
                       </property>
                       <property name="AppointmentStoreName">
                          <value>AppointmentStoreName1369</value>
                       </property>
                       <property name="AppointmentStoreMainPhoneNumber">
                          <value>AppointmentStoreMainPhoneNumber1370</value>
                       </property>
                       <property name="AppointmentStoreAddress1">
                          <value>AppointmentStoreAddress11371</value>
                       </property>
                       <property name="AppointmentStoreAddress2">
                          <value>AppointmentStoreAddress21372</value>
                       </property>
                       <property name="AppointmentStoreAddress3">
                          <value>AppointmentStoreAddress31373</value>
                       </property>
                       <property name="AppointmentStoreState">
                          <value>AppointmentStoreState1374</value>
                       </property>
                       <property name="AppointmentStoreCity">
                          <value>AppointmentStoreCity1375</value>
                       </property>
                       <property name="AppointmentStoreCountry">
                          <value>AppointmentStoreCountry1376</value>
                       </property>
                       <property name="AppointmentStoreZip">
                          <value>AppointmentStoreZip1377</value>
                       </property>
                       <property name="AppointmentStoreZipExtension">
                          <value>AppointmentStoreZipExtension1378</value>
                       </property>
                       <property name="AppointmentStoreZoneName">
                          <value>AppointmentStoreZoneName1379</value>
                       </property>
                       <property name="AppointmentStoreDistrictName">
                          <value>AppointmentStoreDistrictName1380</value>
                       </property>
                    </row>
                 </property>
                 <property name="Appointment">
                    <row>
                       <property name="AppointmentId">
                          <value>AppointmentId1381</value>
                       </property>
                       <property name="DepartmentName">
                          <value>DepartmentName1382</value>
                       </property>
                       <property name="ClientFirstName">
                          <value>ClientFirstName1383</value>
                       </property>
                       <property name="ClientLastName">
                          <value>ClientLastName1384</value>
                       </property>
                       <property name="PetName">
                          <value>PetName1385</value>
                       </property>
                       <property name="IsCanceled">
                          <value>IsCanceled1386</value>
                       </property>
                       <property name="StatusConditionId">
                          <value>StatusConditionId1387</value>
                       </property>
                       <property name="IsNoShow">
                          <value>IsNoShow1388</value>
                       </property>
                       <property name="AppointmentStatus">
                          <value>AppointmentStatus1389</value>
                       </property>
                       <property name="ResourceFirstName">
                          <value>ResourceFirstName1390</value>
                       </property>
                       <property name="ResourceLastName">
                          <value>ResourceLastName1391</value>
                       </property>
                       <property name="Duration">
                          <value>Duration1392</value>
                       </property>
                       <property name="DropOffTime">
                          <value>2015-02-05</value>
                       </property>
                       <property name="PickUpTime">
                          <value>2015-02-05</value>
                       </property>
                       <property name="LowEstimate">
                          <value>1393</value>
                       </property>
                       <property name="HighEstimate">
                          <value>1394</value>
                       </property>
                       <property name="SKU">
                          <value>SKU1395</value>
                       </property>
                       <property name="AppointmentStoreNumber">
                          <value>AppointmentStoreNumber1396</value>
                       </property>
                       <property name="AppointmentStoreName">
                          <value>AppointmentStoreName1397</value>
                       </property>
                       <property name="AppointmentStoreMainPhoneNumber">
                          <value>AppointmentStoreMainPhoneNumber1398</value>
                       </property>
                       <property name="AppointmentStoreAddress1">
                          <value>AppointmentStoreAddress11399</value>
                       </property>
                       <property name="AppointmentStoreAddress2">
                          <value>AppointmentStoreAddress21400</value>
                       </property>
                       <property name="AppointmentStoreAddress3">
                          <value>AppointmentStoreAddress31401</value>
                       </property>
                       <property name="AppointmentStoreState">
                          <value>AppointmentStoreState1402</value>
                       </property>
                       <property name="AppointmentStoreCity">
                          <value>AppointmentStoreCity1403</value>
                       </property>
                       <property name="AppointmentStoreCountry">
                          <value>AppointmentStoreCountry1404</value>
                       </property>
                       <property name="AppointmentStoreZip">
                          <value>AppointmentStoreZip1405</value>
                       </property>
                       <property name="AppointmentStoreZipExtension">
                          <value>AppointmentStoreZipExtension1406</value>
                       </property>
                       <property name="AppointmentStoreZoneName">
                          <value>AppointmentStoreZoneName1407</value>
                       </property>
                       <property name="AppointmentStoreDistrictName">
                          <value>AppointmentStoreDistrictName1408</value>
                       </property>
                    </row>
                 </property>
                 <property name="Appointment">
                    <row>
                       <property name="AppointmentId">
                          <value>AppointmentId1409</value>
                       </property>
                       <property name="DepartmentName">
                          <value>DepartmentName1410</value>
                       </property>
                       <property name="ClientFirstName">
                          <value>ClientFirstName1411</value>
                       </property>
                       <property name="ClientLastName">
                          <value>ClientLastName1412</value>
                       </property>
                       <property name="PetName">
                          <value>PetName1413</value>
                       </property>
                       <property name="IsCanceled">
                          <value>IsCanceled1414</value>
                       </property>
                       <property name="StatusConditionId">
                          <value>StatusConditionId1415</value>
                       </property>
                       <property name="IsNoShow">
                          <value>IsNoShow1416</value>
                       </property>
                       <property name="AppointmentStatus">
                          <value>AppointmentStatus1417</value>
                       </property>
                       <property name="ResourceFirstName">
                          <value>ResourceFirstName1418</value>
                       </property>
                       <property name="ResourceLastName">
                          <value>ResourceLastName1419</value>
                       </property>
                       <property name="Duration">
                          <value>Duration1420</value>
                       </property>
                       <property name="DropOffTime">
                          <value>2015-02-05</value>
                       </property>
                       <property name="PickUpTime">
                          <value>2015-02-05</value>
                       </property>
                       <property name="LowEstimate">
                          <value>1421</value>
                       </property>
                       <property name="HighEstimate">
                          <value>1422</value>
                       </property>
                       <property name="SKU">
                          <value>SKU1423</value>
                       </property>
                       <property name="AppointmentStoreNumber">
                          <value>AppointmentStoreNumber1424</value>
                       </property>
                       <property name="AppointmentStoreName">
                          <value>AppointmentStoreName1425</value>
                       </property>
                       <property name="AppointmentStoreMainPhoneNumber">
                          <value>AppointmentStoreMainPhoneNumber1426</value>
                       </property>
                       <property name="AppointmentStoreAddress1">
                          <value>AppointmentStoreAddress11427</value>
                       </property>
                       <property name="AppointmentStoreAddress2">
                          <value>AppointmentStoreAddress21428</value>
                       </property>
                       <property name="AppointmentStoreAddress3">
                          <value>AppointmentStoreAddress31429</value>
                       </property>
                       <property name="AppointmentStoreState">
                          <value>AppointmentStoreState1430</value>
                       </property>
                       <property name="AppointmentStoreCity">
                          <value>AppointmentStoreCity1431</value>
                       </property>
                       <property name="AppointmentStoreCountry">
                          <value>AppointmentStoreCountry1432</value>
                       </property>
                       <property name="AppointmentStoreZip">
                          <value>AppointmentStoreZip1433</value>
                       </property>
                       <property name="AppointmentStoreZipExtension">
                          <value>AppointmentStoreZipExtension1434</value>
                       </property>
                       <property name="AppointmentStoreZoneName">
                          <value>AppointmentStoreZoneName1435</value>
                       </property>
                       <property name="AppointmentStoreDistrictName">
                          <value>AppointmentStoreDistrictName1436</value>
                       </property>
                    </row>
                 </property>
              </property>
           </property>
        </EMailData>

下面是一个XSLT1.0样式表,适用于您的最新示例,其中要分组的元素是树下的嵌套级别:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>
<xsl:key name="group" match="/*/*/*/property" use="@name"/>
<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>
<xsl:template match="/*/*/*[property[@name]]">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:for-each select="*[generate-id() = generate-id(key('group', @name)[1])]">
      <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates select="key('group', @name)/*"/>
      </xsl:copy>
    </xsl:for-each>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>

相关内容

  • 没有找到相关文章

最新更新