I have an XML file and a corresponding XSL stylesheet which I am using to transform to XML to an XHTML document. This may be a stupid question, but how do I execute the XSL file? Right now when I’m opening my XSL file into the browser, a copy of my code with color codes and appropriate formatting is displayed. However, obviously I wish to see the output of the program. I researched a bit and figured out that the XSLT file isn’t being compiled into byte code and therefore can’t run. Is there some type of processing application which does this job to compile an XSLT file?
Thanks for any help 🙂
“Bytecode” is a red herring. The issue is how to supply XML to an XSLT program and have that program be executed. There is no one way to do this because it depends on the environment you’re working in.
To get you started, here’s one way. Most browsers understand the
xsl-stylesheetprocessing-instruction. So you can serve up an XML file like this to a browser:When you load your xml file in the browser it will retrieve
my-xsl-stylesheet.xslfrom the server, apply it to the current xml, and display the result. (Make sure your files are being served with the correct MIME type, e.g.application/xml.)But there are many more options. You can transform the XML on the server as the documents are retrieved. You can precompile all your XML to html and serve the html to the browsers directly. If you have a browser that supports programmatic transformation of XML, you can use an HTML file with some javascript to load the XML and XSLT using XMLHttpRequest and run the transformation on the browser.