ZaoTaoBao
ZaoTaoBao

Reputation: 2615

show different images depends of value option

I have this 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>

And I want access to dynamic-content/option and values..to show and image related with the value.

I was trying but i don't find out he right way.

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

Upvotes: 0

Views: 45

Answers (1)

Joel M. Lamsen
Joel M. Lamsen

Reputation: 7173

try this stylesheet

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

Upvotes: 1

Related Questions