[MarkLogic Dev General] question about namespace as attribute

Jason Hunter jhunter at marklogic.com
Fri Aug 27 15:39:45 PDT 2010


The xmlns="mynamespace" text is written in a format that looks like an attribute but it's not actually an attribute.  This is an oddity of XML caused by the fact that namespaces were added after the XML 1.0 specification finalized.

That means /@* won't match namespace declarations.

MarkLogic outputs namespace declarations automatically at the point where they're needed.  In your output it's actually there.  I get this:

<article xmlns="mynamespace"><subnode>test</subnode></article>
You may not see the xmlns namespace declaration if you use a web browser's view as XML facility because, inexplicably, browsers often suppress that.  In CQ hit the Text view instead and you'll see it there.

-jh-

On Aug 27, 2010, at 12:25 PM, helen chen wrote:

> If I run the following code, 
> 
> xquery version "1.0-ml";
> 
> let $a := <article xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns="mynamespace"><subnode>test</subnode></article>
> 
> return
>   element {fn:QName("mynamespace","article")}
>   {
>     $a/@*
>     ,
>     $a/node()
>   }
> 
> the return I got is 
> <article xmlns="mynamespace"><subnode>test</subnode></article>
> I missed the namespace definition in the original article node xmlns:m="http://www.w3.org/1998/Math/MathML"  in my new article node.
> 
> It looks like the $a/@*  does not put the namespace attribute there.  How can I get all the attributes into my new node dynamically so I know I didn't miss anything?
> 
> Thanks, Helen
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20100827/20e06ac7/attachment.html 


More information about the General mailing list