2

Using my browser, I want to test if my xslt code is working.

Currently I am copy pasting my xml and xslt code into w3school's example page and test it there.

However, this is a real pain, since inserting tabs don't work there, syntax highlighting isn't active and the output window is too small. It is inconvenient to test your code there in general.

So:

  • What do I have to setup to test my xslt code?
  • Do I have to change the name of the xslt file to xhtml or html?
  • How do you test xslt code in general?

I want to call the link file://code.xslt in my browser and see the result, for example.

I am on Ubuntu, Linux.


Testing with Chrome

To circumvent chrome's same origin policy, I had to restart chrome with google-chrome --allow-file-access-from-files.

Here and here is more info.

Community
  • 1
  • 1
polym
  • 568
  • 1
  • 11
  • 26
  • I haven't tried it yet but you can use Xml Notepad by Microsoft to test Xslt Documents, if you are working on a windows machine. – Ole Viaud-Murat Jul 08 '14 at 10:45
  • Thank you for your suggestion. Sadly, I am on Ubuntu (Linux). Updated my answer to avoid any confusion :). – polym Jul 08 '14 at 10:47

1 Answers1

6

A super-simple way to test your XSLT in a browser is to add the following header to your XML source document:

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

then load it (the XML source) in the browser.

Another option is to use a stand-alone HTML document with some javascript to load your XML and XSLT documents and initiate the transform.

None of these can really replace a dedicated application. Note also that you have tagged this with XSLT 2.0, but I don't know of any browser that supports it.

michael.hor257k
  • 96,733
  • 5
  • 30
  • 46