Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run an XSLT file?

Tags:

xml

xslt

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.

like image 642
Eric Anastas Avatar asked Oct 19 '09 17:10

Eric Anastas


People also ask

How do I run an XSLT file in Notepad ++?

XML Tools Plugin can also be used to perform XSLT (Extensible Stylesheet Language Transformations). 3. Open dictionary. xml in Notepad++ and click menu "Plugins" > "XML Tools" > "XSL Transformation Settings".

What app opens XSLT files?

You can open an XSLT file in any text editor since it's a text-only file. Windows Notepad is the text editor built-in to Windows and can be helpful if you need to quickly make a change, but it's probably not the best program for doing heavy editing.


3 Answers

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:

    • MSXML
    • Saxon
    • Xalan

alt text

like image 108
BryanH Avatar answered Oct 20 '22 20:10

BryanH


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.

like image 38
Robert Rossney Avatar answered Oct 20 '22 19:10

Robert Rossney


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

like image 25
Tomalak Avatar answered Oct 20 '22 19:10

Tomalak