Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2007, 03:12 AM
Authorized User
 
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default xml transformation to wml using asp.net

 Hi,

     I am trying to transform an xml file to wml using asp.net. I did this work previously in ASP but now I want to do the same work in Asp.net. Could anyone give some examples how to do this in asp.net.

 Here is my asp code( which is working)

 <% '---Create an instance of the DOM object---

Set xml = Server.CreateObject("MSXML2.DOMDocument")

'---Let it run synchronously---

xml.async = false

'---Load the XML document---

xml.load (Server.MapPath("hnxml\f00cd56dd3764a6900257380004 287a1.xml"))

Set xsl = Server.CreateObject("MSXML2.DOMDocument")

xsl.async = false

'---Load the XSLT stylesheet---

xsl.load (Server.MapPath("hnxml.xslt"))

'---Set the MIME type---

Response.ContentType = "text/vnd.wap.wml"

'---Send the WML prologue---

Response.Write ""

Response.Write ""

'---Performs the transformation---

Response.write (xml.transformNode(xsl)) %>


Thanks,

Aruna.G



 
Old November 7th, 2007, 07:23 AM
Authorized User
 
Join Date: Oct 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default


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);
}

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.ThrowInvalid StateError(XPathNodeType constructorType) at System.Xml.Xsl.Runtime.XmlQueryOutput.ConstructInE numAttrs(XPathNodeType rootType) at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartAt tribute(String prefix, String localName, String ns) at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartAt tributeLocalName(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(IXPathNavigabl e contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigabl e contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPa thNavigable 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

Edit/Delete Message






Similar Threads
Thread Thread Starter Forum Replies Last Post
WML and XSL transformation. Feodorov XSLT 2 February 13th, 2008 05:00 PM
Newbie: ASP.NET/XML Transformation Problem kwilliams ASP.NET 2.0 Basics 1 August 28th, 2006 02:40 PM
Is XML supports transformation of HTML to XML? zeeonline XSLT 1 July 28th, 2006 05:13 PM
asp-wml -databse andy11983 Classic ASP Basics 0 April 12th, 2004 05:51 PM
Server side transformation with- XSL/XML, ASP, IIS kenneth02 Classic ASP XML 3 November 10th, 2003 10:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.