开发者

XSL get the element if the element's name AND its attribute equals certain value

开发者 https://www.devze.com 2023-03-20 09:33 出处:网络
How do I translate the below code into a xsl-compilable form? What I wanted: return the element with the element name == CT AND the CT\'s attribute == \'person\'.

How do I translate the below code into a xsl-compilable form?

What I wanted: return the element with the element name == CT AND the CT's attribute == 'person'.

The xsl I tried (but failed):

<xsl:if 开发者_StackOverflowtest="CT and @Name='person'">

Google keywords are not being very helpful when "And" is involved...

Thanks.


Appropriate XPath: <xsl:value-of select="CT[@Name = 'person']" />

Supposed XML:

<root>
    <CT Name="a">A</CT>
    <CT Name="person">Person</CT>
</root>

XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
        <xsl:value-of select="//CT[@Name = 'person']" />
    </xsl:template>
</xsl:stylesheet>

Result: Person

0

精彩评论

暂无评论...
验证码 换一张
取 消