473,396 Members | 1,966 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,396 software developers and data experts.

From dataset to ADODB/XML persistance format, via XSLT

I have a web service that takes the XML representation of a dataset and uses
XSLT to transform it to the format required to open a disconnected ADODB
recordset on the XML, and returns the transformed XML as a string, for use
in an Access/VBA application. The transformed XML looks, in part, like this
....

<z:row AbsenceDate="2004-06-01T00:00:00.0000000+01:00"
TeacherCode="davolio" ClassCode="Junior Infants" StudentCode="Ana Trujillo"
NoteReceived="true" LeaveGiven="false" StudentLate="true" ReasonCode="First
Reason">
</z:row>
<z:row ...

.... etcetera - there are three records like this in the test data.

The problem is that ADODB can't handle this. With the XML in this format,
ADODB sees only the first record. It needs the XML to look like this, using
the abbreviated < ... /> format.

<z:row AbsenceDate="2004-06-01T00:00:00.0000000+01:00"
TeacherCode="davolio" ClassCode="Junior Infants" StudentCode="Ana Trujillo"
NoteReceived="true" LeaveGiven="false" StudentLate="true" ReasonCode="First
Reason"/>
<z:row ...

I can provide full steps to demonstrate and reproduce this problem, but they
are quite long, so I won't post them unless asked.

I'm told by people in the XSL newsgroup that most XSLT transformers output
the abbreviated < ... /> form as in the second example above unless there is
significant white space in either the XSLT or the source XML. I've tried
removing all unnecessary white space from the XSLT. That didn't change
anything. So I guess I need to somehow find and remove unnecessary white
space in the source XML (which is not created directly by my code, but
'behind the scenes' by ADO.NET, see code below ...) or alternatively,
perhaps using regular expressions, manipulate the transformed XML before
returning it, replacing any occurrence of <z:row whatever>possible white
space</z:row> with <z:row whatever/>

Any pointers on how to achieve either of the above would be welcome. Here's
the web service code (in C#):

[WebMethod]
public System.String GetData()
{
System.String strResult;
System.String strProvider =
System.Configuration.ConfigurationSettings.AppSett ings["PrimaryProvider"];
System.String strDataSource =
System.Configuration.ConfigurationSettings.AppSett ings["PrimarySource"];
System.String strConnection = strProvider + " ; " + strDataSource;
System.Data.OleDb.OleDbConnection objConnection = new
System.Data.OleDb.OleDbConnection(strConnection);
System.Data.OleDb.OleDbCommand objCommand = new
System.Data.OleDb.OleDbCommand("SELECT * FROM qryAbsence",objConnection);
objCommand.CommandTimeout=60000;
System.Data.OleDb.OleDbDataAdapter objAdapter = new
System.Data.OleDb.OleDbDataAdapter(objCommand);
System.Data.DataSet objDataset = new DataSet("Absences");
objAdapter.Fill(objDataset, "Absences");
System.Xml.XmlDataDocument objSource = new
System.Xml.XmlDataDocument(objDataset);
System.Xml.Xsl.XslTransform objTransform = new
System.Xml.Xsl.XslTransform();
objTransform.Load(@"http://localhost/GetAbsent/GetAbsent.xslt");

System.IO.StringWriter sw = new System.IO.StringWriter();
objTransform.Transform(objSource, null, sw, new
System.Xml.XmlUrlResolver());
sw.Close();

strResult = sw.ToString();

objDataset.Dispose();
objAdapter.Dispose();
objCommand.Dispose();
objConnection.Dispose();

return strResult;

}

--
Brendan Reynolds (Access MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.

Nov 12 '05 #1
0 1743

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

Similar topics

1
by: Wil | last post by:
I'm very new to developing in .NET and even newer to XML. The past few days have been pretty frustrating for me because I'm trying to perform a transform on data in a dataset and it's not working....
10
by: .Net_Newbie | last post by:
Hello, gurus I have a problem about format XML I use ms data access building block to get a data set from stored procedure. the dataset's save xml give me data with the elements. Is there any...
0
by: Brendan Reynolds | last post by:
I have a web service that takes the XML representation of a dataset and uses XSLT to transform it to the format required to open a disconnected ADODB recordset on the XML, and returns the...
4
by: nick_faye | last post by:
hi guys, hope somebody can assist me. i have two ms access database. i have to copy the entries in database1 to my database2. however, i have to copy entries from database1 that does not...
0
by: jake.jacobsen | last post by:
Hello. I'm getting an error on the XMLRead method of a dataset class. The error is "Input string was not in a correct format." I've verified that the xml is valid and the transform of the XML...
3
by: sandeshmeda | last post by:
I have a XML file that is basically a Excel file saved as XML. I need to be able to change the XML into a different format. I was thinking one approach would be to: 1. Populate the dataset...
4
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:
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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,...

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.