SoquUI多模式的Xquery Assertion

时间:2015-05-05 20:00:17

标签: xml automation xquery soapui

我试图为需要如下所示的响应创建一个断言:

 <Names>          
  <NameList PropertyName="Record">
           <Names>
              <SimpleValue Value="Date :xx"/>
              <SimpleValue Value="Name :xx"/>           
           </Names>
        </NameList>
  <NameList PropertyName="Record">
           <Names>
              <SimpleValue Value="Date :xx"/>
              <SimpleValue Value="Name :xx"/>             
           </Names>
        </NameList>
 </Names>

断言应完全匹配。

我想出了一个看起来像这样的Xquery Assertions:

  declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
   <Names>
   {
   for $x in/Response/NameList/Names/NameList      
   return <NameList> {($x/@PropertyName)} 
   <Names>
    {
    for $x in/Response/NameList/Names/NameList/Names/SimpleValue
    return  <SimpleValue>{($x/@Value)} </SimpleValue>
    }
    </Names>
    </NameList>
    }
    </Names>

但是,这将从Namelist下的每个Names节点返回SimpleValue。 它看起来像这样:

   <Names>
    <NameList PropertyName="Record">
      <Names>
        <SimpleValue Value="Date:xx"/>
        <SimpleValue Value="Name:xx"/>
        <SimpleValue Value="Date:xx"/>
        <SimpleValue Value="Name:xx"/>
     </Names>
    </NameList>
   <NameList PropertyName="Record">
     <Names>
      <SimpleValue Value="Date:xx"/>
      <SimpleValue Value="Name:xx"/>
      <SimpleValue Value="Date:xx"/>
      <SimpleValue Value="Name:xx"/>
     </Names>
  </NameList>
 </Names>
你能帮帮忙吗? 感谢

2 个答案:

答案 0 :(得分:3)

要约束输出,请参阅外循环中的变量:

{
for $y in $x/Names/SimpleValue
return  <SimpleValue>{($y/@Value)} </SimpleValue>
}

答案 1 :(得分:0)

我的专业版许可证目前已过期,所以我无法测试,但我很确定你需要做这样的事情:

declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
<Names>
{
    for $x in/Response/NameList/Names/NameList      
    return <NameList> {($x/@PropertyName)} 
    <Names>
    {
        for $y in $x/Names/SimpleValue
        return  <SimpleValue>{($y/@Value)} </SimpleValue>
    }
    </Names>
</NameList>
}
</Names>