Hi, In the result of a function:inspect(), it seems that the @name of the function element is not a prefixed name when using the "declare default namespace" in a function module whereas it is prefixed name for the others. Is it me who miss something, or it should always be the same ? Thanks, Emmanuel
Hi Emmanuel,
I think the current behavior is correct. You'll indeed need to look at both the name and uri in order to reference the correct function. I just tried the following query:
declare default function namespace 'x'; declare namespace x='x'; declare function a() { 1}; declare function x:b() { 1}; declare function Q{x}c() { 1}; for $f in (a#0, x:b#0, Q{x}c#0) return inspect:function($f)/@name/fn:string()
It returns the following result:
<function name="a" uri="x"> <return type="xs:integer"/> </function> <function name="x:b" uri="x"> <return type="xs:integer"/> </function> <function name="c" uri="x"> <return type="xs:integer"/> </function>
Do you have another example to indicate what you are expecting in the result?
Thanks, Christian
Thanks for your answer.
I may be wrong, but for me uri (namespace) and prefix are not necessarily the same. So, I would expect always a prefixed name for @name, because when uri and prefix are different, it becomes impossible to deduce the prefixed name.
But it may need a closer look to the specification.
Best regards, Emmanuel
Le 24 févr. 2015 à 17:28, Christian Grün christian.gruen@gmail.com a écrit :
Hi Emmanuel,
I think the current behavior is correct. You'll indeed need to look at both the name and uri in order to reference the correct function. I just tried the following query:
declare default function namespace 'x'; declare namespace x='x'; declare function a() { 1}; declare function x:b() { 1}; declare function Q{x}c() { 1}; for $f in (a#0, x:b#0, Q{x}c#0) return inspect:function($f)/@name/fn:string()
It returns the following result:
<function name="a" uri="x"> <return type="xs:integer"/> </function> <function name="x:b" uri="x"> <return type="xs:integer"/> </function> <function name="c" uri="x"> <return type="xs:integer"/> </function>
Do you have another example to indicate what you are expecting in the result?
Thanks, Christian
I may be wrong, but for me uri (namespace) and prefix are not necessarily the same. So, I would expect always a prefixed name for @name, because when uri and prefix are different, it becomes impossible to deduce the prefixed name.
I see (I guess).. Could you provide us with some example code that demonstrates the confusion? Christian
But it may need a closer look to the specification.
Best regards, Emmanuel
Le 24 févr. 2015 à 17:28, Christian Grün christian.gruen@gmail.com a écrit :
Hi Emmanuel,
I think the current behavior is correct. You'll indeed need to look at both the name and uri in order to reference the correct function. I just tried the following query:
declare default function namespace 'x'; declare namespace x='x'; declare function a() { 1}; declare function x:b() { 1}; declare function Q{x}c() { 1}; for $f in (a#0, x:b#0, Q{x}c#0) return inspect:function($f)/@name/fn:string()
It returns the following result:
<function name="a" uri="x"> <return type="xs:integer"/> </function> <function name="x:b" uri="x"> <return type="xs:integer"/> </function> <function name="c" uri="x"> <return type="xs:integer"/> </function>
Do you have another example to indicate what you are expecting in the result?
Thanks, Christian
I’m trying an exemple below, but after a closer look, everything is alright. I was confused by QNames construction…
If we had two different modules.
In the first one
module namespace x = ‘x' ; declare default function namespace 'x'; declare function a() { 1}; declare function x:b() { 1}; declare function Q{x}c() { 1}; for $f in (a#0, x:b#0, Q{x}c#0) return inspect:function($f)/@name/fn:string()
In an other one
module namespace y = ‘y' ; declare function y:a() { 1}; declare function y:b() { 1}; declare function Q{y}c() { 1}; for $f in (a#0, y:b#0, Q{y}c#0) return inspect:function($f)/@name/fn:string()
And we would like to retrieve the QName of the function called « a » in the context, the one that exists in the module x if it exists and, if it doesn’t exists, the one in the module y :
let $context := inspect:context()//function[@name = ‘a’] return if( $context[@uri = ‘x'] ) then xs:QName($context/@uri/fn:string || : || $context/@name/fn:string) else if( $context[@uri = ‘y’] ) then xs:QName($context/@uri/fn:string || : || $context/@name/fn:string) else ’something else'
There would be an issue if we wanna built a QName with xs:QName. But I think it could be OK if we were building a QName with fn:QName because the name is optionally prefixed with fn:QName ( fn:QName( $context/@uri/fn:string, $context/@name/fn:string) )
So, in fact, everything is all right.
Thanks a lot,
Emmanuel
Le 24 févr. 2015 à 18:19, Christian Grün christian.gruen@gmail.com a écrit :
I may be wrong, but for me uri (namespace) and prefix are not necessarily the same. So, I would expect always a prefixed name for @name, because when uri and prefix are different, it becomes impossible to deduce the prefixed name.
I see (I guess).. Could you provide us with some example code that demonstrates the confusion? Christian
But it may need a closer look to the specification.
Best regards, Emmanuel
Le 24 févr. 2015 à 17:28, Christian Grün christian.gruen@gmail.com a écrit :
Hi Emmanuel,
I think the current behavior is correct. You'll indeed need to look at both the name and uri in order to reference the correct function. I just tried the following query:
declare default function namespace 'x'; declare namespace x='x'; declare function a() { 1}; declare function x:b() { 1}; declare function Q{x}c() { 1}; for $f in (a#0, x:b#0, Q{x}c#0) return inspect:function($f)/@name/fn:string()
It returns the following result:
<function name="a" uri="x"> <return type="xs:integer"/> </function> <function name="x:b" uri="x"> <return type="xs:integer"/> </function> <function name="c" uri="x"> <return type="xs:integer"/> </function>
Do you have another example to indicate what you are expecting in the result?
Thanks, Christian
basex-talk@mailman.uni-konstanz.de