查找属性代码等于 url 上传递的参数的孩子的孩子 - XSL [英] Find child of child which attribute code is equal to the parameter passed on the url - XSL

查看:15
本文介绍了查找属性代码等于 url 上传递的参数的孩子的孩子 - XSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个动态网站上,网址如下所示:departments/CHEM.html

On this dynamic website, The url looks something like this : departments/CHEM.html

CHEM 是一个参数.

CHEM is a parameter.

     <xsl:param name="dep" select="'CHEM'" />

下面是一段xml

<course acad_year="2012" cat_num="5085" offered="Y">
  <term term_pattern_code="1" fall_term="Y" spring_term="N">fall term</term>
  <department code="CHEM">
     <dept_long_name>Department of Chemistry and Chemical Biology</dept_long_name>
     <dept_short_name>Chemistry and Chemical Biology</dept_short_name>
  </department>
</course> ....

我正在尝试让 dept_short_name 用于我的 H1 标签,但我没有成功.到目前为止,我尝试过

I am trying to get the dept_short_name to use on my H1 tag, but I have not been successful.So far I tried

<h2><xsl:value-of select="course/department/[code={@$dep}]"/></h2>

有什么建议???谢谢!

Any suggestions??? Thanks!

推荐答案

就用:

<xsl:value-of select="course/department[@code eq $dep]/dept_short_name"/>

记住:

在 XPath 2.0 (XSLT 2.0) 中,使用 eq 运算符进行值比较——它比一般的比较运算符 = 更有效,后者实际上只需要当至少有一个操作数是序列时使用.

In XPath 2.0 (XSLT 2.0) use the eq operator for value comparissons -- it is more efficient than the general comparisson operator = which really, only, needs to be used when at least one of its operands is a sequence.

这篇关于查找属性代码等于 url 上传递的参数的孩子的孩子 - XSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆