1

2 つのシングルトン タグ間のコンテンツを選択するための XQuery クエリを実行する方法を知っていますか。

<pb n="1"/>
   this is <foo>page</foo> number one
<pb n="2"/>
   this is <bar>page</bar> number two
<pb n="3"/>
   this is <x>page</x> number three

たとえば、2ページ目のコンテンツが欲しいので、<pb n="2"/>と nextの間<pb/>。出力は次のようになります。

   this is <bar>page</bar> number two
4

3 に答える 3

3

次のように、演算子とfollowing-sibling一緒に使用してこれを行うことができます。<<

let $xml := <xml>
<pb n="1"/> 
   this is <foo>page</foo> number one 
<pb n="2"/> 
   this is <bar>page</bar> number two 
<pb n="3"/> 
   this is <x>page</x> number three 
</xml>
return
  $xml/pb[2]/following-sibling::node()[. << $xml/pb[3]]

チッ!

于 2012-07-18T11:26:43.377 に答える
1

TEI wiki でDavid Sewell のmilestone-chunk()関数を参照してください。この記事は、eXist-db 拡張関数util:get-fragment-between()も指していることに注意してください。

于 2012-07-18T14:37:53.547 に答える
0

このクエリは、たまたま純粋な XPath 2.0 式です。

/*/node()[not(self::pb) and preceding-sibling::pb[1]/@n eq '2']

この XML ドキュメント(単一の最上位要素にラップされた提供された XML フラグメント) で実行すると、次のようになります。

<t>
    <pb n="1"/>
       this is <foo>page</foo> number one
    <pb n="2"/>
       this is <bar>page</bar> number two
    <pb n="3"/>
       this is <x>page</x> number three
</t>

必要な正しい結果が生成されます。

   this is <bar>page</bar> number two
于 2012-07-19T02:46:40.267 に答える