문제

다음과 같은 XML 파일이 있습니다.

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

Fistname, Last name, date_join 및 data_end를 기반으로 중복 항목을 제거하고 싶습니다.

XSLT를 사용하여 이를 달성하는 방법을 설명해 줄 수 있는 사람이 있습니까?

도움이 되었습니까?

해결책

다음은 몇 가지 샘플입니다. 요소 이름 및 ID 필드를 기반으로 중복을 제거하는 방법.이것을 임의의 필드로 확장하는 것은 그리 어렵지 않습니다.

큐:확장.내 XML의 일부는 다음과 같습니다.

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

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

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

원하는 출력은 다음과 같습니다.

xxxx
yyyy

즉, 상태의 중복된 값이 인쇄되어서는 안 됩니다.이것이 가능합니까?

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

   <xsl:for-each select="$unique-list">
 <xsl:value-of select="." />
   </xsl:for-each>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top