title: How to check if element node contains a specific value in xsl
body: <p>I have an XML document:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;document&gt;
      &lt;fruits&gt;
          &lt;fruit id="1"&gt;
              &lt;title&gt;I like pineapples&lt;/title&gt;
              &lt;description&gt; a tropical plant with edible multiple fruit consisting of coalesced berries&lt;/description&gt;
          &lt;/fruit&gt;
          &lt;fruit id="2"&gt;
              &lt;title&gt;I like watermelons&lt;/title&gt;
              &lt;description&gt;has a smooth exterior rind (green, yellow and sometimes white) and a juicy, sweet interior flesh&lt;/description&gt;
          &lt;/fruit&gt;
      &lt;/fruits&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p>How do I check if the <code>title</code> element contains 'pineapple' so that i can only display <code>description</code> for that particular <code>fruit</code> ?</p>
  
  <p>Here is the XSLT transformation I have:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
  
  &lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
    &lt;xsl:output  method="xml" omit-xml-declaration="yes" doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
               doctype-system="http://www.wapforum.org/DTD/xhtml-mobile10.dtd"/&gt;
   &lt;xsl:template match="/"&gt;
      &lt;xsl:element name="html"&gt;
        &lt;xsl:element name="head"&gt;        
          &lt;xsl:element name="title"&gt;Fruits&lt;/xsl:element&gt;
        &lt;/xsl:element&gt;
  
        &lt;xsl:element name="body"&gt;
          &lt;xsl:if test="/document/fruits/fruit/title[contains(text(),'pineapple')]"&gt;
            &lt;xsl:value-of select="description"/&gt;
          &lt;/xsl:if&gt;
          &lt;/xsl:element&gt;
      &lt;/xsl:element&gt;
    &lt;/xsl:template&gt;
   &lt;/xsl:stylesheet&gt;
  </code></pre>