Hi,

Let's consider a simplified version of your code:

    <ns:root xmlns:ns="one">
       <child xmlns="two"/>
    </ns:root>/*

It is important to understand that the namespace "one", bound to the
prefix "ns", is in scope for the element 'child'.  It is not because
the element name does not use that perfix that it should disappear
from the XDM instance.  What if it used in a value, like the following
(think about XML Schema e.g.):

    <ns:root xmlns:ns="one">
       <child xmlns="two" unit="ns:mile"/>
    </ns:root>/*

The behaviour you see, is the one required by the XQuery
recommendation.  And it should not harm.  If you really want to get
rid of that namespace binding, you can 1) make a recursive descent
transform, copying every element, copying only the namespace bindings
actually used in an element or attribute name, or 2) make sure that
all unused namespace bindings from ancestors are "hidden", by reusing
the same prefix (or default namespace):

    <root xmlns="one">
       <child xmlns="two"/>
    </root>/*

Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 21 July 2015 at 17:07, Raghu wrote:
> HI All,
>
> The following snippet gives me the unused namespace prefix (in this case
> ns), I need to ignore such unused namespace prefixes in the output
>
> Query
>
> declare namespace ns="http://somewhere.something.com";;
> xdmp:document-insert
> (
> "/text.xml",
> <ns:root>
> <child xmlns="http://anywhere.anything.com";></child>
> </ns:root>
> );
> doc("/text.xml")//*:child
>
> Result
>
> <child xmlns:ns="http://somewhere.something.com";
> xmlns="http://anywhere.anything.com"/>
>
> Thanks in advance!
> Raghu
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to