user3379902
user3379902

Reputation: 29

find if child element exist by variable

I have long list from a query statement to check if the said tag exist. If it does. copy-of with value. If not do something else with it. I am trying to do something like

 <xsl:choose>
        <xsl:when test="$TEST1/THING/row/name() = $tagname">
        <xsl:copy-of select = "$TEST1/THING/row/name()"/>
        </xsl:when>
    <xsl:otherwise>
    <!-- DO something -->
    </xsl:otherwise>
</xsl:choose>

And it is not working! Any ideas?

Upvotes: 0

Views: 160

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116992

Try:

<xsl:when test="$TEST1/THING/row/*[name() = $tagname]">

Note that this is pretty much a guess. Without context, that's all you can get.

Upvotes: 1

Related Questions