Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 匹配特定父节点XSLT的特定子属性_Xml_Xslt_Xpath - Fatal编程技术网

Xml 匹配特定父节点XSLT的特定子属性

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在下面的XML中匹配和更改方面名称x的displayHeight属性的值,但是下面的XSL模板更改了所有displayHeight值。我需要以下模板来匹配的displayHeight属性,仅当方面名称为x时

<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>