xml - XSLT - how to print value through variable? -


 <table tablename="something">      <item table="something">        <column columnname="someid">somevalue</column> 

hi - above structure of xml-source.

i want create xslt variable prints "somevalue" of "someid" upon usage of

i can't figure out correct xpath syntax make happen. need both printing values , conditioning. condition needs test if "someid" not empty - how path this?

i hope someone'll able assist.

thanks much.

if understanding correctly trying do, create variable by

<xsl:variable name="someidvalue" select="//column[@columnname='someid']"/> 

then, can output by

<xsl:value-of select="$someidvalue"/> 

and test if not empty

<xsl:if test="$someidvalue != ''"><!-- --></xsl:if> 

for example, example.xml as

<table tablename="something">     <item table="something">         <column columnname="someid">somevalue</column>         <column columnname="someid2"/>     </item> </table> 

and example.xsl as

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0">      <xsl:variable name="someidvalue" select="//column[@columnname='someid']"/>     <xsl:variable name="someidvalue2" select="//column[@columnname='someid2']"/>      <xsl:template match="/">         <xsl:if test="$someidvalue != ''">someid not empty , equal '<xsl:value-of select="$someidvalue"/>'.</xsl:if>         <xsl:if test="$someidvalue2 != ''">someid2 not empty , equal '<xsl:value-of select="$someidvalue2"/>'.</xsl:if>     </xsl:template>  </xsl:stylesheet> 

transforming xml xsl result in output of

someid not empty , equal 'somevalue'. 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -