2

Apache Tomcat の Exist DB を XML データベースとして使用し、FLWOR の「let」句で定義された次の xpath を渡してシーケンスを構築しようとしています。

$xpath := $root/second/third

次のように、ローカルで定義された関数宣言に変換します。

declare function local:someFunction($uuid as xs:string?, $xpath as xs:anyAtomicType?)
{
  let $varOne := $xpath/fourth[@uuid = $uuid]/fifthRight
  let $varTwo := $xpath/fourth[@uuid = $uuid]/fifthLeft
  let $combined := ($varOne,$varTwo)
  return $combined
};

もちろん、exist xquery サンドボックスにこれを入力すると、Type: xs:anyAtomicType is not defined が表示されます。代わりに何を使用する必要がありますか、またはこれを別の方法で行う必要がありますか?

ご提案いただきありがとうございます。

4

2 に答える 2

1

エラーを再現できませんでした (xs:anyAtomicType が定義されていません)。しかし、おそらく次のことが役に立ちますか?

$xpath (最初はノード) がアトミック型パラメーターとして渡された (したがってアトミック化された) 場合、関数 ( ) 内を移動しようとすると、必ず型エラー XPTY0019 がスローされます$xpath/fourth。次のコードはあなたの側で動作しますか (node()*代わりに渡されます)?

declare function local:someFunction($uuid as xs:string?, $xpath as node()*)
{
  let $varOne := $xpath/fourth[@uuid = $uuid]/fifthRight
  let $varTwo := $xpath/fourth[@uuid = $uuid]/fifthLeft
  let $combined := ($varOne,$varTwo)
  return $combined
};

let $root :=
  <first>
    <second>
      <third>
        <fourth uuid="1">
          <fifthLeft>foo</fifthLeft>
          <fifthRight>bar</fifthRight>
        </fourth>
      </third>
    </second>
  </first>
let $xpath :=$root/second/third
return
local:someFunction("1", $xpath)

(編集:任意の数のノードを許可するためにスターを忘れました)

于 2010-05-18T15:30:16.673 に答える
0

一般に、$ root / second / thirdのような式は一連の項目を生成するため、パスと考えるのは役に立ちません。タイプxs:anyAtomicTypeを使用しますか?アイテムをアトムに強制します。

関数を次のように簡略化できます

declare function local:y($uuid as xs:string?, $xpath as item()*)
{
  $xpath/fourth[@uuid = $uuid]/(fifthRight,fifthLeft)
};

ところで、 eXist dbは、XalanやLuceneなどのApacheコンポーネントを使用していますが、ApacheやTomcatに接続されていない独立したオープンソースプロジェクトです。

于 2010-05-19T07:05:55.600 に答える