Realtime JSLT Example

Below you can try out entering test XML data and a piece of JSLT. With every keystroke the application will try to compile your JSLT and execute it to form the output. The output is 'plain flat text' in this case to make it more clear what it outputs. It is of course trivial to have it output to an 'innerHTML' part of a div, for it to update HTML in real-time. Please note this example is completely javascript based, and does not use any server-side component. Please check this article for more information. You can also download this example. You see a few \n and \s characters in the example below, that is just to insert whitespace(\s) and newlines (\n) into the output as it is plaintext and not HTML where you would use nbsp and br tags. Take special note of the % character in a [code] block. This character actually outputs what follows to the output buffer. Doing [%(4+10)] will output 14 into the buffer. Doing %#'file' in a codeblock outputs the 'number of nodes' matched by the file xpath into the output buffer. When you encounter a compile error with good looking code, check if you have a missing ; somewhere. Improving ; insertion and space removal is still on the improvement list. Email or MSN me on rik at javeline.nl if you have any questions.

XML

JSLT

Output

Generated code