473,511 Members | 16,888 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I use an industry standard XSD and ADO.NET / SQLServer to output a conforming XML file

We have tentatively agreed with a supplier to exchange order
information. The plan is to use an 'industry standard' order schema
definition from say www.xcbl.org.

Is there are simple way to use ADO.NET in this scenario.
Ideally (naively) I would like to do something along these lines :

1. Create a SQLServer stored proc that returns a dataset (or similar)
containing the order details such as :

select PurchaseOrderID,ProductID,Qty
from PurchaseOrder
join PurchaseOrderItem......

2. In a COM+ object (not entirely relevant to the problem, but this
is how it will work), I would expect to create a ADO.NET dataset
populated from a RPC to the above proc.

3. I would assume I need to tell ADO.NET about the xsd, and perhaps
provide some sort of field mapping?

4. I would then like to call some sort WriteXML method on the dataset
object

5. To complete the scenario, I expect I would then 'post' the XML
file to the supplier's web service.
I don't have a vast experience with XML, but I am comfortable that I
could (and may have to) code this manually, perhaps using the
XMLDocument class in the .net framework. I am at the stage of
exploring my options, and don't want to re-invent the wheel if the
functionality already exists.

Regards.
Nov 12 '05 #1
1 1860
Depending on the schema, there are a couple of ways to do it.
XSL would be one way: you could transform the incoming XML (From ADO.NET
query) into the form you like:

System.Xml.XmlDataDocument doc= new System.Xml.XmlDataDocument(dataset1);
System.Xml.Xsl.XslTransform x1= new System.Xml.Xsl.XslTransform ();
x1.Load(XslFilename);
MemoryStream ms = new MemoryStream();
x1.Transform(doc.CreateNavigator(), null, ms);
ms.Seek(0,System.IO.SeekOrigin.Begin);
string buf = (new StreamReader(ms)).ReadToEnd();

However, XSL is often not, ahhh, let's say, very approachable. So you may
want to use a tool to design the XSL. Or get the help of an expert. (I
don't know of a way to automatically or mechanically generate an XSL
transform, given a starting XSD and an ending XSD. )

Try www.topxml.com for an intro.

Another option if your database is SQL Server is to use SQL2000's FOR XML
support in your queries. You can shape the output XML exactly as you would
like. Again, though, there is some arcane syntax involved.
For example, here's a query I used to retrieve a bunch of FAQ entries from a
table:

SELECT 1 AS Tag,
NULL AS Parent,
'' as [FaqList!1!],
NULL as [Category!2!CategoryName!element],
NULL as [FAQ!3!ID!element],
NULL as [FAQ!3!timestamp!element],
NULL as [FAQ!3!Question!element],
NULL as [FAQ!3!Answer!element]

UNION ALL
select 2 as Tag,
1 as Parent,
'',
rtrim(c.[category name]),
NULL, NULL, NULL, NULL
FROM faq_categories c

UNION ALL
SELECT 3 AS Tag,
2 AS Parent,
'',
rtrim(c.[category Name]),
rtrim(f.ix),
f.timestamp,
rtrim(f.question),
rtrim(f.answer)
FROM faq_categories c, faq f
WHERE c.ix = f.category_ix
ORDER BY [Category!2!CategoryName!element], [FAQ!3!Question!element]
FOR XML EXPLICIT

Not a pretty sight, is it?
For more on this, check out
http://www.eggheadcafe.com/articles/20030804.asp

Whether you use XSL or SQLXML, be careful about performance.

-D

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ OmitThis . m i c r o s o f t . c o m

"Rossco" <rj******@gmail.com> wrote in message
news:2f**************************@posting.google.c om...
We have tentatively agreed with a supplier to exchange order
information. The plan is to use an 'industry standard' order schema
definition from say www.xcbl.org.

Is there are simple way to use ADO.NET in this scenario.
Ideally (naively) I would like to do something along these lines :

1. Create a SQLServer stored proc that returns a dataset (or similar)
containing the order details such as :

select PurchaseOrderID,ProductID,Qty
from PurchaseOrder
join PurchaseOrderItem......

2. In a COM+ object (not entirely relevant to the problem, but this
is how it will work), I would expect to create a ADO.NET dataset
populated from a RPC to the above proc.

3. I would assume I need to tell ADO.NET about the xsd, and perhaps
provide some sort of field mapping?

4. I would then like to call some sort WriteXML method on the dataset
object

5. To complete the scenario, I expect I would then 'post' the XML
file to the supplier's web service.
I don't have a vast experience with XML, but I am comfortable that I
could (and may have to) code this manually, perhaps using the
XMLDocument class in the .net framework. I am at the stage of
exploring my options, and don't want to re-invent the wheel if the
functionality already exists.

Regards.

Nov 12 '05 #2

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

Similar topics

2
2290
by: cpeters5 | last post by:
Deaa group, I am using SQLServer 2000 in an XP Sp2. I would like to do the following: I have a program running on a database server that generates some data which are loaded to the database....
31
2767
by: Bill Cunningham | last post by:
There must be some change in the standard because I ran into this error when I put this line in a header. # pragma once I only wanted the headers to be included once. The compiler said something...
9
1407
by: James Harris | last post by:
I'm wanting to write in C some code in which it is necessary to address a device as I/O space rather than as part of memory. I would like the code to be as standard - and hence as portable - as...
14
1769
by: E. Robert Tisdale | last post by:
I am a long time subscriber to the comp.lang.c newsgroup. Recently (over the last few years), comp.lang.c subscribers have been citing and quoting ANSI/ISO C standards documents to support their...
4
1666
by: Bill Nguyen | last post by:
I wonder if I can write to an XML file using column structure (and column names) of an SQLserver table. for example: Table A: column1 int column2 char(30) column3 date XML output:
85
4750
by: fermineutron | last post by:
Some compilers support __asm{ } statement which allows integration of C and raw assembly code. A while back I asked a question about such syntax and was told that __asm is not a part of a C...
270
9221
by: jacob navia | last post by:
In my "Happy Christmas" message, I proposed a function to read a file into a RAM buffer and return that buffer or NULL if the file doesn't exist or some other error is found. It is interesting...
24
1789
by: Fumeur | last post by:
Is the following program standard conform? (reduced as much as possible so it still shows the problem) /* begin */ #include <stdio.h> void xfprintf(FILE *); void xfprintf(FILE *f) {...
20
2205
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code -----------------------------------...
0
7242
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,...
0
7510
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...
0
5668
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,...
1
5066
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...
0
3225
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...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
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 ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
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...

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.