473,385 Members | 2,005 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,385 software developers and data experts.

WebMethod, XmlDocument and CreateProcessingInstruction

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
Nov 22 '05 #1
3 2508
I am trying to do an identical thing

Did you ever find the solution ?

David Davies,
Goldman Sachs

"Lars Moastuen" wrote:
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

Nov 22 '05 #2
Trying a cross post to
microsoft.public.dotnet.framework.webservices

"David Davies" wrote:
I am trying to do an identical thing

Did you ever find the solution ?

David Davies,
Goldman Sachs

"Lars Moastuen" wrote:
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

Nov 22 '05 #3
Try Cross posting to dotnet.framework.webservices

"David Davies" wrote:
I am trying to do an identical thing

Did you ever find the solution ?

David Davies,
Goldman Sachs

"Lars Moastuen" wrote:
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

Nov 22 '05 #4

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

Similar topics

0
by: Shawn | last post by:
Hi. I'm using XMLDOM to write xml to the browser, but it won't display the encoding I've specified. This is the code I'm using: Set objPI = xmlDoc.createProcessingInstruction("xml",...
3
by: Lars Moastuen | last post by:
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...
3
by: sd | last post by:
Hello All, I aplogize if this has already been answered however I couldn't find anything related to this... I have bunch of webservices written in vb.net returning native data types, due to...
3
by: schneider | last post by:
The DocumentElement is always null? and is readonly? How to I add node items to the root? I'm try to create a document from nothing. All the samples start by loading a string or file. ...
2
by: Raj | last post by:
I am using a SOAP WebMethod -ASP.net (wse2.0) public SoapEnvelope Request() { return SoapEnvelope } The results come back in an indented format as below even if I dont have any newline or...
2
by: Peter McEvoy | last post by:
Folks, I've been building a Webservice API for a contract that will be exposed to the internet at large. There are two endpoints, and each endpoint contains a number of webmethods. Every...
4
by: MattBell | last post by:
I've tried to search for an answer to this without much success, and I think it's probably a common thing to do: I have a web service I want to accept an XmlDocument as an argument which conforms...
8
by: Thirsty Traveler | last post by:
I have a WebMethod as follows: public XmlDocument OrderContract(XmlDocument doc) { return OrderBLL.OrderContract(doc); } However, the client is generating a compile error when the...
1
by: olrt | last post by:
Hello, I have designed a WebService with the following method : public DbAppAnswer GetDs(DbAppRequest request) DbAppRequest and DbAppAnswer are defined as :
1
by: Martin Pöpping | last post by:
Hello, is there a way to add a stylhesheet like: <?xml-stylesheet type="text/css" href="styles.css" ?> to an XmlDocument?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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:
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...
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,...

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.