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.