Layer7 API Management

  • 1.  why does xpath matches() not work?

    Posted Jun 14, 2018 10:18 AM

    When I use the xpath assertion with the function true(), it works fine, the result is obviously true.

    But when I want to use the function matches("abracadabra", "bra") as it is stated here XQuery 1.0 and XPath 2.0 Functions and Operators (SecondEdition)  (which also should return true), it always returns false, why?



  • 2.  Re: why does xpath matches() not work?

    Broadcom Employee
    Posted Jun 15, 2018 11:18 AM

    Hello,

     

    In the Evaluate XPath assertion change the XPath Version to 2.0 and it will succeed and return true



  • 3.  Re: why does xpath matches() not work?
    Best Answer

    Posted Jun 18, 2018 03:07 AM

    Hi,

     

     

    I already have the version set to 2.0, but I found out what the problem was: In my test case the response message was not set. So I manually added the following string to the response message:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <a></a>

     

    After this, the xpath matched.



  • 4.  Re: why does xpath matches() not work?

    Broadcom Employee
    Posted Jul 01, 2018 08:27 PM

    Yes, the target message of xpath needs to be an xml message to make xpath work. Besides the default response, you can also use a context variable.