Xslt get value of created xml element -
<xsl:when test="conditon = 'value1'"> <typeid>4</typeid> </xsl:when> <xsl:when test="conditon = 'value2'"> <typeid>4</typeid> </xsl:when> <xsl:when test="conditon = 'value3'"> <typeid>4</typeid> </xsl:when> .... ....
i have above. want check condition on created xml tag (typeid). i.e, below condition in xslt file,
<xsl:if test="$typeid = 4"> <price>100</price> </xsl:if>
so, how can use above condition on created tag (above typeid created tag on want make condition)
or other way achieve above?
$typeid
refers variable named typeid
, , not element have created.
what can do, define variable called typeid
set value want, , use variable create element, , check in condition.
<xsl:variable name="typeid"> <xsl:choose> <xsl:when test="conditon = 'value1'">1</xsl:when> <xsl:when test="conditon = 'value2'">2</xsl:when> <xsl:when test="conditon = 'value4'">4</xsl:when> <xsl:choose> </xsl:variable> <typeid> <xsl:value-of select="$typeid" /> </typeid> <xsl:if test="$typeid = 4"> <price>100</price> </xsl:if>
do note code have in same block of code, typeid
variable local in scope block.
Comments
Post a Comment