편집 : 질문그룹화 XML 요소
이 this question 확장 코드가 리팩토링 ... 나는 형식으로 프리젠 테이션의 시작 시간과 끝 나타내는 XML 피드가
:2012-06-06 10:45
그 각 노드가이 방식으로 표현되면서, :, 난 단지 배 그룹에 대해 걱정 앞의 질문에서
<session id="9c4716c71f" name="Session 1" starttime="2012-06-06 10:45" endtime="2012-06-06 12:45" location="" chair="">
<article code="c1" id="TT-282" type="presentation"></article>
<article code="c2" id="TT-301" type="presentation"></article>
...
</session>
<session id="9c4716c249z" name="Session 2" starttime="2012-06-06 14:45" endtime="2012-06-06 16:45" location="" chair="">
<article code="c1" id="TT-214" type="presentation"></article>
<article code="c2" id="TT-328" type="presentation"></article>
...
그러나 지금은 원하는 2012 년 6 월 6 일까지이 모든 것을 그룹화하십시오.
따라서 이상적으로는 출력을 먼저 날짜별로 그룹화 한 다음 시간별로 그룹화하는 것이 좋습니다 (다음 코드에서 보게 될 것입니다).
는 내가 그 부분을 표시하기 위해 적용되는 템플릿이 있습니다
<!-- formatting dateTime -->
<xsl:template name="formatDate">
<xsl:param name="dateTime" />
<xsl:variable name="date" select="substring-before($dateTime, ' ')" />
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="number(substring-before(substring-after($date, '-'), '-'))" />
<xsl:variable name="day" select="number(substring-after(substring-after($date, '-'), '-'))" />
<!-- output -->
<xsl:choose>
<xsl:when test="$month = '1'">January</xsl:when>
<xsl:when test="$month = '2'">February</xsl:when>
<xsl:when test="$month = '3'">March</xsl:when>
<xsl:when test="$month = '4'">April</xsl:when>
<xsl:when test="$month = '5'">May</xsl:when>
<xsl:when test="$month = '6'">June</xsl:when>
<xsl:when test="$month = '7'">July</xsl:when>
<xsl:when test="$month = '8'">August</xsl:when>
<xsl:when test="$month = '9'">September</xsl:when>
<xsl:when test="$month = '10'">October</xsl:when>
<xsl:when test="$month = '11'">November</xsl:when>
<xsl:when test="$month = '12'">December</xsl:when>
</xsl:choose>
<xsl:value-of select="' '" />
<xsl:value-of select="$day" />
<xsl:value-of select="', '" />
<xsl:value-of select="$year" />
</xsl:template>
<!-- formatting dateTime -->
<xsl:template name="formatTime">
<xsl:param name="dateTime" />
<xsl:value-of select="substring-after($dateTime, ' ')" />
</xsl:template>
을하고 나는이 방식을 적용
이<h4>
<!-- output DD-MM-YYYY -->
<xsl:call-template name="formatDate">
<xsl:with-param name="dateTime" select="@starttime" />
</xsl:call-template>
</h4>
여기에 그룹 내 현재의 방법이다. 알 수 있듯이 형식화되지 않은 datetime (2012-06-06 10:45
)에 직접 그룹화되어 있지만 형식이 지정된 날짜 ($cdate
에 저장 됨)를 먼저 그룹화 한 다음 $ctime
내에 그룹화하고 싶습니다.
<xsl:template match="session">
<xsl:variable name="cdate">
<xsl:call-template name="formatDate">
<xsl:with-param name="dateTime" select="@starttime" />
</xsl:call-template>
</xsl:variable>
<xsl:if test='not(preceding-sibling::session[@starttime = current()/@starttime])'>
<h2><xsl:value-of select="@starttime" /></h2>
<div><xsl:apply-templates /></div>
</xsl:if>
</xsl:template>
<xsl:template match="article">
<b><xsl:value-of select="@name" /></b>
</xsl:template>
그래서 현재 내가 페이지에 보여주는 독특한 @startime 값의 목록을보고하고있다. 정말, 정말 (내가 여전히 XSLT의 사고 방식을하고 있어요)보고 싶어요 출력은 다음과 같은 것입니다 :
June 06, 2012
10:45 - 12:45 | TT-282
| TT-301
----------------------------------
14:45 - 16:45 | TT-214
| TT-328
June 07, 2012
....
내가 직접 서식에 대해 조금 덜 신경이 시점에서,하지만 단지 이 두 부분으로 구성된 변수 기반 그룹을 만들 수 있기를 원합니다. 모든 도움이 제공됩니다.
닫으 투표려고하는 경우에 나는 다시 downvotes ... – espais
을 이해하지 못하는 적어도 뭐가 잘못 ... 나에게 말씀 해주십시오의 내가 – espais