Search code examples
xmlxsltibm-watsonwatson

How to use an "or condition" in xsl:when in XSLT(IBM Watson Explorer)?


I am trying to an XSLT for my below XML:

<?xml version="1.0" encoding="UTF-8"?> 
    <results>
                <headline>
                  <a href="/bin-public/xyz/documents/customer-service/durable-power-of-bank.pdf"></a>
                  </headline>     
                  <linkPDF><a href="www.xyz.com"></a></linkPDF> 
     </results>
     <results>
                    <headline>
                     <a href="www.example.com"></a>
                     </headline>     
                    <linkPDF></linkPDF>
   </results>
    <results>
                   <headline>
                   <a href="www.example.html"></a>
                    </headline>     
                    <linkPDF><a href="www.abc.com"></a></linkPDF> 
     </results>

I want to add two condition: where headline/href contains a non-pdf endpoint URL or where linkPDF contains any value.

This is my XSLT condition, but it's not working:

<xsl:when test="not(viv:test(./headline/a/@href,'*.pdf','wc')) or 'linkPDF/a/href'">
 <!-- do something -->
 </xsl:when>

So, how can I use "OR" condition in viv:test? Or can I do the same thing without using viv:test in XSLT?Any help would be appreciated.


Solution

  • Change

    or 'linkPDF/a/href'
    

    to

    or linkPDF/a/href
    

    to evaluate an XPath in the second term of the or expression rather than a string literal.