首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OSB Xquery之后插入多个元素

OSB Xquery之后插入多个元素
EN

Stack Overflow用户
提问于 2016-05-20 00:46:13
回答 4查看 3.1K关注 0票数 0

OSB服务部门对我的答复如下:

代码语言:javascript
复制
<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来完成这一任务?

代码语言:javascript
复制
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> 

谢谢!!

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2016-05-24 02:56:06

谢谢各位,有个简单的方法可以通过插入动作来完成。在cus之后插入:customerName

代码语言:javascript
复制
  let $getAllCustomersResponse := 
  <GetAllCustomersResponse>
  <cus:customerXXXXX>2</cus:customerXXXX> 
  <cus:customerXXYYY>2</cus:customerXXYYY>
  <cus:customerVVV>2</cus:customerVVV>
   ............
   ............

  </GetAllCustomersResponse> 
  return
  $getAllCustomersResponse/*
票数 0
EN

Stack Overflow用户

发布于 2016-05-20 05:05:45

是的,它可以,而且实际上是首选的方法。您将需要阅读一些关于FLWOR表达式的内容,但最终会得到一些描述的for循环。

票数 0
EN

Stack Overflow用户

发布于 2016-05-20 07:19:08

加上Trent的正确答案,这里有一个有用的链接和示例代码-

代码语言:javascript
复制
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)

  };
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37336261

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档