.NETGURU
Applying XSL
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngxml' list.


Jon Le
How do you apply an XSL to an XML source and display it, say, in a
browser?

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

Reply to this message...
 
    
Dan Wahlin
This can be accomplished by using the XslTransform class in the
System.Xml.Xsl namespace. Here's a simple example from the SDK:

//Create a new XslTransform object.
XslTransform xslt = new XslTransform();

//Load the stylesheet.
xslt.Load("http://server/favorite.xsl";);

//Create a new XPathDocument and load the XML data to be transformed.
XPathDocument mydata = new XPathDocument("inputdata.xml");

//Create an XmlTextWriter which outputs to the console.
XmlWriter writer = new XmlTextWriter(Console.Out);

//Transform the data and send the output to the console.
xslt.Transform(mydata,null,writer);

You'll find several examples at the following URL:

http://www.xmlforasp.net/content.aspx?content=search&searchText=xsl

You can also read a free online chapter from the book XML for ASP.NET
Developers on using XSLT with .NET at the following URL:

http://www.xmlforasp.net/pdf/chapter7.pdf

HTH,
Dan Wahlin

Wahlin Consulting LLC
Microsoft MVP - ASP.NET
http://www.XMLforASP.Net: #1 ASP.NET XML Resource
XML for ASP.NET Developers by Dan Wahlin in bookstores everywhere!

-----Original Message-----
From: Jon Le [mailto:Click here to reveal e-mail address]
Sent: Tuesday, June 04, 2002 12:00 PM
To: aspngxml
Subject: [aspngxml] Applying XSL

How do you apply an XSL to an XML source and display it, say, in a
browser?

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

| [aspngxml] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngxml.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Brian W. Spolarich

| How do you apply an XSL to an XML source and display it, say, in a
| browser? =20

In the very simplest form you can do something like this:

    private void Page_Load(object sender, System.EventArgs e)
    {
        XmlDocument myDoc =3D new XmlDocument();
        myDoc.LoadXml(@"C:\Path\to\my.xml");
        XslTransform myXslt =3D new XslTransform();
        myXslt.Load(@"C:\Path\to\my.xsl");
        myXslt.Transform(myDoc, null, Response.Output);
    }

This example reads the specified XML document (using the XmlDocument =
class, which implies that the XML source is relatively modest in size if =
you don't want to consume lots of memory) as well as the specified XSL =
file, and transforms one using the other.

The XmlDocument.LoadXml() and XslTransform.Load() methods are heavily =
overloaded, so their sources can some from a myriad of different places. =
The XslTransform.Transform method is also overloaded, and can go to any =
Stream subclass, as well as a host of *Writer classes.

The documentation that Visual Studio.NET (VS.NET) is extremely helpful =
with examples in this regard. I don't know if the docs that come with =
the non-VS.NET distribution of the .NET Framework developer's kit.

Regards,

-bws

Reply to this message...
 
    
Rangi Keen
You can use the XML Web Server Control to transform an XML document using an
XSL style sheet:

<asp:Xml id="Xml1"
Document="XmlDocument object to display"
DocumentContent="String of XML"
DocumentSource="Path to XML Document"
Transform="XslTransform object"
TransformSource="Path to XSL Transform Document"
runat="server">

More information is available at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
ml/gnconxmlwebservercontrol.asp.

...........................................................................
Necessity is the plea for every infringement of human freedom.
It is the argument of tyrants; it is the creed of slaves.
-William Pitt, British prime-minister (1759-1806)

-----Original Message-----
Subject:    Applying XSL
From:    Jon Le <Click here to reveal e-mail address>
Date:    Tue, 4 Jun 2002 11:59:48 -0700 (PDT)

How do you apply an XSL to an XML source and display it, say, in a browser?

Reply to this message...
 
 
System.Console
System.EventArgs
System.Xml.XmlDocument
System.Xml.XmlTextWriter
System.Xml.XmlWriter
System.Xml.XPath.XPathDocument
System.Xml.Xsl.XslTransform




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification