Xml 匹配特定父节点XSLT的特定子属性
我试图使用XSL在下面的XML中匹配和更改方面名称x的displayHeight属性的值,但是下面的XSL模板更改了所有displayHeight值。我需要以下模板来匹配的displayHeight属性,仅当方面名称为x时Xml 匹配特定父节点XSLT的特定子属性,xml,xslt,xpath,Xml,Xslt,Xpath,我试图使用XSL在下面的XML中匹配和更改方面名称x的displayHeight属性的值,但是下面的XSL模板更改了所有displayHeight值。我需要以下模板来匹配的displayHeight属性,仅当方面名称为x时 <xsl:template match="@value[parent::property[@name='displayHeight']]"> <xsl:attribute name="value"> <xsl:value-
<xsl:template match="@value[parent::property[@name='displayHeight']]">
<xsl:attribute name="value">
<xsl:value-of select="'Value Has Been Changed By XSL'"/>
</xsl:attribute>
</xsl:template>
XML源文件
<?xml version="1.0" encoding="utf-8"?>
<a>
<b>
<aspect name="x">
<properties>
<property name="displayHeight" value="600"/>
<property name="displayWidth" value="800"/>
</properties>
</aspect>
<aspect name="y">
<properties>
<property name="displayHeight" value="1280"/>
<property name="displayWidth" value="720"/>
</properties>
</aspect>
</b>
</a>
使用
<xsl:template match="aspect[@name = 'x']/properties/property[@name = 'displayHeight']/@value">
<xsl:attribute name="value">
<xsl:value-of select="'Value Has Been Changed By XSL'"/>
</xsl:attribute>
</xsl:template>