我收到OSB服务的回复如下:
<cus:GetAllCustomersResponse xmlns:cus="http://www.waai.nl/cdm/customer">
<cus:customerId>1</cus:customerId>
<cus:customerName>2</cus:customerName>
</cus:GetAllCustomersResponse>
我想在OSB代理中的resposne中插入客户名之后的几个元素。我可以通过插入来实现,但是如果有20个元素,我必须添加20个插入。您能否建议是否可以通过OSB代理中的Xquery来完成?
cus:GetAllCustomersResponse xmlns:cus="http://www.waai.nl/cdm/customer">
<cus:customerId>1</cus:customerId>
<cus:customerName>2</cus:customerName>
<cus:customerXXXXX>2</cus:customerXXXX>
<cus:customerXXYYY>2</cus:customerXXYYY>
<cus:customerVVV>2</cus:customerVVV>
<cus:customerBBB>2</cus:customerBBB>
<cus:customerEEE>2</cus:customerEEE>
......
......
</cus:GetAllCustomersResponse>
谢谢!
答案 0 :(得分:0)
是的,它可以,事实上是首选的方法。您需要阅读FLWOR个表达式,但最终会得到一些for
循环的描述。
答案 1 :(得分:0)
添加到Trent的正确答案,这是一个有用的link和示例代码 -
declare function local:insertEmpInfo($EmployeesIn as element()){
copy $Employees := $EmployeesIn
modify
(
for $employee in $Employees/EMP
return (
insert node <GENDER>M</GENDER> into $employee,
insert node <LOC>IND</LOC> into $employee/LOC,
insert node <ADDMORE>REPEAT_ME</ADDMORE> into $employee
)
)
return $Employees
};
declare function local:main () {
let $EmployeesIn := <EMPS>
<EMP>
<ID>1</ID>
<NAME>A</NAME>
<LOC/>
</EMP>
<EMP>
<ID>2</ID>
<NAME>B</NAME>
<LOC/>
</EMP>
</EMPS>
return local:insertEmpInfo($EmployeesIn)
};
答案 2 :(得分:0)
还有一件事,变换表达式(复制/修改)只有在使用OSB 12 +时才有效。
let $value := <foo><bar>hello</bar></foo>
return
copy $new := $value
modify (
insert node <bat>world!</bat> as last into $new,
replace value of node $new/bar with "Hello"
)
return $new
返回:
<foo>
<bar>Hello</bar>
<bat>world!</bat>
</foo>
答案 3 :(得分:0)
谢谢大家,通过插入操作得到了一个简单的方法。在cus之后插入:customerName
let $getAllCustomersResponse :=
<GetAllCustomersResponse>
<cus:customerXXXXX>2</cus:customerXXXX>
<cus:customerXXYYY>2</cus:customerXXYYY>
<cus:customerVVV>2</cus:customerVVV>
............
............
</GetAllCustomersResponse>
return
$getAllCustomersResponse/*