显示不同的图像取决于值选项



我有这个xml:

<root>
<dynamic-element instance-id="m2Q8mTq0" name="ofereix" type="multi-list">
        <dynamic-content>
            <option><![CDATA[Aigua]]></option>
            <option><![CDATA[Aixoplug]]></option>
            <option><![CDATA[Picnic]]></option>
        </dynamic-content>
    </dynamic-element>
</root>

我想访问动态内容/选项和值。以显示与值相关的图像。

我正在尝试,但我没有发现他的方式是正确的。

<xsl:for-each select="root/dynamic-element[@name='ofereix']/dynamic-element">
        <xsl:if test= "" >--> so here what I need?
    </xsl:if> 
</xsl:for-each>

试试这个样式表

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">
    <xsl:output indent="yes"/>
    <xsl:template match="/">
        <xsl:for-each select="/root/dynamic-element[@name='ofereix']/dynamic-content">
            <xsl:if test="option[.='Aigua']">
                <xsl:text>success!!</xsl:text>
            </xsl:if>
            <xsl:if test="option[.='Aixoplug']">
                <xsl:text>success!!</xsl:text>
            </xsl:if>
            <xsl:if test="option[.='Picnic']">
                <xsl:text>success!!</xsl:text>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

最新更新