Domanda

Ho un file XML come

<ns0:Employees xmlns:ns0="http://TestIndexMap.Employees">
  <Employee FirstName="FirstName_0" LastName="LastName_1" dept="dept_2" empNumber="1">
    <Schedules>
      <Schedule Date_join="2008-01-20" Date_end="2008-01-30" />
    </Schedules>
  </Employee>
  <Employee FirstName="FirstName_0" LastName="LastName_1" dept="dept_2" empNumber="2">
    <Schedules>
      <Schedule Date_join="2008-01-20" Date_end="2008-01-30" />
    </Schedules>
  </Employee>
  <Employee FirstName="FirstName_2" LastName="LastName_1" dept="dept_2" empNumber="2">
    <Schedules>
      <Schedule Date_join="2007-01-21" Date_end="2007-12-30" />

    </Schedules>
  </Employee>
  <Employee FirstName="FirstName_2" LastName="LastName_1" dept="dept_2" empNumber="2">
    <Schedules>
      <Schedule Date_join="2007-01-21" Date_end="2007-12-30" />
      <Schedule Date_join="2008-06-20" Date_end="2008-01-30" />

    </Schedules>
  </Employee>
</ns0:Employees>

Vorrei rimuovere i duplicati in base al nome pugno, cognome, date_join e data_end.

Per favore, qualcuno può spiegare come ottenerlo con XSLT?

È stato utile?

Soluzione

Ecco alcuni esempi di come rimuovere i duplicati in base al nome dell'elemento e al campo ID . Non dovrebbe essere troppo difficile estenderlo a campi arbitrari.

  

Q: Espansione. Una parte del mio aspetto XML   in questo modo:

 <location>
   <state>xxxx</state>
 </location>

 <location>
    <state>yyyy</state>
 </location>

  <location>
    <state>xxxx</state>
 </location>
  

L'output desiderato è:

xxxx
yyyy
  

Cioè, i valori duplicati di stato non devono essere stampati.   Può essere fatto?

   <xsl:variable name="unique-list"
     select="//state[not(.=following::state)]" />   

   <xsl:for-each select="$unique-list">
 <xsl:value-of select="." />
   </xsl:for-each>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top