我對某個XSLT進行了業務規則更改,但我不確定如何處理它。如果你看下面的XML,你會看到我有一個員工部分和一個設備部分。員工部分有一個嵌套在日期標籤和TimeDetail標籤中的WorkOrderNumber,並且在Equipment - > EquipmentWorkOrder中嵌套有一個EquipmentWorkOrderNumber。使用XSLT從XML的兩個不同部分獲取不同的值
我用來僅僅需要獲得不同的WorkOrderNumber,因爲WorkOrderNumber和EquipmentWorkOrderNumber之間會有相關性,但現在可能會有額外的EquipmentWorkOrderNumber,這些額外的EquipmentWorkOrderNumber不存在於員工WorkOrderNumber部分中。
我需要獲取不同的WorkOrderNumber和EquipmentWorkOrderNumber而不復制這些值。我已經嘗試了許多以下代碼的變體,但沒有真正的進展。
<!-- The Key at the top -->
<xsl:key name="distinctWoEquipWo" match="//WorkOrderNumber | //EquipmentWorkOrderNumber" use="."/>
<!-- Where I loop through the distinct values -->
<xsl:for-each select=".//WorkOrderNumber | .//EquipmentWorkOrderNumber[generate-id() = generate-id(key('distinctWoEquipWo', .)[1])]">
是否有可能在select中獲得不同的WorkOrderNumber和EquipmentWorkOrderNumber值?
這是我正在使用的XML嗎?
<?xml-stylesheet type="text/xsl" href="TemplateTest.xsl"?>
<Timesheet>
<WeekEnding>Apr 28, 2013</WeekEnding>
<TeamMember>
<EmployeeNumber>AB00910</EmployeeNumber>
<EmployeeName>Demo, Derek</EmployeeName>
<EmployeeClass>F</EmployeeClass>
<Monday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>9</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Monday>
<Tuesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>12</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Tuesday>
<Wednesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>11</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Wednesday>
<Thursday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>8</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>3</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Thursday>
<Friday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>0</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>7</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Friday>
<Saturday />
<Sunday />
<CrewLeader>1</CrewLeader>
</TeamMember>
<TeamMember>
<EmployeeNumber>BB7789A</EmployeeNumber>
<EmployeeName>Employee, Daniel</EmployeeName>
<EmployeeClass>AL</EmployeeClass>
<Monday />
<Tuesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>12</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>YES</PerDiem>
<Notes>5xfullperdiem</Notes>
</TimeDetail>
</Tuesday>
<Wednesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>11</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>YES</PerDiem>
<Notes>5xfullperdiem</Notes>
</TimeDetail>
</Wednesday>
<Thursday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>8</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>3</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>YES</PerDiem>
<Notes>5xfullperdiem</Notes>
</TimeDetail>
</Thursday>
<Friday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>Regular</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>7</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>YES</PerDiem>
<Notes>5xfullperdiem</Notes>
</TimeDetail>
</Friday>
<Saturday />
<Sunday />
</TeamMember>
<TeamMember>
<EmployeeNumber>CDE890</EmployeeNumber>
<EmployeeName>Test, John</EmployeeName>
<EmployeeClass>G</EmployeeClass>
<Monday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>9</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Monday>
<Tuesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>12</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Tuesday>
<Wednesday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>11</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>Over Time</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Wednesday>
<Thursday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>8</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>3</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Thursday>
<Friday>
<TimeDetail>
<StartTime>Start</StartTime>
<StopTime>Stop</StopTime>
<WorkOrderNumber>4812537</WorkOrderNumber>
<RegularHoursStartTime>Start</RegularHoursStartTime>
<RegularHoursStopTime>Stop</RegularHoursStopTime>
<RegularHoursStartTime2>Start</RegularHoursStartTime2>
<RegularHoursStopTime2>Stop</RegularHoursStopTime2>
<RegularHours>0</RegularHours>
<OverTimeStartTime>Start</OverTimeStartTime>
<OverTimeStopTime>Stop</OverTimeStopTime>
<OverTimeStartTime2>Start</OverTimeStartTime2>
<OverTimeStopTime2>Stop</OverTimeStopTime2>
<OverTimeHours>7</OverTimeHours>
<OtherStartTime>Start</OtherStartTime>
<OtherStopTime>Stop</OtherStopTime>
<OtherStartTime2>Start</OtherStartTime2>
<OtherStopTime2>Stop</OtherStopTime2>
<OtherHours>Other</OtherHours>
<PerDiem>NO</PerDiem>
<Notes>Notes</Notes>
</TimeDetail>
</Friday>
<Saturday />
<Sunday />
</TeamMember>
<Equipment>
<EquipmentWorkOrder>
<EquipmentWorkOrderNumber>4812537</EquipmentWorkOrderNumber>
<EquipmentDetail>
<EquipmentMileage>Mileage</EquipmentMileage>
<EquipmentHourMeter>Hour Meter</EquipmentHourMeter>
<EquipmentType>Bucket truck</EquipmentType>
<EquipmentNumber>8s96</EquipmentNumber>
<MondayHours>0</MondayHours>
<TuesdayHours>12</TuesdayHours>
<WednesdayHours>11</WednesdayHours>
<ThursdayHours>11</ThursdayHours>
<FridayHours>7</FridayHours>
<SaturdayHours>Saturday</SaturdayHours>
<SundayHours>Sunday</SundayHours>
<EquipmentNotes>Notes</EquipmentNotes>
</EquipmentDetail>
<EquipmentDetail>
<EquipmentMileage>Mileage</EquipmentMileage>
<EquipmentHourMeter>Hour Meter</EquipmentHourMeter>
<EquipmentType>Line truck</EquipmentType>
<EquipmentNumber>20x949</EquipmentNumber>
<MondayHours>9</MondayHours>
<TuesdayHours>12</TuesdayHours>
<WednesdayHours>11</WednesdayHours>
<ThursdayHours>11</ThursdayHours>
<FridayHours>7</FridayHours>
<SaturdayHours>Saturday</SaturdayHours>
<SundayHours>Sunday</SundayHours>
<EquipmentNotes>Notes</EquipmentNotes>
</EquipmentDetail>
<EquipmentDetail>
<EquipmentMileage>Mileage</EquipmentMileage>
<EquipmentHourMeter>Hour Meter</EquipmentHourMeter>
<EquipmentType>Pickup truck</EquipmentType>
<EquipmentNumber>38g356</EquipmentNumber>
<MondayHours>9</MondayHours>
<TuesdayHours>12</TuesdayHours>
<WednesdayHours>11</WednesdayHours>
<ThursdayHours>11</ThursdayHours>
<FridayHours>7</FridayHours>
<SaturdayHours>Saturday</SaturdayHours>
<SundayHours>Sunday</SundayHours>
<EquipmentNotes>Notes</EquipmentNotes>
</EquipmentDetail>
<EquipmentDetail>
<EquipmentMileage>Mileage</EquipmentMileage>
<EquipmentHourMeter>Hour Meter</EquipmentHourMeter>
<EquipmentType>Air compressor</EquipmentType>
<EquipmentNumber>1d158</EquipmentNumber>
<MondayHours>9</MondayHours>
<TuesdayHours>12</TuesdayHours>
<WednesdayHours>11</WednesdayHours>
<ThursdayHours>11</ThursdayHours>
<FridayHours>7</FridayHours>
<SaturdayHours>Saturday</SaturdayHours>
<SundayHours>Sunday</SundayHours>
<EquipmentNotes>Notes</EquipmentNotes>
</EquipmentDetail>
</EquipmentWorkOrder>
</Equipment>
</Timesheet>
感謝您的所有幫助。
你能告訴我們你希望收到XML輸出? – ABach 2013-05-07 14:22:21
輸出是html,但有很多,但在上面的循環中,我試圖用工作訂單號打印標題。 的 的xsl:for-each>的 –
inosu812
2013-05-07 14:36:11
@ inosu812似乎適用於我(使用xsltoroc) – 2013-05-07 14:50:14