Xpath-根据元素名选择属性

Xpath-根据元素名选择属性,xpath,attributes,Xpath,Attributes,我想根据父元素选择一个属性 一种方法是: <xsl:template match="@Name[name(..) = 'EntityType' and namespace-uri(..)= 'http://schemas.microsoft.com/ado/2008/09/edm']"> 有没有可能用一种更短的方式——类似于(whic不起作用)的方式 @Name[../edm:EntiyType] 文档中已经定义了名称空间前缀(例如,我可以选择//*/edm:EntityTyp

我想根据父元素选择一个属性

一种方法是:

<xsl:template match="@Name[name(..) = 'EntityType' and namespace-uri(..)= 'http://schemas.microsoft.com/ado/2008/09/edm']">

有没有可能用一种更短的方式——类似于(whic不起作用)的方式

@Name[../edm:EntiyType]

文档中已经定义了名称空间前缀(例如,我可以选择//*/edm:EntityType)

谢谢,
Matra

根据您应用模板的方式,以下各项应起作用

<xsl:template match="edm:EntiyType/@Name">


No,这是不正确的,因为它选择了一个元素EntityType而不是attribute@name,因为它应该匹配attribute not element。当然。你是对的,我已经测试过了,它很有效。简单而美丽。几分钟前我在看同一个链接,但没有看到答案。