3

I have xml documents like -

<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>

I am using JavaScript in MarkLogic, and want to run an element value query on c:id. Something like this -

cts.elementValueQuery(xs.QName("c:id"), "http://example.com/xyz/no-data")

But for this I need to declare the namespace c. Has it been xQuery we could have done something like this -

declare namespace c="http://example.com/ns/core";

But I am not able to get how to do this in JavaScript.

Ankit Bhardwaj
  • 754
  • 8
  • 27

1 Answers1

5

You can use fn.QName() instead of xs.QName(). In the example below, I've declared nsC (namespace-C) as something analogous to a declared namespace prefix.

const nsC = "http://example.com/ns/core";
cts.elementValueQuery(
  fn.QName(nsC, "id"), 
  "http://example.com/xyz/no-data"
)
Dave Cassel
  • 8,352
  • 20
  • 38