Qexo中的XML属性查询。

时间:2012-01-23 17:42:39

标签: xml xquery xquery-sql

我有以下XML,我使用Xquerry使用Qexo查询一些结果。如何仅查询联属属性?如果我想查询每个作者的所有隶属关系?

我可以做更简单的事情,但这非常棘手,无法获得任何在线参考......

    <conference>
<paper>
<conferencename>VLDB</conferencename>
<year>2006</year>
<author affiliation="ASU"> K. Selçuk Candan</author>
    <author affiliation="NEC America"> Wang-Pin Hsiung</author>
    <author affiliation="Turn"> Songting Chen</author>
    <author affiliation="NEC America"> Jun'ichi Tatemura</author>
    <author affiliation="UCSB">Divyakant Agarwal</author> 
<Article>AFilter: Adaptable XML Filtering with Prefix-Caching and Suffix-Clustering. 559-570
Electronic Edition (link) BibTeX </Article>
<place>Seoul, Korea</place>
</paper>
</conference>

只是为了返回所有值,这是使用的Xquery。

for $x in doc("vldb.xml")/conference/paper
where $x/conferencename = "VLDB"
order by $x/Author
return
<x>
{ $x/Author, $x/Article, $x/conferencename, $x/year}
</x>

1 个答案:

答案 0 :(得分:1)

您忘了指定想要的输出 ...?

尝试类似这样的内容

for $x in /conference/paper 
  where $x/conferencename = "VLDB" 
  order by $x/Author 

    return
      <x  affiliation = "{$x/author/@affiliation}"> 
         {$x/author, $x/Article, $x/conferencename, $x/year}
      </x>