|
Home > Archive > MS SQL XML > September 2005 > SQL Server 2005 XML: Namespaces Not Being Hit/Used
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
SQL Server 2005 XML: Namespaces Not Being Hit/Used
|
|
| GrasshopperQ 2005-09-13, 8:24 pm |
| Any use of namespaces within SQL Server 2005 XQueries or Schemas has been
completely fruitless for me. E.g.
SELECT
@ValidXML.value('declare namespace
fn="http://www.w3.org/2005/04/xpath-functions";
fn:month-from-date(shiftDate)', 'varchar(2)')
consistently produces the following error:
Msg 2395, Level 16, State 1, Procedure HgTimeClock_LoadEntr
ies, Line 40
XQuery [value()]: There is no function
'{http://www.w3.org/2005/04/xpath-functions}:month-from-date()'
This is not the only example of a namespace not being used, though I won't
bore you with the rest.
Can someone PLEASE tell me what I'm missing?
Thanks!
| |
| Michael Rys [MSFT] 2005-09-20, 8:24 pm |
| You are missing:
a) That the fn prefix is predefined in the methods to the July 2004 working
draft. If you overwrite it with a later namespace, it will be taken as a
function that we have no knowledge about.
b) That we currently do not implement all functions of the XQuery F&O
library (for a variety of reasons, including stability of the spec). Books
Online provides you with the list of functions that we implement.
I hope this helps.
Michael
"GrasshopperQ" < GrasshopperQ@discuss
ions.microsoft.com> wrote in message
news:048B4EFF-93DF-46F2-83F7- A7D6F73854F5@microso
ft.com...
> Any use of namespaces within SQL Server 2005 XQueries or Schemas has been
> completely fruitless for me. E.g.
>
> SELECT
> @ValidXML.value('declare namespace
> fn="http://www.w3.org/2005/04/xpath-functions";
> fn:month-from-date(shiftDate)', 'varchar(2)')
>
> consistently produces the following error:
>
> Msg 2395, Level 16, State 1, Procedure HgTimeClock_LoadEntr
ies, Line 40
> XQuery [value()]: There is no function
> '{http://www.w3.org/2005/04/xpath-functions}:month-from-date()'
>
> This is not the only example of a namespace not being used, though I won't
> bore you with the rest.
>
> Can someone PLEASE tell me what I'm missing?
>
> Thanks!
| |
| GrasshopperQ 2005-09-21, 1:26 pm |
| That helps solve 1/2 my problem, and many thanks for that. I now know that I
can use only the very few functions available not in the xpath-functions
namespace, but in...wherever SQL Server stores the functions that are gotten
from http://www.w3.org/2004/07/xpath-functions.
There's still the question of it it means anything at all to put references
to outside (non-SQL Server) namespaces in any XML? E.g. writing an XQuery
such as
'declare namespace func="http://www.w3.org/2005/02/xpath-functions";
hours-from-datetime("2005-01-01T08:00:00Z")'
would be worthless since it really doesn't go out to that namespace to get
those standard XPath Functions.
Is that correct?
"Michael Rys [MSFT]" wrote:
> You are missing:
>
> a) That the fn prefix is predefined in the methods to the July 2004 working
> draft. If you overwrite it with a later namespace, it will be taken as a
> function that we have no knowledge about.
> b) That we currently do not implement all functions of the XQuery F&O
> library (for a variety of reasons, including stability of the spec). Books
> Online provides you with the list of functions that we implement.
>
> I hope this helps.
> Michael
>
>
>
> "GrasshopperQ" < GrasshopperQ@discuss
ions.microsoft.com> wrote in message
> news:048B4EFF-93DF-46F2-83F7- A7D6F73854F5@microso
ft.com...
>
>
>
| |
| Michael Rys [MSFT] 2005-09-21, 1:26 pm |
| Note that in XQuery, the namespace declaration is just associating a prefix
with a URI. It does not load any resources. If you look at the XQuery
processing model in the XQuery spec, you will see that there is a set of
preloaded functions that the names can be resolved to. At some point, we may
add more functions to that list, including different namespace versions of
the same function.
Best regards
Michael
"GrasshopperQ" < GrasshopperQ@discuss
ions.microsoft.com> wrote in message
news:AEA1FFB8-72A6-477E-BC7D- 204D1D8747FE@microso
ft.com...[color=darkred]
> That helps solve 1/2 my problem, and many thanks for that. I now know
> that I
> can use only the very few functions available not in the xpath-functions
> namespace, but in...wherever SQL Server stores the functions that are
> gotten
> from http://www.w3.org/2004/07/xpath-functions.
>
> There's still the question of it it means anything at all to put
> references
> to outside (non-SQL Server) namespaces in any XML? E.g. writing an XQuery
> such as
>
> 'declare namespace func="http://www.w3.org/2005/02/xpath-functions";
> hours-from-datetime("2005-01-01T08:00:00Z")'
>
> would be worthless since it really doesn't go out to that namespace to get
> those standard XPath Functions.
>
> Is that correct?
>
>
>
> "Michael Rys [MSFT]" wrote:
>
| |
| GrasshopperQ 2005-09-21, 1:26 pm |
| Is there a reason at all, then, to use namespace references in any
XML-related functionality in SQL Server? If I reference an XLST or an online
custom set of xpath functions or whatever, and it's not going out there to
get the reference, it would make sense to not bother with namespaces, right?
"Michael Rys [MSFT]" wrote:
> Note that in XQuery, the namespace declaration is just associating a prefix
> with a URI. It does not load any resources. If you look at the XQuery
> processing model in the XQuery spec, you will see that there is a set of
> preloaded functions that the names can be resolved to. At some point, we may
> add more functions to that list, including different namespace versions of
> the same function.
>
> Best regards
> Michael
>
>
> "GrasshopperQ" < GrasshopperQ@discuss
ions.microsoft.com> wrote in message
> news:AEA1FFB8-72A6-477E-BC7D- 204D1D8747FE@microso
ft.com...
>
>
>
| |
| Michael Rys [MSFT] 2005-09-21, 8:24 pm |
| Namespaces serve a specific base semantics: To allow to scope names to an
application-specific domain to avoid name clashes. Declaring the prefixes in
XQuery and XML is a purely syntactic way of having to avoid to write
/{http://www.example.com}doc/{....}element etc every time.
In addition, the URIs can be associated with resources such as a schema
collection, a document, or a function library. However, you need mechanisms
to manage such resources inside the database for a variety of reasons
(stability of metadata and data, security etc).
In SQL Server 2005, we currently only provide schema collections and since
we have external mechanisms to bind them to the data, the XQuery
functionality can pick them up. However, even though we now have schema
namespace URIs implicitly made available, we still need a way to bind the
prefixes to be able to refer to the types, elements and attributes defined
in the schema. That's why you still need the namespace declaration syntax.
For example, if you define a schema collection SC that contains a schema
with the target namespace http://example.com and a user-defined atomic type
hatSize that derives from xs:integer, you want to be able to write XQueries
such as
declare namespace f = "http://example.com";
f:hatSize(6) (:casts 6 to an instance of hatSize :)
declare namespace f= "http://example.com";
data(/f:doc/f:a/@f:x) instance of f:hatSize
Best regards
Michael
"GrasshopperQ" < GrasshopperQ@discuss
ions.microsoft.com> wrote in message
news:AFF87091-3187-4648-A84D- 8E595D1EE981@microso
ft.com...[color=darkred]
> Is there a reason at all, then, to use namespace references in any
> XML-related functionality in SQL Server? If I reference an XLST or an
> online
> custom set of xpath functions or whatever, and it's not going out there to
> get the reference, it would make sense to not bother with namespaces,
> right?
>
>
>
> "Michael Rys [MSFT]" wrote:
>
|
|
|
|
|