次の XML データがあります。
<Timesheet>
<WeekEnding>Oct 7, 2012</WeekEnding>
<JobNumber>Doe - 508</JobNumber>
<WGNumber>WG No.</WGNumber>
<Customer>Dummy Company</Customer>
<City>Raleigh</City>
<State>North Carolina</State>
<TeamMember>
<EmployeeNumber>101010</EmployeeNumber>
<EmployeeName>Doe, Joseph</EmployeeName>
<EmployeeClass>UCL</EmployeeClass>
<Monday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>safety meeting</WorkOrderNumber>
<RegularHours>.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Safety meeting</Notes>
</TimeDetail>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>rain time</WorkOrderNumber>
<RegularHours>2</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Rain time</Notes>
</TimeDetail>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>777091</WorkOrderNumber>
<RegularHours>7.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Capital blvd st lights</Notes>
</TimeDetail>
</Monday>
<Tuesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>safety meeting</WorkOrderNumber>
<RegularHours>.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Safety meeting</Notes>
</TimeDetail>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>777091</WorkOrderNumber>
<RegularHours>9.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Capital blvd st lights</Notes>
</TimeDetail>
</Tuesday>
<Wednesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>5555591</WorkOrderNumber>
<RegularHours>10</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Capital blvd st lights</Notes>
</TimeDetail>
</Wednesday>
<Thursday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>111122</WorkOrderNumber>
<RegularHours>10</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>120 sigma dr</Notes>
</TimeDetail>
</Thursday>
<Friday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>999935</WorkOrderNumber>
<RegularHours>Regular</RegularHours>
<OverTimeHours>8</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>St light job Progress to pay half time</Notes>
</TimeDetail>
</Friday>
<Saturday></Saturday>
<Sunday></Sunday>
</TeamMember>
<TeamMember>
<EmployeeNumber>606060</EmployeeNumber>
<EmployeeName>Does, Stephen</EmployeeName>
<EmployeeClass>EO</EmployeeClass>
<Monday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>safety meeting</WorkOrderNumber>
<RegularHours>.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Safety meeting</Notes>
</TimeDetail>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>rain time</WorkOrderNumber>
<RegularHours>2</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Rain time</Notes>
</TimeDetail>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>777091</WorkOrderNumber>
<RegularHours>7.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Capital blvd st lights</Notes>
</TimeDetail>
</Monday>
<Tuesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>safety meeting</WorkOrderNumber>
<RegularHours>.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Safety meeting</Notes>
</TimeDetail>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>777091</WorkOrderNumber>
<RegularHours>9.5</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Capital blvd st lights</Notes>
</TimeDetail>
</Tuesday>
<Wednesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>5555591</WorkOrderNumber>
<RegularHours>10</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Capital blvd st lights</Notes>
</TimeDetail>
</Wednesday>
<Thursday></Thursday>
<Friday></Friday>
<Saturday></Saturday>
<Sunday></Sunday>
</TeamMember>
<TeamMember>
<EmployeeNumber>707070</EmployeeNumber>
<EmployeeName>Hancock, Samuel</EmployeeName>
<EmployeeClass>EO</EmployeeClass>
<Monday></Monday>
<Tuesday></Tuesday>
<Wednesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>5555591</WorkOrderNumber>
<RegularHours>10</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Capital blvd st lights</Notes>
</TimeDetail>
</Wednesday>
<Thursday></Thursday>
<Friday></Friday>
<Saturday></Saturday>
<Sunday></Sunday>
</TeamMember>
<TeamMember>
<EmployeeNumber>808080</EmployeeNumber>
<EmployeeName>Franklin, Ben</EmployeeName>
<EmployeeClass>EO</EmployeeClass>
<Monday></Monday>
<Tuesday></Tuesday>
<Wednesday></Wednesday>
<Thursday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>111122</WorkOrderNumber>
<RegularHours>10</RegularHours>
<OverTimeHours>Over Time</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>120 sigma dr</Notes>
</TimeDetail>
</Thursday>
<Friday></Friday>
<Saturday></Saturday>
<Sunday></Sunday>
</TeamMember>
<TeamMember>
<EmployeeNumber>909090</EmployeeNumber>
<EmployeeName>Doess, Smith</EmployeeName>
<EmployeeClass>UCL</EmployeeClass>
<Monday></Monday>
<Tuesday></Tuesday>
<Wednesday></Wednesday>
<Thursday></Thursday>
<Friday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>999935</WorkOrderNumber>
<RegularHours>4</RegularHours>
<OverTimeHours>4</OverTimeHours>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>St light job Progress to pay half time</Notes>
</TimeDetail>
</Friday>
<Saturday></Saturday>
<Sunday></Sunday>
</TeamMember>
従業員をループして、次のループを使用してデータを表示しています。
<xsl:for-each select="Timesheet/TeamMember[EmployeeNumber!='Employee No.']"></xsl:for-each>
そのループでは、従業員ループの現在の位置に対する従業員の個別の作業指示を表示する別のループを実行する必要があります。以下は、私が取り組んできたコードです。問題は、現在の従業員ではなく、XML ファイル全体の個別の作業指示書をすべて返すことです。何時間にもわたって何度も書き直しましたが、XML ファイルですべての作業指示書を取得するか、0 にするかのどちらかです。ありがとう。
このキーを XSLT の先頭で宣言しています
<xsl:key name="distinctWorkOrder" match="//WorkOrderNumber" use="."></xsl:key>
これは、従業員の作業指示を取得しようとしているループです
<xsl:for-each select="..//WorkOrderNumber[generate-id() = generate-id(key('distinctWorkOrder', .)[1])][//EmployeeNumber=$empId])">
更新: 出力は HTML です。従業員情報を表示するには、次のようにしました。
<tr style="height:20px;">
<td class="normalBorders" style="text-align:left;">Name</td>
<td class="borderT" style="text-align:center;">
<div style="border-bottom:1px solid black;height:12px;width:200px;">
<xsl:value-of select="EmployeeName"></xsl:value-of>
</div>
</td>
<td colspan="2" class="borderT" style="text-align:right;">Emp. ID#</td>
<td colspan="2" class="borderT" style="text-align:center">
<div style="border-bottom:1px solid black;height:15px; width:100%;display:inline-block;">
<xsl:value-of select="EmployeeNumber"/>
</div>
</td>
<td colspan="2" class="borderT"> </td>
<td rowspan="2" colspan="4" class="borderT borderR">
<div style="width:100%;height:27px;border-bottom:1px solid black;">
<img src="{../Signatures/Path}" style="width:100%;height:34px;"/>
</div>
</td>
</tr>
<tr style="height:20px;">
<td class="borderL" style="text-align:left;">Sign/Date</td>
<td style="text-align:center;">
<div style="border-bottom:1px solid black;height:12px;width:200px;">
<xsl:value-of select="EmployeeName"></xsl:value-of>
</div>
</td>
<td colspan="5"> </td>
<td style="text-align:right;">Approved</td>
</tr>
ここで、これに似た作業指示データをループして出力する必要があります
<xsl:for-each select="..//WorkOrderNumber[generate-id() = generate-id(key('distinctWorkOrder', .)[1])][//EmployeeNumber=$empId])">
<tr>
<td class="normalBorders"><xsl:value-of select="//WorkOrderNumber"/></td>
<td>Other data</td>
</tr>