【问题标题】:How to print data without the tag on basex?如何在basex上打印没有标签的数据?
【发布时间】:2021-02-15 18:26:23
【问题描述】:

我需要在下面显示没有标签的 xquery 的数据,所以如果你能帮助我,我将不胜感激。你怎么会注意到我已经有查询了。

 (: Output the customer names of each pair of customers who are associated with the same 
    rep. There should not be any duplicate reversed pair and no customer be paired with the 
    same customer.:)
    
    <result>
      {
        for $customer1 in doc ("../premiere/Customer.xml")//Customer,
            $customer2 in doc ("../premiere/Customer.xml")//Customer
        where  $customer1/RepNum =  $customer2/RepNum and $customer1/CustomerNum <  $customer2/CustomerNum
        order by $customer1/CustomerName
        return 
        <pair>
         "{$customer1/CustomerName}"
         "{$customer2/CustomerName}"
        </pair>
    
      }
    </result>

查询的输出是:

    <result>
  <pair>
     "<CustomerName>Al's Appliance and Sport</CustomerName>"
     "<CustomerName>Kline's</CustomerName>"
    </pair>
  <pair>
     "<CustomerName>Al's Appliance and Sport</CustomerName>"
     "<CustomerName>All Season</CustomerName>"
    </pair>
    .
    . 
    .
  <pair>
     "<CustomerName>The Everything Shop</CustomerName>"
     "<CustomerName>Deerfield's Four Seasons</CustomerName>"
    </pair>
</result>

我的输出必须是:

<results>
  <pair>Al's Appliance and Sport - Kline's</pair>
  <pair>Al's Appliance and Sport - All Season</pair>
  <pair>Bargains Galore - Johnson's Department Store</pair>
  <pair>Brookings Direct - The Everything Shop</pair>
  <pair>Brookings Direct - Lee's Sport and Appliance</pair>
  <pair>Brookings Direct - Deerfield's Four Seasons</pair>
  <pair>Ferguson's - Bargains Galore</pair>
  <pair>Ferguson's - Johnson's Department Store</pair>
  <pair>Kline's - All Season</pair>
  <pair>Lee's Sport and Appliance - Deerfield's Four Seasons</pair>
  <pair>The Everything Shop - Lee's Sport and Appliance</pair>
  <pair>The Everything Shop - Deerfield's Four Seasons</pair>
</results>

如何删除我的输出标签?

【问题讨论】:

    标签: xml xquery basex


    【解决方案1】:

    代替

    <pair>
             "{$customer1/CustomerName}"
             "{$customer2/CustomerName}"
    </pair>
    

    请尝试以下方法:

    <pair>{concat(data($customer1/CustomerName), ' - ', data($customer2/CustomerName))}</pair>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 2017-12-25
      • 1970-01-01
      • 1970-01-01
      • 2018-11-26
      相关资源
      最近更新 更多