0

Hi i have XSLT file and i want to validate it .

i have more tag in xml file "sell", "rent", "Buy", "n/a", "NA", ""

But i want to show only if i have any three tag as like

"sell", "rent" and "buy" than show to this tag.

xml file

     <cd>
        <title>Rohit</title>
        <recomondation>buy</recomondation>
        <year>1985</year>
    </cd>
<cd>
        <title>Raj</title>
        <recomondation>n/a</recomondation>
        <year>2090</year>
    </cd>
<cd>
        <title>amit</title>
        <recomondation>rent</recomondation>
        <year>1990</year>
    </cd>
<cd>
        <title>kavi</title>
        <recomondation>sell</recomondation>
        <year>2012</year>
    </cd>
<cd>
        <title>jokesh</title>
        <recomondation>NA</recomondation>
        <year>1990</year>
    </cd>
<cd>
        <title>james</title>
        <recomondation>Rent</recomondation>
        <year>1890</year>
    </cd>

if recomondation tag "sell", "rent" and "buy" than recomondation data show otherwise not show.

i have found one link in stackoverflown but i m not understand .

Please help me

Community
  • 1
  • 1
Rohit Azad Malik
  • 31,410
  • 17
  • 69
  • 97

1 Answers1

0

You can try something like this

  <xsl:for-each select="cd[recomondation='sell' or recomondation='rent' or recomondation='buy']">
    <xsl:copy-of select="."/>
  </xsl:for-each>

This will cause an iteration on all cd nodes whose child recommendation node contain your mentioned data. With your sample data currently only three nodes will be filtered out. If you are looking only for the recommendation nodes then you can try this

  <xsl:for-each select="cd//recomondation[.='sell' or .='rent' or .='buy']">
    <xsl:value-of select="."/>
  </xsl:for-each>
Saurav
  • 592
  • 4
  • 21