Testing xslt code using your browser

2020-02-06 16:56发布

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.

1条回答
Melony?
2楼-- · 2020-02-06 17:47

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.

查看更多
登录 后发表回答