L
Lars Moastuen
I'm currently writing a webservice. I've successfully written a
service that gives me some XML data, but now I want to link a
XLS-stylesheet to that data. The way I'm trying to do that is to
create a webmethod that returns a XmlDataDocument, and use
CreateProcessingInstruction() to add a "stylesheet-header"... Problem
is that the headers I add using CreateProcessingInstruction() seems to
be removed (?) when the data is transferred over the web. When I use
XmlDocument.Save() the output is fine... What causes this? Is there
any workaround?
The optimal solution would allow me to return a ADO.NET DataSet, and
still link an XLS-datasheet to the document. Reason is that I'm
intending to use the service with crystal reports through the ADO.NET
driver (doesn't recognize methods not returning DataSet). Is there a
way?
My method is as follows:
[WebMethod]
public XmlDataDocument test()
{
Basin tree = db.GetBasinTree();
DataSet ds = new DataSet();
ds.EnforceConstraints = false;
DataTable tb = ds.Tables.Add("basin");
tb.Columns.Add("basinid", typeof(Decimal));
tb.Columns.Add("basinname", typeof(String));
tb.Columns.Add("parent", typeof(Decimal));
tb.Columns.Add("haschildren", typeof(bool));
AddBasinChildren(tb, tree);
XmlDataDocument xmlDoc = new XmlDataDocument(ds);
String stylesheet = "type=\"text/xsl\" href=\"test.xsl\"";
XmlProcessingInstruction xlsNode =
xmlDoc.CreateProcessingInstruction("xml-stylesheet", stylesheet);
xmlDoc.InsertBefore(xlsNode, xmlDoc.DocumentElement);
xmlDoc.Save("c:\\temp\\thisworks.xml");
return xmlDoc;
}
Help appreciated!
Lars Moastuen
GeoKnowledge
service that gives me some XML data, but now I want to link a
XLS-stylesheet to that data. The way I'm trying to do that is to
create a webmethod that returns a XmlDataDocument, and use
CreateProcessingInstruction() to add a "stylesheet-header"... Problem
is that the headers I add using CreateProcessingInstruction() seems to
be removed (?) when the data is transferred over the web. When I use
XmlDocument.Save() the output is fine... What causes this? Is there
any workaround?
The optimal solution would allow me to return a ADO.NET DataSet, and
still link an XLS-datasheet to the document. Reason is that I'm
intending to use the service with crystal reports through the ADO.NET
driver (doesn't recognize methods not returning DataSet). Is there a
way?
My method is as follows:
[WebMethod]
public XmlDataDocument test()
{
Basin tree = db.GetBasinTree();
DataSet ds = new DataSet();
ds.EnforceConstraints = false;
DataTable tb = ds.Tables.Add("basin");
tb.Columns.Add("basinid", typeof(Decimal));
tb.Columns.Add("basinname", typeof(String));
tb.Columns.Add("parent", typeof(Decimal));
tb.Columns.Add("haschildren", typeof(bool));
AddBasinChildren(tb, tree);
XmlDataDocument xmlDoc = new XmlDataDocument(ds);
String stylesheet = "type=\"text/xsl\" href=\"test.xsl\"";
XmlProcessingInstruction xlsNode =
xmlDoc.CreateProcessingInstruction("xml-stylesheet", stylesheet);
xmlDoc.InsertBefore(xlsNode, xmlDoc.DocumentElement);
xmlDoc.Save("c:\\temp\\thisworks.xml");
return xmlDoc;
}
Help appreciated!
Lars Moastuen
GeoKnowledge