473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Xquery Help Sql 2005

CK
I have the following XML in an XML column in a SQL 2005 Database.
<DeliveryList xmlns="http://schemas.adventure-works.com/DeliverySchedule">
<Delivery SalesOrderID="43659">
<CustomerName>Steve Schmidt</CustomerName>
<Address>6126 North Sixth Street, Rockhampton</Address>
</Delivery>
<Delivery SalesOrderID="43660">
<CustomerName>Tony Lopez</CustomerName>
<Address>6445 Cashew Street, Rockhampton</Address>
</Delivery>
</DeliveryList>

I need to query that column using the value method to retreive the address
of the first delivery. I come up with this,
SELECT
DeliveryList.value('data((/DeliveryList/Delivery/Address)[1])','nvarchar(100)')
DeliveryAddress
FROM Sales.DeliverySchedule
but it tells me
XQuery [Sales.DeliverySchedule.DeliveryList.value()]: There is no element
named 'DeliveryList'
I have tried every permutation of the path and I can not seem to get it to
work? Any ideas?

Nov 22 '06 #1
5 3076
Like XPath and XSLT, XQuery is namespace-sensitive. To query an element
that is in a namespace (as these are, via the xmlns= default-namespace
declaration), you must tell XQuery what namespace it's in.

I believe that XQuery has a mechanism for specifying a default
namespace. (XSLT 1.0 didn't have that, but I believe XSLT 2.0 and XQuery
added it.) The alternative would be for your XQuery to use prefixes, and
for you to provide bindings for those prefixes to the proper namespace URIs.

I'm not sure how any of that would be accessed through SQL 2005, but
hopefully this will get you pointed in the right direction.
Nov 22 '06 #2
CK
Well here is the namespace.
http://schemas.adventure-works.com/DeliverySchedule

What do I do now?

"Joseph Kesselman" <ke************@comcast.netwrote in message
news:45649627$1@kcnews01...
Like XPath and XSLT, XQuery is namespace-sensitive. To query an element
that is in a namespace (as these are, via the xmlns= default-namespace
declaration), you must tell XQuery what namespace it's in.

I believe that XQuery has a mechanism for specifying a default namespace.
(XSLT 1.0 didn't have that, but I believe XSLT 2.0 and XQuery added it.)
The alternative would be for your XQuery to use prefixes, and for you to
provide bindings for those prefixes to the proper namespace URIs.

I'm not sure how any of that would be accessed through SQL 2005, but
hopefully this will get you pointed in the right direction.

Nov 22 '06 #3
CK wrote:
Well here is the namespace.
http://schemas.adventure-works.com/DeliverySchedule

What do I do now?
You read your tool's documentation to understand how it wants to to
specify namespaces to be used in queries. As I said, I haven't used that
particular tool so I can't advise you beyond that generality.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Nov 22 '06 #4
CK
You have not used Sql server?
Well thank you for your help anyways.

"Joseph Kesselman" <ke************@comcast.netwrote in message
news:4564bf94@kcnews01...
CK wrote:
>Well here is the namespace.
http://schemas.adventure-works.com/DeliverySchedule

What do I do now?

You read your tool's documentation to understand how it wants to to
specify namespaces to be used in queries. As I said, I haven't used that
particular tool so I can't advise you beyond that generality.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

Nov 22 '06 #5
You have to declare the namespace and prefix the elements from that
namespace like that:

SELECT
DeliveryList.value('
declare namespace
d="http://schemas.adventure-works.com/DeliverySchedule";
data((/d:DeliveryList/d:Delivery/d:Address)[1])','nvarchar(100)')
DeliveryAddress
FROM Sales.DeliverySchedule

Please make sure that the DeliverySchedule table was properly created:

CREATE TABLE DeliverySchedule (
....
DeliveryList XML(CONTENT DeliverySchema))

and the DeliverySchema was previously registered.

There is a good support for SQL Server 2005 XML features into our
oXygen XML editor (please check
http://www.oxygenxml.com/native_xml_databases.html)
You can edit and add XSD schemas to the SQL Server XSD repository,
define tables and run SQL/SQL/XML and XQuery interrogations using the
SQL Editor.

Stefan Vasile
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Nov 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ken North | last post by:
Dr. Michael Rys of Microsoft discusses SQL Server 2005 support for XQuery, SQL/XML and the SQL:2003 standard. He discusses b-tree, quadtree, and r-tree indexes and pluggable and selectable indexing...
0
by: Tony Lavinio | last post by:
Dear Stylus Studio Friends, The new year is scarcely one month old, but we already have lots to report! For starters, there's Stylus Studio 6 Release 2. The latest release of Stylus Studio...
0
by: Tony Lavinio | last post by:
Dear com.text.xml XML community: It's hard to imagine a major company that doesn't have at least some systems running SQL Server, or using Microsoft XML technologies for that matter. Because of...
0
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies...
8
by: Clamps | last post by:
So I've been reading about XQuery, but cannot find a dll or namespace download to use the technology in vs.net 2002 or 2003. Any directions would be great. -- "If I'm the president, we're going...
1
by: Philipp Schumann | last post by:
Hi .NET XML fans, does anyone know ad hoc whether support for the above standards is planned for .NET 2.0? I suppose this would be extremely valuable for many folks... Thanks, Phil
2
by: BK | last post by:
I am working on system that will have a cataloging component which would essentially be a Folder/File structure. So far I have coded the Iteration over a selected folder and am displaying the...
1
by: Shilpa | last post by:
Please let me know the advantages and disadvantages of XQuery vs OpenRowSet in SQL Server 2005. Which would be better? Regards, Shilpa
0
by: Manish | last post by:
I am new to XML. Initially I was saving all the settings in either PHP or text files or database tables and use to parse the config variables from files or query from the database. Now I want to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.