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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -