Hi David,

I'll take your suggestion. Every time I ask a question I learn a lot more. I 
appreciate all the response.  

Helen


On Aug 30, 2010, at 10:43 AM, Lee, David wrote:

> The namespace binding is sort 'magic', think of it like attribute
> orders.
> It only needs to appear at the top most element of any element that uses
> it.  Any other place is cosmetic, and may actually be harmful if you
> were to mix & match sibling nodes with different bindings to the same
> namespace.
> All XML & Namespapce aware serializers (that I know of) will put the
> binding as needed, ideally at just the right scope.
> 
> So yes I suggest your last sentence is correct, don't worry about it.
> 
> -David
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of helen chen
> Sent: Monday, August 30, 2010 10:31 AM
> To: [email protected]; General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] question about namespace as
> attribute
> 
> Hi Georges and David,
> 
> I tried the code (I list at the end)  and I found no matter what I do,
> the namespace binding will eventually show up at the point that the data
> shows up.  It is added as needed.  I'm trying to convert one xml to
> another xml with adding/changing some information.
> 
> I was thinking that the original raw data has this namespace binding at
> the top and I wanted to keep it, thinking about your question: "Why
> would you like to copy this namespace binding?" , I think you are right.
> The data will be correct, it is just where the namespace binding shows
> up.  Maybe I should not worry about keeping the namespace binding at the
> top.
> 
> Thanks a lot for all your suggestions.
> 
> Helen
> 
> 
> 
> xquery version "1.0-ml";
> 
> declare function local:add-ns-node($elem   as element(),
>    $prefix as xs:string,  $ns-uri as xs:string  ) as element()
> {
>  element { QName($ns-uri, concat($prefix, ":x")) }{ $elem }/*
> };
> 
> 
> let $a := <article xmlns:m="http://www.w3.org/1998/Math/MathML";
> xmlns="mynamespace">
> <subnode>test</subnode>
> <m:a>test mnode</m:a>
> </article>
> 
> return
>  element {fn:QName("mynamespace","article")}
>  {
>    $a/@*
>    ,
> (:
>    for $subnode in $a/node()
>    let $ns := fn:namespace-uri-from-QName(fn:node-name($subnode))
>    return
>      if($ns eq "http://www.w3.org/1998/Math/MathML";)
>      then
>        local:add-ns-node($subnode, "m",
> "http://www.w3.org/1998/Math/MathML";)
>      else $subnode
> :)
>    $a/node()
> 
>  }
> 
> 
> 
> 
> On Aug 28, 2010, at 8:03 AM, Florent Georges wrote:
> 
>> helen chen wrote:
>> 
>> Hi,
>> 
>>> 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.
>> 
>> Yes, even though they are serialized in a similar way, XDM
>> defines attributes and namespaces as two very different beasts.
>> 
>>> How can I get all the attributes into my new node dynamically
>>> so I know I didn't miss anything?
>> 
>> If you really want to copy the in-scope bindings at some point,
>> you should be able to define a function to do so, by using both
>> fn:namespace-uri-for-prefix() and fn:in-scope-prefixes(), and the
>> following trick:
>> 
>> 
> http://fgeorges.blogspot.com/2006/08/add-namespace-node-to-element-in.ht
> ml
>> 
>> But maybe that's not what you really want to do.  Why would you
>> like to copy this namespace binding?
>> 
>> Regard,
>> 
>> -- 
>> Florent Georges
>> http://fgeorges.org/
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to