473,698 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="20 04-06-01T00:00:00.000 0000+01:00"
TeacherCode="da volio" ClassCode="Juni or Infants" StudentCode="An a Trujillo"
NoteReceived="t rue" LeaveGiven="fal se" StudentLate="tr ue" ReasonCode="Fir st
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="20 04-06-01T00:00:00.000 0000+01:00"
TeacherCode="da volio" ClassCode="Juni or Infants" StudentCode="An a Trujillo"
NoteReceived="t rue" LeaveGiven="fal se" StudentLate="tr ue" ReasonCode="Fir st
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>possib le 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.Configur ation.Configura tionSettings.Ap pSettings["PrimaryProvide r"];
System.String strDataSource =
System.Configur ation.Configura tionSettings.Ap pSettings["PrimarySou rce"];
System.String strConnection = strProvider + " ; " + strDataSource;
System.Data.Ole Db.OleDbConnect ion objConnection = new
System.Data.Ole Db.OleDbConnect ion(strConnecti on);
System.Data.Ole Db.OleDbCommand objCommand = new
System.Data.Ole Db.OleDbCommand ("SELECT * FROM qryAbsence",obj Connection);
objCommand.Comm andTimeout=6000 0;
System.Data.Ole Db.OleDbDataAda pter objAdapter = new
System.Data.Ole Db.OleDbDataAda pter(objCommand );
System.Data.Dat aSet objDataset = new DataSet("Absenc es");
objAdapter.Fill (objDataset, "Absences") ;
System.Xml.XmlD ataDocument objSource = new
System.Xml.XmlD ataDocument(obj Dataset);
System.Xml.Xsl. XslTransform objTransform = new
System.Xml.Xsl. XslTransform();
objTransform.Lo ad(@"http://localhost/GetAbsent/GetAbsent.xslt" );

System.IO.Strin gWriter sw = new System.IO.Strin gWriter();
objTransform.Tr ansform(objSour ce, null, sw, new
System.Xml.XmlU rlResolver());
sw.Close();

strResult = sw.ToString();

objDataset.Disp ose();
objAdapter.Disp ose();
objCommand.Disp ose();
objConnection.D ispose();

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 1785

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

Similar topics

1
363
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. Basically, all of the data is stored in an Access .mdb that is read into a dataset when the application is loaded. There are some minor changes to the schema between what is in the physical database to accomodate some things that Access just...
10
3312
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 better way to format what I want ,says some attributes & some elements ?? Is it easy ?? or I must using string.format each datarow in the dataset to construct the xml or via xslt to transform ?? any idea ?? Regards,
0
554
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 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"...
4
1682
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 exist yet in the entries in my database2. i am using INSERT INTO table_in_database2 SELECT fields_from_table_in_database1 FROM table_in_database1 IN directory_of_database1. i was trying to put a WHERE command but i always get an error. please help.
0
2073
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 using my XSLT file returns ok. I bleive the dataset schema is correct too, but is there any way to debug the schema or the XMLRead method? XslTransform trans = new XslTransform(); trans.Load(Server.MapPath("mytest.xslt")); XmlUrlResolver...
3
1816
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 based on the XML file I get from excel 2. Use a WriteXML to create a XML file in the format I need. Will this work? How do I get started on this? Are there any other alternate ways of doing this?
4
1671
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
3121
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, dataset.writexml works great (got the code from http://forums.devx.com/archive/index.php/t-57273.html ) The only question I have is, when Excel opens up, it isn't the view I would prefer. It opens as a read-only workbook, I would prefer as an
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
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
8860
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...
1
6518
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
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
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
3
1998
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.