How do I run an XSLT file?

XmlXslt

Xml Problem Overview


I am writing an XSLT file to translate an XML document into an XHTML document. I've used both Visual Studio and XML Notepad 2007 to preview the results of my XSLT file, but now I want to actually write out a real XHTML file so I can see how it looks in other browsers.

Neither Visual Studio or XML NotePad have an obvious way to save the preview. Am I missing something. Obviously the file is getting created because something is being previewed, but I need to know where that file is being created or better yet choose its location.

Xml Solutions


Solution 1 - Xml

You have two options:

  1. Let the browser do it. Pass the XML with a reference to the XSLT and the browser (IE 6 or lower might have problems) will render it as (X)HTML:

    <?xml-stylesheet type="text/xsl" href="http://www.example.com/my-xslt.xsl" ?>

  2. Do it server-side. Most languages have methods for accepting XSLT and XML data, then outputting (X)HTML. Here are some options:

alt text

Solution 2 - Xml

In Visual Studio, add the XML file to a project. Open the XML file. When the file is open and its window is active, you should see, in the Properties window, that you can specify an output filename and a stylesheet. Also, you should see that the menu bar now contains an "XML" item.

If you pick "Show XSLT output" from the "XML" menu, VS will apply the specified transform to the XML file, write its output to the file you specified, and then open that file. If the file has an .xml extension, it'll open it in a text editor window; if it has an .htm extension, it'll open it in a browser window.

It's a little bit clunky (it seems to me that a menu that appears and vanishes instead of being enabled/disabled is kind of hinky), but it works well enough, and it's in the tool you're already using.

Solution 3 - Xml

If you don't mind going to the command line and XSLT 1.0 is what you want: msxsl.exe

Solution 4 - Xml

For a one-off task where you do not want to go thru the pain of an install, you could probably use https://www.freeformatter.com/xsl-transformer.html. I'l disclaim that I have not used this site much.

Solution 5 - Xml

There are many third-party software. One of them is "Oxygen XML Editor". In this software, simply:

  1. Open your .xml
  2. Open your .xslt
  3. Click "run" in the toolbar for see results( output will be in the right panel).
  4. If you want to save result, R-click on result in right panel and choose "save ..."
  5. If you have problem, may be you need change processing in toolbar: "Xalan,Saxon,Saxon-HE,saxon-PE,..."

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEric AnastasView Question on Stackoverflow
Solution 1 - XmlBryanHView Answer on Stackoverflow
Solution 2 - XmlRobert RossneyView Answer on Stackoverflow
Solution 3 - XmlTomalakView Answer on Stackoverflow
Solution 4 - XmlSumit KishoreView Answer on Stackoverflow
Solution 5 - XmlAlex PourView Answer on Stackoverflow