我有xml文件,如 -
<domain xmlns:c="http://example.com/ns/core" xmlns="http://example.com/ns/core">
<c:id>http://example.com/xyz/no-data</c:id>
</domain>
我在MarkLogic中使用JavaScript,并希望在element value query上运行c:id
。像这样的东西 -
cts.elementValueQuery(xs.QName("c:id"), "http://example.com/xyz/no-data")
但为此,我需要声明命名空间c
。是不是xQuery我们可以做这样的事情 -
declare namespace c="http://example.com/ns/core";
但我无法在JavaScript中了解如何执行此操作。
您可以使用fn.QName()而不是xs.QName()。在下面的示例中,我将nsC
(namespace-C)声明为类似于声明的命名空间前缀。
const nsC = "http://example.com/ns/core";
cts.elementValueQuery(
fn.QName(nsC, "id"),
"http://example.com/xyz/no-data"
)