在XSLT中循环使用日期

时间:2013-07-10 23:00:49

标签: xslt

我有以下XML。

<Timesheet>
   <StartDate>2013-06-12T00:00:00</StartDate>
   <EndDate>2013-06-18T00:00:00</EndDate>
   <Details>
      <TimesheetDetail>
         <BusinessDate>2013-06-12T00:00:00</BusinessDate>
         <Site>
            <a:Id>0201</a:Id>
         </Site>
         <TotalDuration>180</TotalDuration>
         <WorkType>
            <a:Category>
               <b:_displayName>Work</b:_displayName>
               <b:_value>3</b:_value>
            </a:Category>
            <a:Code>Mgmnt</a:Code>
            <a:Description>Management</a:Description>
         </WorkType>
      </TimesheetDetail>
      <TimesheetDetail>
         <BusinessDate>2013-06-13T00:00:00</BusinessDate>
         <Site>
            <a:Id>0202</a:Id>
         </Site>
         <TotalDuration>240</TotalDuration>
         <WorkType>
            <a:Category>
               <b:_displayName>Time Off</b:_displayName>
               <b:_value>3</b:_value>
            </a:Category>
            <a:Code>Bereavement</a:Code>
            <a:Description>Bereavement Leave</a:Description>
         </WorkType>
      </TimesheetDetail>
   </Details>
   <Employee>
      <a:EmpUserId>314Test2</a:EmpUserId>
      <a:FirstName>314Test2</a:FirstName>
   </Employee>
</Timesheet>

我需要编写一个XSLT,它会生成一个包含一列的表 站点:值将来自每个Timesheetdetail中的Site属性 StartDate和EndDate之间每天的列。 TotalDuration值需要作为与BusinessDate匹配的上述创建列的值。如果有多个TimesheetDetails,则会创建额外的行。

我面临的问题是 - 如何遍历StartDate和EndDate并为XSLT中的每个日期动态生成列?我还需要显示该日期的“日”。我们可以在XSLT中得到它吗?

1 个答案:

答案 0 :(得分:0)

尝试使用此代码,虽然我没有尝试,但显示网站的方式是:

<xsl:aply-template select="Timesheet/details"/> 

这会在 TimesheetDetail 中生成循环

<xsl:template match="TimesheetDetail">
  <xsl:value-of select="Site/." />
</xsl:template>
相关问题