<ROWS>
     <ROW oid="28439">
        <EFL eid="8" fid="27672" count="2" Name = "A : bbb">
            <MK id="3" val="0"/>
            <MK id="11" val="0578678"/>
        </EFL>
   </ROW>
</ROWS>
I have the above xml, i want to have the following loop in XSL
if Name attribute in EFL tag Exists And Not Empty Then
Display the value of Name attribute Else do something (that i know how to write) EndifPlease note that this IF Condition will be written within for-each loop on Row tag. So, th开发者_开发百科at 's why we can not use Match.
Thanks
Refer the following XSL. It works but havent tested corner cases.
<xsl:stylesheet version = '1.0'
 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
 <xsl:template match="/ROWS">
     <xsl:for-each select="ROW">
         <xsl:choose>
             <xsl:when test='string-length(EFL/@Name)>0'>
                 <xsl:value-of select="EFL/@Name"/> 
             </xsl:when>
             <xsl:otherwise>I know  what to do here....</xsl:otherwise>
         </xsl:choose>
     </xsl:for-each>
 </xsl:template>
Alejandro's quite right; to extrapolate Tushar's example:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text" indent="yes"/>
  <xsl:template match="/ROWS">
    <xsl:apply-templates select="ROW" />
  </xsl:template>
  <xsl:template match="ROW[string-length(EFL/@Name)>0]">
    <xsl:value-of select="EFL/@Name" />
  </xsl:template>
  <xsl:template match="ROW">
    <xsl:text>Something else..</xsl:text>
  </xsl:template>
</xsl:stylesheet>
Depending on the nature of your problem as a whole, this might be a better option; either is perfectly valid though. Strictly speaking in this example, even the template matching /ROWS is unnecessary, but it probably will be for anything more complex.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论