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中在客户名称后面插入几个元素。我可以通过insert来完成它,但是如果有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> 谢谢!!
发布于 2016-05-24 02:56:06
谢谢各位,有个简单的方法可以通过插入动作来完成。在cus之后插入:customerName
let $getAllCustomersResponse :=
<GetAllCustomersResponse>
<cus:customerXXXXX>2</cus:customerXXXX>
<cus:customerXXYYY>2</cus:customerXXYYY>
<cus:customerVVV>2</cus:customerVVV>
............
............
</GetAllCustomersResponse>
return
$getAllCustomersResponse/*发布于 2016-05-20 05:05:45
是的,它可以,而且实际上是首选的方法。您将需要阅读一些关于FLWOR表达式的内容,但最终会得到一些描述的for循环。
发布于 2016-05-20 07:19:08
加上Trent的正确答案,这里有一个有用的链接和示例代码-
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)
};https://stackoverflow.com/questions/37336261
复制相似问题