Pregunta

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!

¿Fue útil?

Solución

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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top