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