我有一个菜单,上面有三个行业和一个“活动”选项:
<ul>
<li id="p_active"><a href="active.xml">Active</a></li>
<li id="p_education"><a href="education.xml">Education</a></li>
<li id="p_energy"><a href="energy.xml">Energy</a></li>
<li id="p_services"><a href="services.xml">Services</a>
</li>
</ul>在每个行业中都有许多公司,此外,它们中的每一个都是“活跃”或“不活跃”。
在转到公司的页面时,有BACK和NEXT按钮,这两个按钮将在公司的主列表中导航到该行业中各自相邻的公司。
(例如,公司ABC是在教育行业,因此在他们的页面上,Back和Next将转到教育行业内的其他公司)。我已经在XSLT中实现了这一点:
<xsl:choose>
<xsl:when test="(company[@ind='Education'])">
<xsl:value-of select="document('invest-port.xml')/portfolio/company[name=$name]/following-sibling::company[@ind='Education'][1]/link"/>
</xsl:when>
<xsl:when test="(company[@ind='Energy'])">
<xsl:value-of select="document('invest-port.xml')/portfolio/company[name=$name]/following-sibling::company[@ind='Energy'][1]/link"/>
</xsl:when>
</xsl:choose>示例公司XML文件:
<fragment>
<company ind="Education" stat="Active">Company ABC</company>
<hq>Boston, MA</hq>
<desc>This company makes products for schools</desc>
</fragment>根据我编写的代码,使用行业作为默认的排序关键字,这是可行的。我的问题是:我希望当用户单击菜单中的“活动”时,“后退”和“下一步”按钮将在@status=的“活动”属性中导航,而不是按行业导航。
实现这一目标的最好方法是什么?我看过很多不同的解决方案,但我似乎找不出做this...Thanks的最好方法!
发布于 2010-06-19 01:30:09
首先,我会尝试去掉choose,并尝试使用一个变量来表示选定的行业:
company[@ind = $ind]然后,放置一个choose来确定您将以何种方式找到下一家/上一家公司。
<xsl:choose>
<xsl:when test="$selectionMethod = 'Active'">
<xsl:value-of select="document('invest-port.xml')/portfolio/company[name=$name]/following-sibling::company[@stat='Active'][1]/link"/>
</xsl:when>
<xsl:otherwise>
existing code
</xsl:otherwise>
</xsl:choose>https://stackoverflow.com/questions/3071765
复制相似问题