473,804 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPath and SQLXML

I have the following XSD created in VS.NET 2003:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ReferralSch ama" targetNamespace ="http://test.org/Referral"
elementFormDefa ult="unqualifie d"
xmlns="http://test.org/Referral" xmlns:mstns="ht tp://test.org/Referral"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:complexTy pe name="ReferralT ype">
<xs:sequence>
<xs:element name="nReferral Id" msdata:ReadOnly ="true"
msdata:AutoIncr ement="true" type="xs:int"/>
<xs:element name="nPersonId " type="xs:int"/>
<xs:element name="nReferral Number" type="xs:int"/>
<xs:element name="dReferral Date" type="xs:dateTi me"/>
<xs:element name="dDateOfBi rth" type="xs:dateTi me"/>
<xs:element name="dDateOfDe ath" type="xs:dateTi me"/>
</xs:sequence>
</xs:complexType>

<xs:element name="Document" >
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="tReferral " type="mstns:Ref erralType"/>
</xs:choice>
</xs:complexType>
<xs:unique name="ReferralK ey" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:tReferral "/>
<xs:field xpath="mstns:nR eferralId"/>
</xs:unique>
</xs:element>
</xs:schema>

and am attempting to load it via the SqlXmlAdapter in SQLXML3.0 as follows:
try
{
SqlXmlCommand cmd = new SqlXmlCommand(C onnString);
cmd.RootTag = "ROOT";
cmd.CommandText = txtXPath.Text;
cmd.CommandType = SqlXmlCommandTy pe.XPath;
cmd.SchemaPath = "..\\..\\Referr alSchama.xsd";

//load data set
DataSet ds = new DataSet();
SqlXmlAdapter ad = new SqlXmlAdapter(c md);
ad.Fill(ds);
}
catch (Exception ex)
{
Console.Write(e x.Message);
}

I've attempting to use various XPath statements such as the following to
load the data, but it fails with the following exception every time:

"XPath: unable to find /XXXXX in the schema".

XPath tried:
tReferral
tDocument/tReferral
Document/tReferral/nReferralId=1
tReferral/nReferralId=1
Document/tReferral/[@nReferralId=1]
tReferral/[@nReferralId=1]

Anyone know what I'm doing wrong?
Nov 12 '05 #1
1 3039
You haven't included the namespace. Use the SqlXmlCommand's Namespaces
property to reference the http://test.org/Referral namespace (see Executing
XPath Queries with Namespaces in the SQLXML .NET Framework Support > SQLXML
Managed Classes > Using the SQLXML Managed Classes topic of the SQLXML 3.0
docs).

Hope that heps,
Graeme

--
----
Graeme Malcolm
Principal Technologist
Content Master Ltd.
www.contentmaster.com
"Hollywood" <ho*******@thze ro.com> wrote in message
news:uZ******** *******@TK2MSFT NGP09.phx.gbl.. .
I have the following XSD created in VS.NET 2003:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ReferralSch ama" targetNamespace ="http://test.org/Referral"
elementFormDefa ult="unqualifie d"
xmlns="http://test.org/Referral" xmlns:mstns="ht tp://test.org/Referral"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:complexTy pe name="ReferralT ype">
<xs:sequence>
<xs:element name="nReferral Id" msdata:ReadOnly ="true"
msdata:AutoIncr ement="true" type="xs:int"/>
<xs:element name="nPersonId " type="xs:int"/>
<xs:element name="nReferral Number" type="xs:int"/>
<xs:element name="dReferral Date" type="xs:dateTi me"/>
<xs:element name="dDateOfBi rth" type="xs:dateTi me"/>
<xs:element name="dDateOfDe ath" type="xs:dateTi me"/>
</xs:sequence>
</xs:complexType>

<xs:element name="Document" >
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="tReferral " type="mstns:Ref erralType"/>
</xs:choice>
</xs:complexType>
<xs:unique name="ReferralK ey" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:tReferral "/>
<xs:field xpath="mstns:nR eferralId"/>
</xs:unique>
</xs:element>
</xs:schema>

and am attempting to load it via the SqlXmlAdapter in SQLXML3.0 as follows:
try
{
SqlXmlCommand cmd = new SqlXmlCommand(C onnString);
cmd.RootTag = "ROOT";
cmd.CommandText = txtXPath.Text;
cmd.CommandType = SqlXmlCommandTy pe.XPath;
cmd.SchemaPath = "..\\..\\Referr alSchama.xsd";

//load data set
DataSet ds = new DataSet();
SqlXmlAdapter ad = new SqlXmlAdapter(c md);
ad.Fill(ds);
}
catch (Exception ex)
{
Console.Write(e x.Message);
}

I've attempting to use various XPath statements such as the following to
load the data, but it fails with the following exception every time:

"XPath: unable to find /XXXXX in the schema".

XPath tried:
tReferral
tDocument/tReferral
Document/tReferral/nReferralId=1
tReferral/nReferralId=1
Document/tReferral/[@nReferralId=1]
tReferral/[@nReferralId=1]

Anyone know what I'm doing wrong?

Nov 12 '05 #2

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

Similar topics

1
1795
by: Mark Sisson | last post by:
Ok gurus, what would you do? I'm developing an app in C# and trying to use SqlXml but there seems to be a problem at every turn. I want to create a biz object that represents an order to sell a home. The database schema for this order has about 15 related tables therefore I need to also have 15 related biz classes (for my brokers, appraisals, repairs, offers yada yada yada). The database schema may change slightly from week to week with...
0
1070
by: Ralph Krausse | last post by:
Hello all, Newbie here and have a few questions. I wish to use the classes SqlXmlAdapter,SqlXmlCommand,etc in my ASP.NET project but when I add 'using Microsoft.Data.SqlXml', the IDE doesn't see the namespace. I tried to add the reference but I dont see it. 1. Why is that? Do I have to download and install SqlXml 3.0 SP2? Does that add the namespace? I searched for Microsoft.Data.SqlXml.dll on my hard drive and didn't find it.
0
1064
by: Nick Chan | last post by:
hello i exposed some stored procs as web methods, is there a way to use authentication? i just want to set only me can use it. And is there a way to save the SQLXML IIS Settings and export to another PC ?
0
1568
by: Paula DiTallo | last post by:
Hello Techies-- I am reading an XML document with many nested elements. Many of these elements go to such a variety of tables, that I am trying to simply the read of the document by dumping the data into a single table using SQLXML/BulkXMLLoad. I have triggers set on an insert of this table to cascade inserts to the appropriate myriad of other tables. Originally I tried to use simpleType, then I tried to use: complexType, mixed="true"...
1
1421
by: norm dingle | last post by:
Does anyone know how to get the managed classes for sqlxml loaded? I can not seem to get them to load. Thanks norm
3
1719
by: David Elliott | last post by:
I am in the process of creating an application to scrape databases in order to create typed DataSets. One of the last pieces that I need to do is to remap database fields to something more pleasant. In order to do this I have created a static map that will perform the transformation. Below is a sample of an XML Schema that would be returned from the database. What I am looking to do is given a column name, find the node. For...
4
1659
by: Don | last post by:
Hi: When I read my sqlxml results into a reader and deserialize it, I only get the first record deserialized into my object. If I have five records, they're all in the reader. But how do I get access to all of them via an object or objects? Do I need an object collection? Here's my XML that comes back from SQL Server: <Employees empid="1" lastname="Ng" firstname="William" title="Technical Consultant" hiredate="01/01/1999"/>
1
2700
by: campwes | last post by:
Hey, all! We're having trouble displaying SQL Server data in a web site as XML, using a transform. The query is a simple SELECT statement. When running the query, we get the following error from the web site: <error> Microsoft.Data.SqlXml.Common.ISQLXMLCommandManagedInterface.ExecuteToOutputStream() +0 Microsoft.Data.SqlXml.SqlXmlCommand.innerExecute(Stream strm) +137
0
1419
by: RJ | last post by:
I saw an article on MSDN knowledge base that explains how to use a SQLXML tool ( IIS Configuration ) to select a stored procedure and generate a web service wrapper. I noticed that the example to call the generated web service was VBScript / VB6 / COM. When I go to VS.NET and create a VB.NET WinForm app, then try to add the web reference to the SQLXML generated web service, the VS.NET dialog "Web Services on the Local Machine" does list...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.