I have been wondering whether it would be possible to use xslt to render .leo files from web pages. This would build on Ville's work. First, a demo:
1. Copy the two attached files to the same folder on your hard drive. Note: recent revs have added these two files to the top-level leo folder, so you could also use those files instead. Both demo files are now in the top-level leo-editor in the git repo *and* on leoeditor.com. 2. Open xslt-test.leo in your browser. You should see something like this: test.leo - This is a test node 1 - Node 1 text. node 2 - Node 2 text. That is, browsers (tested with IE and Mozilla) can render .leo files on your file system as html. Alas, there are problems rending .leo files from urls instead of files. But when we succeed we will have a read-only version of Leo as a web app! ===== About leo_to_html.xsl Ville created leo_to_html.xsl, but I didn't understand its significance until early this morning. This xslt file tells a web browser (or other xslt processor) how to render a .leo file as html. I made several changes this morning to leo_to_html.xsl so that it works with the "tryit" editor for xslt at w3schools: http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog_ex1 This editor is a good way to discover problems either in .xsl files themselves or references to .xsl files from .xml files. ===== Problems It does not seem possible to use leo_to_html.xsl directly: 1. Visiting http://leoeditor.com/xslt-test.leo does not work. The browser renders xslt-test.leo xml, not html. That is, the browser does not perform the xslt transformations. 2. Visiting https://github.com/leo-editor/leo-editor/blob/master/xslt-test.leo shows the "raw" xml, without the xslt transformations being applied. The reason is clear enough. The url is a *representation* of the .leo file, not the .leo file itself. 3. xslt-test.leo contains the following line:: <?xml-stylesheet type="text/xsl" href="leo_to_html.xsl"?> This line is supposed to be set by the following setting:: @string stylesheet = ekr_test This default is useless, and setting it to:: @string stylesheet = type="text/xsl" href="leo_to_html.xsl" does not appear to work. I'll look into this, but cutting and pasting the desired <?xml-stylesheet > element into .leo files should work well enough for testing. 4. By default, Mozilla refuses to render xslt-test.leo containing the following stylesheet element:: <?xml-stylesheet type="text/xsl" href="leoeditor.com/leo_to_html.xsl"?> In other words, Mozilla refuses to execute "remote" .xsl files. A cryptic message is shown instead. Googling that message gives: http://stackoverflow.com/questions/3420513/firefox-and-remote-xsl-stylesheets Apparently Mozilla enforces "same origin" policy. But it's no good relaxing that policy: browsers on smart phones are probably even more restrictive. ===== Conclusions The tryit editor shows that it is possible to apply arbitrary xslt style sheets to arbitrary xml files. We should be able to create a page, say on leoeditor.com, that would render .leo files properly using leo_to_html.xsl. The question is, how exactly to do this? This is exciting, despite the problem listed above, and probably others. The xslt approach is almost infinitely easier than alternative approaches. Once we can properly render, say, a link to a .leo file on GitHub, we can start improving leo_to_html.xsl. The obvious thing to do is to change the xsl so that it generates html similar to that generated by Bernhard Mulder's mod_http plugin. Your comments, please. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
leo_to_html.xsl
Description: XML document
xslt-test.leo
Description: Binary data