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.