我有以下 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>