xml - Check the node is present or not in xslt -


i new xslt, though manage work on it. struck 1 case need expert. trying finding node exists or not. search same question, in didn't expected answer. having node, mainnode->subnode1->subnode2->sunnode3. if checking below

<xsl:if test= "not(//mainnode/subnode1/subnode2/sunnode3)"> 

which working, if same converts in variable, below

<xsl:if test= "not(//mainnode/$var1/$var2/sunnode3)"> 

where, var1 = subnode1, var2 = subnode2

why not working. can't use variable in path searching. if not solution this.

you can't construct path step dynamically using variables. can use variable filter element name, example :

<xsl:if test= "not(//mainnode/*[name()=$var1]/*[name()=$var2]/sunnode3)"> 

Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -