.xmlファイルとテンプレートを作成してデータを抽出しましたが、属性のみが表示されます。MarkLogicのXQueryテンプレートには値が表示されず、属性(TDE)のみが表示されます
これは私の.xml-テストファイルです:
<user id="1234" email="[email protected]" password="1234">
<type>Human</type>
<notes>
<note reference="5432" id="753" xmlns="http://testnamespace.de/note">
<text>example</text>
<username>John Doe</username>
<groups>
<group id="42">Avengers</group>
<group id="55">JLA</group>
</groups>
<distinctiveTitle>title</distinctiveTitle>
<personNameInverted>Doe John</personNameInverted>
</note>
</notes>
、ここで対応するテンプレート:(?)
import module namespace tde = "http://marklogic.com/xdmp/tde" at "/MarkLogic/tde.xqy";
declare namespace testns = "http://testnamespace.de/note";
let $userNoteTDE:=
<template xmlns="http://marklogic.com/xdmp/tde" xmlns:testns="http://testnamespace.de/note">
<context>/user/notes/testns:note</context>
<rows>
<row>
<schema-name>user</schema-name>
<view-name>notes</view-name>
<columns>
<column>
<name>reference</name>
<scalar-type>string</scalar-type>
<val>@reference</val>
<nullable>true</nullable>
<default>""</default>
</column>
<column>
<name>id</name>
<scalar-type>string</scalar-type>
<val>@id</val>
<nullable>true</nullable>
<default>""</default>
</column>
<column>
<name>text</name>
<scalar-type>string</scalar-type>
<val>text</val>
<nullable>true</nullable>
<default>""</default>
</column>
<column>
<name>username</name>
<scalar-type>string</scalar-type>
<val>username</val>
<nullable>true</nullable>
<default>""</default>
</column>
<column>
<name>distinctiveTitle</name>
<scalar-type>string</scalar-type>
<val>distinctiveTitle</val>
<nullable>true</nullable>
<default>""</default>
</column>
<column>
<name>personNameInverted</name>
<scalar-type>string</scalar-type>
<val>personNameInverted</val>
<nullable>true</nullable>
<default>""</default>
</column>
</columns>
</row>
</rows>
</template>
私は正しいパスし、使用するコンテキストを変更名前空間(この部分は別のテンプレートにネストする必要があるため):
<context>/user/notes/testns:note</context>
私はTDEでテンプレートを確認した場合:ノード・データ抽出(FN:DOC(TESTFILEのPATH)、$ userNoteTDE) 私は次の出力を得る:
{
"TESTFILE PATH": [
{
"row": {
"schema": "user",
"view": "notes",
"data": {
"rownum": "1",
"reference": "5432",
"id": "753",
"text": "",
"username": "",
"distinctiveTitle": "",
"personNameInverted": ""
}
}
}
]
}
このショーを、その属性は正しく表示されますが、要素の値(text、username、distinctiveTitle、personNameInverted)は機能しません。 私の推測では、値にはより洗練されたパスや式が必要ですが、情報は見つかりません。 私は私のテンプレートで<val>testns:text</val>
に例えばテキスト値を変更すると、私はエラーを取得:XDMP-UNBPRFX:(ERR:XPST0081)プレフィックスtestnsだから何とか要素にはできない
を結合名前空間を持っていません宣言された名前空間を使用しますが、属性は可能です。 、それはそれべき問題ではないはず、彼らは自分自身のコンテキストを必要とするので、
はまた、私は、私のテンプレートで<groups>
セクションをスキップ?
ありがとうございました。
あなたが理解してくれたので、あなたの答えを「受け入れられた」とマークしてください。そうすれば、この質問には良い答えが得られました。 –