简体   繁体   中英

How to declare namespace for Element in Marklogic?

I want to declare namespace for an Element. I am trying as below-

declare namespace abc="http://marklogic.com/somenamespace";
let $link := "anylink"
let $Content := <content>content</content>
let $result := element abc:data  { 
element headers{},
element root {
  element {"element"}{
            attribute link {$link},
            $Content
          }
     }
}
return $result

The output i am getting as-

<abc:data xmlns:abc="http://marklogic.com/somenamespace">
<headers>
------
---------
--------
</abc:data>

I don't want "abc:" in my data node. i want it like-

<data xmlns="http://marklogic.com/somenamespace">

any suggestions ?

This should work

declare default element namespace "http://marklogic.com/somenamespace";
let $link := "anylink"
let $Content := <content>content</content>
let $result := element data  { 
element headers{},
element root {
element {"element"}{
        attribute link {$link},
        $Content
      }
 }
}
return $result

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM