Hi Eric,
The xmlns "attribute" is not exactly an attribute, and for some
obscure/arcane XML and XQuery specification reasons that I cannot
adequately explain here, you are not allowed to use an attribute
constructor to construct the special xmlns "attribute" and have that
value be your default namespace for the constructed element. I think
(not sure here) the reason has something to do with the element
constructor specifying a QName for the element, and that QName cannot be
changed later on in the constructor.
Instead, you can specify the QName in your element constructor to be in
the namespace in which you want it. For example, I think the following
does what you are looking for in 3.2:
xquery version "0.9-ml"
declare namespace my = "my-namespace"
xdmp:document-insert('/insert-test.xml', <root xmlns="my-namespace" />);
xquery version "0.9-ml"
declare namespace my = "my-namespace"
xdmp:node-insert-child(
doc('/insert-test.xml')/my:root,
<direct xmlns="my-namespace"/>
);
xquery version "0.9-ml"
declare namespace my = "my-namespace"
(: notice the QName is constructed in the namespace bound to the my
prefix :)
xdmp:node-insert-child(
doc('/insert-test.xml')/my:root,
element my:computed {}
);
xquery version "0.9-ml"
declare namespace my = "my-namespace"
doc('/insert-test.xml')
This returns:
<root xmlns="my-namespace">
<direct/>
<my:computed xmlns:my="my-namespace"/>
</root>
-Danny
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Eric
Palmitesta
Sent: Monday, January 26, 2009 2:21 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] xdmp:node-insert-child, xmlns and
computedconstructors
Sorry, I should have included this in the previous email:
xdmp:version(), xdmp:platform(), xdmp:architecture()
Yields:
3.2-9 linux x86_64
Eric
Eric Palmitesta wrote:
> declare namespace my = "my-namespace"
>
> xdmp:document-insert('/insert-test.xml', <root xmlns="my-namespace"
/>)
>
> xdmp:node-insert-child(
> doc('/insert-test.xml')/my:root,
> <direct xmlns="my-namespace"/>
> )
>
> xdmp:node-insert-child(
> doc('/insert-test.xml')/my:root,
> element computed { attribute xmlns { "my-namespace" } }
> )
>
> doc('/insert-test.xml')
>
> Yields:
>
> <root xmlns="my-namespace"><direct/><computed xmlns=""/></root>
>
> Why doesn't the computed element get my-namespace?
>
> Eric
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general