2012-01-23 43 views
1

我有以下的XML,我用Xquerry來查詢一些使用Qexo的結果。如何僅查詢屬性等屬性?就像我想查詢每個作者的所有關係一樣?Qexo中的XML屬性查詢。

我可以做簡單的,但是這是非常棘手和din't得到任何在線參考......

<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

你忘了指定什麼是想要的輸出 ...?

嘗試這樣

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>