将XPath语句添加到FLOWR以选择"id". Twitter数据库中的节点 [英] add an XPath statement to a FLOWR to select "id" nodes from Twitter database

查看:109
本文介绍了将XPath语句添加到FLOWR以选择"id". Twitter数据库中的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在"id"字段中查找 twitter 数据库:

Looking at the "id" field for a twitter database:

thufir@dur:~/flwor$ 
thufir@dur:~/flwor$ basex
BaseX 9.0.1 [Standalone]
Try 'help' to get more information.
> 
> open twitter
Database 'twitter' was opened in 218.67 ms.
> 
> xquery //id
<id type="number">1224165280068382720</id>
<id type="number">60919433</id>
<id type="number">1224160851797643264</id>
<id type="number">60919433</id>
..
<id type="number">14248074</id>
Query executed in 268.13 ms.
> 

如何从FLWOR语句中获得相同的结果?

how would I get the same result from a FLWOR statement?

thufir@dur:~/flwor$ 
thufir@dur:~/flwor$ cat id.xq 

for $tweets in db:open("twitter")
let $tweet := $tweets
return <results>{$tweet}</results>

thufir@dur:~/flwor$ 

将所有内容包装在<result>标记中,但仍提供每个节点.如何仅选择"id"节点?尝试以下版本:

which wraps everything in <result> tags, but still gives every node. How is just the "id" node selected? Trying variations on:

  let $tweet := $tweets/id

,未获得积极结果.也许是因为混合了JSON?

without positive results. Perhaps because there's JSON in the mix?

推荐答案

雪花ID:

thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ basex tweetID.xq 
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ cat tweetID.xq 
for $tweets  in db:open("twitter")
return <tweet>{$tweets/json/id__str}</tweet>
thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ 

FLWOR:

for $tweets  in db:open("twitter")
return <tweet>{$tweets/json/id__str}</tweet>

这篇关于将XPath语句添加到FLOWR以选择"id". Twitter数据库中的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆