Tool to to apply .xsl files to XML to view output
Hi all,(I am sorry if this is a duplicate, but I did not get a response from the other forum I posted this in)
I call a web service that returns a block of XML which then gets given an .xsl file so that the users are able to view a styled report online. The XML that comes back from the suppliers web service is also stored in the database. What I want to do is be able to re-apply this .xsl file to the XML? If I pull the XML from the database and save it into a .xml file, what do I need to do to apply the .xsl file to it? Is there an easy way to do this? Or do I need to use specific software?
Thanks
Tryst
[682 byte] By [
Tryst] at [2008-1-6]
The simplest possible way: add an xml-stylesheet processing instruction to the XML:
<?xml-stylesheet type="text/xsl" href="http://thetransform.xsl"?>
Now open the XML file in a browser, and the browser will display the transformed XML.
If you need to do this programmatically, it's a little more elaborate. You use the XslCompiledTransform class to apply XSLT transforms to XML documents. This is a really super-versatile class, which means that it has a lot of options that may not apply to your specific problem (like I bet the transform doesn't use arguments). But the basics are:
- create an XslCompiledTransform object
- create an XmlReader on the source XML
- create an output stream, probably a StringWriter, maybe a FileStream
- execute the Transform() method on the XslCompiledTransform object
Now your output stream contains the result of the transform, and you can open it in a browser (if it's a file) or write it to a WebBrowser (if it's a string).
Thanks, guys, I got the best of all worlds with your replies

If you end up doing a lot of development on your xslt, I would highly recommend the Visual Studio 2005 route (as the previous post mentioned). The thing that's great about VS 2005 is that you can put break points in the file to stop it on the line that's giving you trouble. You can then write xpath in the command window to query the current node that you are on. This is extremely helpful. It works just like debugging C# or VB. Also, you should check out the xpathmania plug-in that donxml created. it allows you to write xpath queries against your xml file within VS2005.
Cheers,
John
Thanks for the input all

Another thing, is there a way to link the CSS file into all this? As my .xsl files also contain styles.
Thanks
Hi all,
is there no direct way to edit the source of the XML in XML Notepad 2007. So far, it just seems quite fiddly to add nodes.
Thanks
I'm not sure if this is the correct forum for my query, but I'm jumping in on the first .xls thread that I found that has something to do with the web. I'm fresh into development although I've been doing quite a lot of complicated formulas, templates, and basic VBA macros (mostly recorded and tweaked here and ther) in Excel for some time now.
This might seem really basic to most of you but I need to know how to return a query to an MS SQL Server via XML as an .xls file that follows the format of a template I've created. I've seen it done using simple dropdowns to set parameters but I'm absolutely stumped as to how the code can return an .xls file that follows a very specfic format (colors included, rows and columns labeled properly and not by their dbase field/record names). No formulas are visible in the returned .xls file but it's obvious that calculations such as percentages and logical operators were used on the data returned by the query.
I could, of course, query the server directly from Excel, but that wouldn't make the .xls file (a daily report) readily available to other users in the intranet. I could use Crystal Reports, but that would be extra expense for licenses. We already have corporate licenses for all the MS tools that we will be needing for the task above, why spend more?
Cheers,
Alex