Paul,
I can't really answer your question as phrased, because there isn't a
"declared default attribute namespace" in XQuery 1.0. You can declare
the default element namespace, and default function namespace, but not
attribute namespace. If you remove the xmlns declaration, the QName
value of $pr-qname would be in the outer scope's default element
namespace - probably in the empty namespace.
When trying to reason about this code, keep in mind that as written, the
attribute constructor is not directly affected by the in-scope
namespaces. That's because the QName value of the $pr-qname variable
already has a namespace. The in-scope namespaces are applied to the
xs:QName constructor for the $pr-qname variable. So when $pr-qname is
declared with its QName value, that value already has the "msearch"
namespace. Try using the fn:namespace-uri($pr-qname) to verify this for
yourself.
-- Mike
On 2010-02-01 06:38, Paul M wrote:
When you state (in-scope)...
xmlns="msearch" is the in-scope namespace declaration?
If this declaration were not to exist, would a declared default attribute
namespace be utilized?
Date: Fri, 29 Jan 2010 13:29:34 -0800
From: Michael
Blakeley<[email protected]</mc/[email protected]>>
Subject: Re: [MarkLogic Dev General] 4.1 vs 3.2 attribute namespace
To: General Mark Logic Developer Discussion
<[email protected]</mc/[email protected]>>
Cc: Paul M<[email protected]</mc/[email protected]>>
Message-ID:<[email protected]</mc/[email protected]>>
Content-Type: text/plain; charset=UTF-8; format=flowed
Paul,
If $pr-qname didn't have a namespace in 3.2, that may have been a bug in
3.2. Per
http://www.w3.org/TR/xquery-operators/#constructor-qname-notation the
xs:QName() constructor is affected by in-scope namespace declarations.
In this situation I would use the fn:QName() function, which takes a
separate namespace parameter. That can be the empty string.
...
let $pr-qname := QName('', fn:concat("ps-rk-",$pos))
...
Alternatively, you could leave $pr-qname as a string.
...
let $pr-qname := fn:concat("ps-rk-",$pos)
...
Either way, the result is the same: the constructed attribute is in the
empty namespace.
<m-ps-group xmlns="msearch"><m-ps-rk-1>8888</m-ps-rk-1><m-ps-cd
ps-rk-1="8888">8888</m-ps-cd><m-ps-text
ps-cd="8888">alleights</m-ps-text></m-ps-group>
-- Mike
On 2010-01-29 10:49, Paul M wrote:
xquery version "0.9-ml"
define function processm-p() as node()*
{
<m-ps-group xmlns="msearch">
{
let $pos := "1"
let $new-value := "8888"
let $ps-text := "alleights"
let $pr-qname := xs:QName(fn:concat("ps-rk-",$pos))
let $epr-qname := xs:QName(fn:concat("m-ps-rk-",$pos))
return (element {$epr-qname} {$new-value}, element m-ps-cd {attribute {$pr-qname}
{$new-value}, $new-value},<m-ps-text
ps-cd="{$new-value}">{$ps-text}</m-ps-text>)
}
</m-ps-group>
}
let $s := processm-p()
return $s
<m-ps-group xmlns="msearch">
<m-ps-rk-1>8888</m-ps-rk-1>
<m-ps-cd _1:ps-rk-1="8888" xmlns:_1="msearch">8888</m-ps-cd><m-ps-text
ps-cd="8888">alleights</m-ps-text>
</m-ps-group>
When run under 3.2, the attribute ps-rk-1 does not contain a namespace...
So what would be the best method to make certain ps-rk-1 does not have a
namespace, if possible?
let $pr-qname := xs:QName(fn:concat("ps-rk-",$pos))
No namespace was specified.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general