xmlxslt

Which browser can show XML data transformed by XSLT?


say, if there is a file that's call data.xml, and a file that is format.xsl (or is it format.xml ?), which is to transform the XML data and format it as well using CSS, then which browser can display it? Which file should be opened? (the .xsl or the .xml?)

Actually I saw in another example that the XSLT file's first line is to href="format.xsl", so I thought the XSLT file is already the .xsl ? then how come it is linking to another .xsl file? How many files are there, 2 or 3?


Solution

  • There are two files, one .xml containing data and one .xsl with the XSLT script for transformation. As of August, 2010, all leading browsers support client side XSLT transformation. Open the .xml file and the associated .xsl file will be used. Usually the script builds an html document which is displayed on the fly. The transformation can also be done by the server with PHP etc.
    To associate a XSLT script, the .xml file needs a line like this:

    <?xml-stylesheet type="text/xsl" href="script.xsl" ?>
    

    Edit 18.04.2021: The question is 10 years old now and a lot has happened. It's possible now to have XSLT 3.0 running in the browser using Saxon-JS. There's a Hello World on Github.