XML/XSL transform problem

L

Lasse Edsvik

Hello

I was trying to do this example shown here:

http://samples.gotdotnet.com/quicks...webctrl/Xml/Xml2.src&file=CS\Xml2.aspx&font=3

When I run it I get 3 warnings and nothing shows in the browser, what might
be wrong?

Warning 1 'System.Xml.Xsl.XslTransform' is obsolete: 'This class has been
deprecated. Please use System.Xml.Xsl.XslCompiledTransform instead.
http://go.microsoft.com/fwlink/?linkid=14202' C:\Documents and
Settings\Administrator\My Documents\Visual
Studio\WebSites\XMLTest\Default.aspx.cs 20 9 C:\...\XMLTest\


Warning 2 'System.Xml.Xsl.XslTransform' is obsolete: 'This class has been
deprecated. Please use System.Xml.Xsl.XslCompiledTransform instead.
http://go.microsoft.com/fwlink/?linkid=14202' C:\Documents and
Settings\Administrator\My Documents\Visual
Studio\WebSites\XMLTest\Default.aspx.cs 20 34 C:\...\XMLTest\


Warning 3 'System.Web.UI.WebControls.Xml.Document' is obsolete: 'The
recommended alternative is the XPathNavigator property. Create a
System.Xml.XPath.XPathDocument and call CreateNavigator() to create an
XPathNavigator. http://go.microsoft.com/fwlink/?linkid=14202' C:\Documents
and Settings\Administrator\My Documents\Visual
Studio\WebSites\XMLTest\Default.aspx.cs 23 9 C:\...\XMLTest\


protected void Page_Load(object sender, EventArgs e)

{

XmlDocument doc = new XmlDocument();

doc.Load(Server.MapPath("people.xml"));

XslTransform trans = new XslTransform();

trans.Load(Server.MapPath("peopletable.xsl"));

xml1.Document = doc;

xml1.Transform = trans;

}
 
S

S. Justin Gengo

Lasse,

The warnings you have received mean that those classes which existed in .NET
1.1 are no longer being used in .NET 2.0. They are easy to fix simply
replace the classes in question with the classes the warning tells you to
use instead.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Joined
Nov 3, 2006
Messages
1
Reaction score
0
Simple solution to XslTransform

I saw your post and remembered that I had the exact same problem. The XslTransform class is obsolete (but it does still work). If you try to use the XslCompiledTransform class then you are screwed when you try to assign it to the Transform property of the xml web control. And that suggestion to use XPathNavigator property instead of the Document property doesn't seem to make any sense in this situation.

I found the best solution is to avoid using the Document and Transform properties with the xml control. You can use DocumentSource and TransformSource and get the same results with less code, and the compiler doesn't complain about it either.

Your Page_Load method can be simplified to this:


protected void Page_Load(object sender, EventArgs e)
{
Xml1.DocumentSource = Server.MapPath("people.xml");
Xml1.TransformSource = Server.MapPath("peopletable.xsl");
}

jazar
www.rhinoback.com
 
Joined
Nov 10, 2008
Messages
1
Reaction score
0
What about when trying to use an extensions DLL?

This whole thread assumes that no extensions are in play. And the last suggestion I think results in using XmlTransform class anyway, even though it is deprecated. What about trying to incorporate an extension DLL? Is there an updated version of this XML object that uses CompiledTransform?
 

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

Similar Threads


Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top