Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

XQuery Help Expand / Collapse
Author
Message
Posted Thursday, May 27, 2010 4:02 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, August 7, 2014 4:41 PM
Points: 238, Visits: 652
Hi fellow developers. I am new to XQuery and have an issue. Based on the following XML I can't get any results unless I remove the namespace information at the top. Is there anyway to ignore the namespace. I have tried the following:

TABLE:
/****** Object: Table [dbo].[Students] Script Date: 05/27/2010 14:57:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Students](
[StudentName] [varchar](50) NULL,
[Labid] [int] NULL,
[Experimentid] [int] NULL,
[ExperimentChemical] [xml] NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

---------------------------------------------------------------------------------
DATA:
INSERT INTO students
SELECT
'ABC',
3,
3,
'
<ATOM xmlns="urn://valence.aero/schemas/airtransport/ATOM/300" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn://valence.aero/schemas/airtransport/ATOM/300 ATOM.300.00.xsd">
<Destination>
<Identity />
</Destination>
<Source>
<Identity>
<Organisation>qantas.com.au</Organisation>
<Function>EI</Function>
<Location>SYD</Location>
<ProcessID>OgsAtomChangeNotification</ProcessID>
</Identity>
<GenerationTime>2010-05-24T11:14:08.355+10:00</GenerationTime>
</Source>
</ATOM>
'

---------------------------------------------------------------------------------
QUERY:
SELECT *
FROM students
WHERE experimentchemical.exist('/ATOM/Source/Identity[Location="SYD"]') = 1

ALSO TRIED:
SELECT *
FROM students
WHERE experimentchemical.exist('//Source/Identity[Location="SYD"]') = 1
Post #929350
Posted Wednesday, May 8, 2013 7:35 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 12:10 PM
Points: 1,619, Visits: 1,236
I know this question is 2 years old, but thought I would answer it anyway.

I don't think you can 'ignore' the namespace, and your best bet may be to use a WITH XMLNAMESPACES clause:

SET ANSI_PADDING ON
GO
;WITH XMLNAMESPACES ('urn://valence.aero/schemas/airtransport/ATOM/300' AS ns)
SELECT *
FROM students
WHERE experimentchemical.exist('/ns:ATOM/ns:Source/ns:Identity[ns:Location="SYD"]') = 1



_________________________________
seth delconte
http://sqlkeys.com
Post #1450564
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse