How to check if an XML element has a certain attribute with XSLT -


i've inherited xslt transformation project , first time using technology. have xml:

<report>     <data>         <group>             <row>                 <cell email="true">                     <stuff>testing@testing.com</stuff>                 </cell>                 <cell>                     <stuff>not email</stuff>                 </cell>             </row>         </group>     </data> </report> 

how can test in xslt see if cell has email attribute, and/or if attribute set?

try

//cell[@email] 

for xpath expresssion. use pattern in template contain instructions ...

<xsl:if test=".[@email]">     <!-- structures generate / further processing --> </xsl:if> 

or

<xsl:if test=".[@email = 'true']">     <!-- structures generate / further processing --> </xsl:if> 

the test expression may contain pattern 1 user1759572's comment - dependes on context going perform test , outcome of transformation wish obtain.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -