如何使用空手道在xml中声明值

时间:2018-10-16 13:30:08

标签: karate

我在xml响应下方,我需要使用空手道对'result'值进行断言

WITH time_log_temp (id, punch_time) 
     AS (SELECT 1, 
                To_date('2018-1-1 8:00:00 AM', 'YYYY-MM-DD HH:MI:SS AM') 
         FROM   dual 
         UNION ALL 
         SELECT 2, 
                To_date('2018-1-1 12:12:00 AM', 'YYYY-MM-DD HH:MI:SS AM') 
         FROM   dual 
         UNION ALL 
         SELECT 2, 
                To_date('2020-2-14 8:00:00 AM', 'YYYY-MM-DD HH:MI:SS AM') 
         FROM   dual), 
     inter 
     AS (SELECT a.date_token, 
                Nvl2 (b.date_token, 'Record found.', 'No records found.') AS 
                is_found 
         FROM   (SELECT To_date (a.month 
                                 || '/' 
                                 || b.day 
                                 || '/' 
                                 || a.year, 'MM/DD/YYYY') AS date_token 
                 FROM   (SELECT To_char (Extract (month FROM a.punch_time)) AS 
                                MONTH, 
                                To_char (Extract (year FROM a.punch_time))  AS 
                                YEAR 
                         FROM   time_log_temp a 
                         GROUP  BY To_char (Extract (month FROM a.punch_time)), 
                                   To_char (Extract (year FROM a.punch_time))) a 
                        join (SELECT To_char (ROWNUM) AS DAY 
                              FROM   dual 
                              CONNECT BY ROWNUM <= 31) b 
                          -- I placed this condition to eliminate dates such as February 31, etc. 
                          -- and it works unless I uncomment the WHERE clause below. 
                          ON b.day <= Extract (day FROM Last_day ( 
                                                        To_date (a.month 
                                                                 || '/1/' 
                                                                 || a.year, 
                                                        'MM/DD/YYYY')))) a 
                left join (SELECT Trunc (a.punch_time) AS date_token 
                           FROM   time_log_temp a 
                           GROUP  BY Trunc (a.punch_time)) b 
                       ON b.date_token = a.date_token 
         ORDER  BY 1, 
                   2) 
SELECT * 
FROM   inter 
-- WHERE  Trunc(date_token, 'MONTH') = '1-JAN-2018' 

我能够获取“值”对象的数据,但无法获取“结果”元素的数据。

1 个答案:

答案 0 :(得分:1)

* def response = 
"""
<Values version="2.0">
  <value name="num1">4</value>
  <value name="num2">3</value>
  <value name="n1">4</value>
  <value name="result">7</value>
  <value name="n2">3</value>
  <value name="value">7</value>
</Values>
"""
* match /Values//value[@name='result'] == '7'