Domanda

I want to make a table invisible, when a specific td is not filled with text.

Here is my XML:

<weitereAnmerkungen>
    <table>
        <thead>
            <tr>
            <th>Weitere Anmerkungen</th>
        </tr>
        </thead>        
        <tbody>
            <tr><td>Gehhilfe, Rollstuhl adhudsha dfuahsf sadfasd fas f asdf asd fas f s sd fsaf as df asd f asd as ghjgfhjgfhjghjgfhjgfhjgfhjghjgfhjghjgfhj   ghjf ghj ghj gh gf</td>
            </tr>   
        </tbody>
    </table>
</weitereAnmerkungen>

My XSLT:

  <xsl:template match="n1:weitereAnmerkungen">
      <xsl:if test="n1:table/n1:tbody/n1:tr/n1:td">     
          <xsl:apply-templates />       
      </xsl:if>  
  </xsl:template>

My Problem is, that also when the td is NOT filled with text, the table is visible. But it should NOT be visible!

I hope somebody can help me!

È stato utile?

Soluzione

You can check if the contents are empty as well with an extra predicate. Optionally, you might want to ignore whitespace with normalize-space:

<xsl:template match="n1:weitereAnmerkungen">
    <xsl:if test="n1:table/n1:tbody/n1:tr/n1:td 
           and n1:table/n1:tbody/n1:tr/n1:td[normalize-space(.) != '']">     
        <xsl:apply-templates />       
    </xsl:if>  
</xsl:template>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top