How would you remove all literals from this xquery

给你一囗甜甜゛ 提交于 2019-12-13 03:16:57

问题


How can a remove the literals from the return in employee.../employee and manager.../manager so I can delete employee.../employee and manager.../manager. I want the result to display without the employee and manager in the resulting xml.

<results>
      {
        for $depen in doc("../company/dependent.xml")//dependent
        where $depen/dependent_name=*
        return
         <row>
         <dependent name="{$depen/dependent_name}"/>
          {
            for $emp in doc("../company/employee.xml")//employee[ssn = $depen/essn ]
            return

            <employee>

            <emp fname="{$emp/fname}" lname="{$emp/lname}"/>
                  {
                  for $man in doc("../company/employee.xml")//employee[ssn = $emp/superssn ]
                  return


                 <mgr fname="{$man/fname}" lname="{$man/lname}"/>          


                 }              
            </employee> 
          } 
         </row>   
      }
    </results>

回答1:


I think you want

<results>
      {
        for $depen in doc("../company/dependent.xml")//dependent
        where $depen/dependent_name=*
        return
         <row>
          <dependent name="{$depen/dependent_name}"/>
          {
            for $emp in doc("../company/employee.xml")//employee[ssn = $depen/essn ]
            return

            (

                  <emp fname="{$emp/fname}" lname="{$emp/lname}"/>,

                  for $man in doc("../company/employee.xml")//employee[ssn = $emp/superssn ]
                  return
                     <mgr fname="{$man/fname}" lname="{$man/lname}"/>          

             )              
          } 
         </row>   
      }
</results>

in terms of the syntax, I am not sure the comparison $depen/dependent_name=* makes any sense without having a context.



来源:https://stackoverflow.com/questions/58718807/how-would-you-remove-all-literals-from-this-xquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!