简体   繁体   English

如何验证xslt我只想验证三个标签?

[英]How to do validate xslt i want to only validate three tag?

Hi i have XSLT file and i want to validate it . 嗨,我有XSLT文件,我想对其进行验证。

i have more tag in xml file "sell", "rent", "Buy", "n/a", "NA", "" 我在xml文件"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. "sell", "rent" and "buy"不会显示在此标签上。

xml file xml文件

     <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. 如果重新标记标记为"sell", "rent" and "buy" ,则显示重新标记数据,否则不显示。

i have found one link in stackoverflown but im not understand . 我在stackoverflown中找到了一个链接,但是我不明白。

Please help me 请帮我

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. 这将在其子推荐节点包含您提到的数据的所有cd节点上引起迭代。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM