i want to use the XSLT in Web Service for XML transformation, but it gives error. here is my XSL:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="tblXXX">
<xsl:choose>
<xsl:when test="Name!=''">
<xsl:value-of select="Name" /><br />
</xsl:when>
</xsl:choose>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
and here is the Code that i am using.
private const int CacheTime = 30;
public enum FaultCode
{
Client=0,
Server=1
}
[WebMethod(CacheDuration=CacheTime,Description="Get values from Database",EnableSession=true)]
public void GetStr(string rType)
{
try
{
string xslPath = Server.MapPath("includes/xsl/hotel.xsl");
string str = System.Configuration.ConfigurationSettings.AppSett ings["connectionString"].ToString();
SqlConnection cnn = new SqlConnection(str);
cnn.Open();
SqlCommand cmd = new SqlCommand("SELECT " + rType + " FROM tblXXX for xml auto,elements",cnn);
XmlReader reader = cmd.ExecuteXmlReader();
XPathDocument doc = new XPathDocument(reader);
cnn.Close();
XslTransform tr = new XslTransform();
tr.Load(xslPath);
tr.Transform(doc,null,System.Web.HttpContext.Curre nt.Response.Output);
reader.Close();
}
catch(SoapException soapEx)
{
throw soapEx;
}
catch(Exception ex)
{
RaiseException("GetStr","http://tempuri.org/CategoriesService",ex.Message,"1000",ex.Source,Fau ltCode.Server);
}
}
it gives this error
The <html> tag from namespace is not expected. Line 1, position 2.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: The <html> tag from namespace is not expected. Line 1, position 2.
Source Error:
Line 35: [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://tempuri.org/GetStr", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse .Literal, ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
Line 36: public void GetStr(string rType) {
Line 37: this.Invoke("GetStr", new object[] {
Line 38: rType});
Line 39: }
Source File: c:\inetpub\wwwroot\test1\Web References\localhost\Reference.cs Line: 37
but when i test the web service projects it runs fine and gives the result only when i deploy it then it gives this error.
any solution