我定义了一个称为标签的变量,该变量选择名称为多个值之一的元素的节点集:
<xsl:variable name="tags" select="//xs:element[@name='Subscription' or @name='Account' or @name='Product' or @name='ProductRatePlan' or @name='ProductRatePlanCharge' or @name='Usage']"/>
我想这样定义一个变量:
<xsl:variable name="tagNames" select="'Subscription','Account','Product','ProductRatePlan','ProductRatePlanCharge','Usage'/>
如何重写第一个表达式以选择名称在$ tagNames集中的所有节点?本质上,我正在寻找一种类似于SQL集成员身份的操作:
SELECT * FROM tags WHERE name in ('Subscription', 'Account', 'Product'....)
最佳答案
在XPath 2.0中,您可以编写:
<xsl:variable name="tags" select="//xs:element[@name=('Subscription','Account','Product','ProductRatePlan','ProductRatePlanCharge','Usage')]"/>
关于xpath - 如何缩短此xpath表达式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15886162/