我有一个时间表列表,可以通过 WordML(使用 XSLT 2.0)在 MS Word 中列出作为输出,并且认为我需要进行某种分组,但我不确定如何完成(如果可能的话)。
上级正在寻找的是每个日期(按日期排序),所有信息都汇总到每个计时员的一个部分中。(日期、计时员姓名缩写、该日期的小时总和、该计时员在该日期的所有叙述数据列表)。
这是我目前拥有的,只是每个日期的每个计时员/计时卡,没有分组。
输入:
<xml-sample>
<timecard index="10">
<timekeeper>
<initials>NC1</initials>
</timekeeper>
<date type="timecard">2015-09-01</date>
<card-values>
<card-value type="billed">
<rate>325.00</rate>
<hours>0.20</hours>
<amount>65.0000</amount>
</card-value>
</card-values>
<narrative>
<line id="1">Narrative for 9/1/2015. With some more detail</line>
<line id="2">on the 2nd line ID.</line>
</narrative>
</timecard>
<timecard index="11">
<timekeeper>
<initials>NC1</initials>
</timekeeper>
<date type="timecard">2015-09-01</date>
<card-values>
<card-value type="billed">
<rate>325.00</rate>
<hours>0.40</hours>
<amount>130.0000</amount>
</card-value>
</card-values>
<narrative>
<line id="1">Another narrative for 9/1/2015. With some more</line>
<line id="2">detail on the 2nd line ID.</line>
</narrative>
</timecard>
<timecard index="12">
<timekeeper>
<initials>NC1</initials>
</timekeeper>
<date type="timecard">2015-09-12</date>
<card-values>
<card-value type="billed">
<rate>325.00</rate>
<hours>0.30</hours>
<amount>97.5000</amount>
</card-value>
</card-values>
<narrative>
<line id="1">Narrative for 9/12/2015. With some more detail</line>
<line id="2">detail on the 2nd line ID.</line>
</narrative>
</timecard>
当前代码:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:kmf="http://www.kleinmundo.com/functions"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
xmlns:tlr="http://www.elite.com/functions"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template name="Time_Detail_Sample">
<xsl:for-each select="xsm-sample/timecard">
<w:p>
<w:r>
<w:t>Date: <xsl:value-of select="format-date(date, '[M01]/[D01]/[Y01]')" />
</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t>Timekeeper: <xsl:value-of select="timekeeper/initials" />
</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t>Hours: <xsl:value-of select="format-number(card-values/card-value[@type='billed']/hours, '###,##0.00')" />
</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<xsl:for-each select="narrative/line">
<w:t>
<xsl:value-of select="(.)" />
<xsl:value-of select="' '" />
</w:t>
</xsl:for-each>
</w:r>
</w:p>
<w:p />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
当前输出:
期望的输出:( 如您所见,2015 年 9 月 1 日的数据汇总为小时总和,并且所有叙述细节都一起列出)。