2
這裏是我的代碼:XSLT |選擇/當
<xsl:choose>
<xsl:when test="$all_alerts[(g:line_abbr = 'MFL') or (g:line_abbr = 'BSL') or (g:line_abbr = 'CCT') or (g:line_abbr = 'NHSL') and (g:problem != 'normal_service')]">
<b>Subway</b><br /><br />
<xsl:for-each select="$all_alerts[g:line_abbr = 'MFL']">
<xsl:if test="g:problem != 'normal_service'"><xsl:value-of select="g:line"/> | <a href="/m/alert/mfl.html">
<xsl:if test="g:problem = 'station_advisory'">Station Advisory</xsl:if>
<xsl:if test="g:problem = 'stop_advisory'">Stop Advisory</xsl:if>
<xsl:if test="g:problem = 'customer_notice'">Customer Notice</xsl:if>
<xsl:if test="g:problem = 'service_advisory'">Service Advisory</xsl:if>
<xsl:if test="g:problem = 'shuttle_bus'">Shuttle Bus</xsl:if></a><br /><br /></xsl:if>
<xsl:if test="g:problem = 'normal_service'"></xsl:if>
</xsl:for-each>
<xsl:for-each select="$all_alerts[g:line_abbr = 'BSL']">
<xsl:if test="g:problem != 'normal_service'"><xsl:value-of select="g:line"/> | <a href="/m/alert/bsl.html">
<xsl:if test="g:problem = 'station_advisory'">Station Advisory</xsl:if>
<xsl:if test="g:problem = 'stop_advisory'">Stop Advisory</xsl:if>
<xsl:if test="g:problem = 'customer_notice'">Customer Notice</xsl:if>
<xsl:if test="g:problem = 'service_advisory'">Service Advisory</xsl:if>
<xsl:if test="g:problem = 'shuttle_bus'">Shuttle Bus</xsl:if></a><br /><br /></xsl:if>
<xsl:if test="g:problem = 'normal_service'"></xsl:if>
</xsl:for-each>
<xsl:for-each select="$all_alerts[g:line_abbr = 'CCT']">
<xsl:if test="g:problem != 'normal_service'"><xsl:value-of select="g:line"/> | <a href="/m/alert/cct.html">
<xsl:if test="g:problem = 'station_advisory'">Station Advisory</xsl:if>
<xsl:if test="g:problem = 'stop_advisory'">Stop Advisory</xsl:if>
<xsl:if test="g:problem = 'customer_notice'">Customer Notice</xsl:if>
<xsl:if test="g:problem = 'service_advisory'">Service Advisory</xsl:if>
<xsl:if test="g:problem = 'shuttle_bus'">Shuttle Bus</xsl:if></a><br /><br /></xsl:if>
<xsl:if test="g:problem = 'normal_service'"></xsl:if>
</xsl:for-each>
<xsl:for-each select="$all_alerts[g:line_abbr = 'NHSL']">
<xsl:if test="g:problem != 'normal_service'"><xsl:value-of select="g:line"/> | <a href="/m/alert/nhsl.html">
<xsl:if test="g:problem = 'station_advisory'">Station Advisory</xsl:if>
<xsl:if test="g:problem = 'stop_advisory'">Stop Advisory</xsl:if>
<xsl:if test="g:problem = 'customer_notice'">Customer Notice</xsl:if>
<xsl:if test="g:problem = 'service_advisory'">Service Advisory</xsl:if>
<xsl:if test="g:problem = 'shuttle_bus'">Shuttle Bus</xsl:if></a><br /><br /></xsl:if>
<xsl:if test="g:problem = 'normal_service'"></xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
如果有g:line_abbr
有g:problem != 'normal service'
然後我想要的標題地鐵展示以及以下信息,否則我什麼也不想要顯示在所有甚至標題的地鐵。
當for-eachs
全部爲空時,以下不隱藏標題'地鐵'。
它可能但我沒有時間去通過並取代物流,當我不完全擁有它。但如果我有時間的話。我會試試這個。謝謝! – balexander 2010-08-16 20:04:53
@ Bry4n:沒問題。我只是添加了這個答案,因爲看到你的代碼的人可能認爲XSLT是冗長的,而不是他們的工具。 – 2010-08-16 20:27:20