以下のように私は3つのXML構造を持っている:私は出版社でグループこれらのXMLをしたいとしても、その合計なしを計算する必要があるだろう各要素の値を追加するにはどうすればよいですか?
a.xml
<Books>
<Book>
<Publisher>ABC Pvt Ltd</Publisher>
<Month>May</Month>
<Year>2016</Year>
<BooksReleased>4</BooksReleased>
</Book>
</Books>
b.xml
<Books>
<Book>
<Publisher>XYZ Pvt Ltd</Publisher>
<Month>April</Month>
<Year>2016</Year>
<BooksReleased>2</BooksReleased>
</Book>
</Books>
c.xml
<Books>
<Book>
<Publisher>ABC Pvt Ltd</Publisher>
<Month>June</Month>
<Year>2016</Year>
<BooksReleased>2</BooksReleased>
</Book>
</Books>
。出版社から特定の年に出版された書籍の数
必要な出力形式:親切
<TotalCalc>
<PublishedBook>
<Publisher>ABC Pvt Ltd</Publisher>
<no.of books>6</no.of books>
</PublishedBook>
<PublishedBook>
<Publisher>XYZ Pvt Ltd</Publisher>
<no.of books>2</no.of books>
</PublishedBook>
</TotalCalc>
、私は次のことを試してみましたが、そのPublisher
の共起をプルアップするためにcts:value-tuples
を使用することが可能であるかもしれない
typeswitch($Publisher)
case element (ABC Pvt Ltd)
return sum($doc/BooksReleases[$doc/$Publisher = 'ABC Pvt Ltd'])
default return 'unknnown'
タプルを使用する以外に他の方法がありますか?バージョン7のタプルを使用しているため使用できません – LSB
関数 'cts:value-tuples'はMarkLogic 7でも知られています:http://docs.marklogic.com/7.0/cts:value-tuples。あなたがサイズ2のタプルだけを必要とする場合は、古い['cts:element-value-co-occurrences'](http://docs.marklogic.com/7.0/cts:element-value-co-起こっている)など。 – grtjn
'cts:value-tuples'は何を返しますか?なぜ各項目に '' json:array-values'をしているのですか? – basari66