Xml transformation to wml using asp.net

S

shakthi

Hi,

I am trying to transform an xml file to wml using asp.net. I get the
xml file from sql server as a string. so I need to convert it to xml
and tranform that xml file to wml.

Here is my code:

private void XmlTransformToWML(string hn_xml)
{
XmlDocument xmlDoc = new XmlDocument();

try
{
xmlDoc.LoadXml(hn_xml);
}
catch (XmlException e)
{
Response.Write(e.Message);
}
XPathDocument xpathDoc = new XPathDocument();

string xslPath = Server.MapPath("hnxml.xslt");


XslCompiledTransform myXslTrans = new XslCompiledTransform();
//Load the XSL stylsheet into the XslCompiledTransform object
myXslTrans.Load(xslPath);
myXslTrans.Transform(xmlDoc, null, Response.Output);
}

My problem is when I execute this code I am getting the following
exception. I have a doubt, can we use XmlDocument as a argument to
transform to wml.

Exception:

System.Xml.Xsl.XslTransformException: Attribute and namespace nodes
cannot be added to the parent element after a text, comment, pi, or
sub-element node has already been added. at
System.Xml.Xsl.Runtime.XmlQueryOutput.ThrowInvalidStateError(XPathNodeType
constructorType) at
System.Xml.Xsl.Runtime.XmlQueryOutput.ConstructInEnumAttrs(XPathNodeType
rootType) at
System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartAttribute(String
prefix, String localName, String ns) at
System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartAttributeLocalName(String
localName) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-
debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-
debug}current) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-
debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-
debug}current) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-
debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-
debug}current) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-
debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-
debug}current) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-
debug}runtime, XPathNavigator ) at Root(XmlQueryRuntime {urn:schemas-
microsoft-com:xslt-debug}runtime) at Execute(XmlQueryRuntime
{urn:schemas-microsoft-com:xslt-debug}runtime) at
System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
XmlResolver dataSources, XsltArgumentList argumentList,
XmlSequenceWriter results) at
System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter
writer, Boolean closeWriter) at
System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument,
XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter
results) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable
contextDocument, XmlResolver dataSources, XsltArgumentList
argumentList, TextWriter results) at
System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input,
XsltArgumentList arguments, TextWriter results) at
topic.XmlTransformToWML(String hn_xml) in d:\Thesis\Thesis
Documentation\Codes From Fuchs\Original HNXML\Mobile Applications
\topic.aspx.cs:line 71 at topic.Page_Load(Object sender, EventArgs e)
in d:\Thesis\Thesis Documentation\Codes From Fuchs\Original HNXML
\Mobile Applications\topic.aspx.cs:line 40



Any ideas would be appreaciated.

Thanks
Aruna.G
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top