Templates MarkLogic中的XQuery模板不';不显示任何值,仅显示属性(TDE)

Templates MarkLogic中的XQuery模板不';不显示任何值,仅显示属性(TDE),templates,namespaces,xquery,marklogic,marklogic-9,Templates,Namespaces,Xquery,Marklogic,Marklogic 9,我创建了一个.xml文件和一个模板来提取一些数据,但只显示属性 这是我的.xml测试文件: <user id="1234" email="test.user@live.com" password="1234"> <type>Human</type> <notes> <note reference="5432" id="753" xmlns="http://testnamespace.de/note"> <t

我创建了一个.xml文件和一个模板来提取一些数据,但只显示属性

这是我的.xml测试文件:

<user id="1234" email="test.user@live.com" 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>
这表明属性显示正确,但不知何故元素的值(text、username、differentiveTitle、personNameInversed)不起作用。 我的猜测是,这些值需要更精确的路径或表达式,但我找不到任何信息。 例如,如果我在模板中将text值更改为
testns:text
,我会得到错误:XDMP-UNBPRFX:(err:XPST0081)前缀testns没有命名空间绑定

因此,不知何故,元素不能使用声明的名称空间,但属性可以

我还跳过了模板中的
部分,因为他们需要自己的上下文,这不重要,对吗


提前感谢您提供的任何有用的见解

MarkLogic支持给了我这个问题的答案,所以我想在这里分享

(谢谢克里斯·哈姆林!)

这确实是一个名称空间问题。显示对于多个名称空间,应使用“路径名称空间”

申报后

    <path-namespaces>
        <path-namespace>
            <prefix>testns</prefix>
            <namespace-uri>http://testnamespace.de/note</namespace-uri>
        </path-namespace>
    </path-namespaces>

testns
http://testnamespace.de/note

    <path-namespaces>
        <path-namespace>
            <prefix>testns</prefix>
            <namespace-uri>http://testnamespace.de/note</namespace-uri>
        </path-namespace>
    </path-namespaces>

在模板和上下文之间,并在我的元素(如testns:text)上使用testns前缀,可以正确显示元素

MarkLogic支持给了我这个问题的答案,所以我想在这里分享

(谢谢克里斯·哈姆林!)

这确实是一个名称空间问题。显示对于多个名称空间,应使用“路径名称空间”

申报后

    <path-namespaces>
        <path-namespace>
            <prefix>testns</prefix>
            <namespace-uri>http://testnamespace.de/note</namespace-uri>
        </path-namespace>
    </path-namespaces>

testns
http://testnamespace.de/note

    <path-namespaces>
        <path-namespace>
            <prefix>testns</prefix>
            <namespace-uri>http://testnamespace.de/note</namespace-uri>
        </path-namespace>
    </path-namespaces>

在模板和上下文之间,并在我的元素(如testns:text)上使用testns前缀,可以正确显示元素

既然你算出了,请把你的答案标记为“接受”,这样很明显这个问题得到了一个好答案。既然你算出了,请把你的答案标记为“接受”,这样很明显这个问题得到了一个好答案。