XSLT for KHTML

Michael Leupold lemma at confuego.org
Sat Aug 8 12:25:42 BST 2009


Hi there,

I've been working on an XSLT plugin for Konqueror/KHTML.

It currently does the following:
- check if the displayed document is not HTML
- search for an <?xml-stylesheet?> PI of type text/xsl, if found, use that 
stylesheet
- if no style is found check doctype and (if not present) xmlns of the 
document element and figure out if it knows which stylesheet to use to 
transform the contents to HTML
- do XSL transformation of the input using the determined stylesheet
- push the results back into KHTML KHTMLPart::write()

While there are still some quirks and very rough edges (only one 
transformation at a time, will crash if the KHTMLPart vanishes while 
transforming as well as some security considerations) it already does 
something.

- example 1 (<?xml-stylesheet?>): 
http://www.confuego.org/uploads/screenshots/automatic-xslt.jpeg
- example 2 (DocBook): http://www.confuego.org/uploads/screenshots/guessing-
doctype.jpeg
- code: http://websvn.kde.org/trunk/playground/network/khtmlxsltplugin

There are still three issues I have and cannot resolve:
- KHTML still displays the raw XML while the processing is not complete. 
This makes it look pretty hackish to anyone using it. Is there a way for a 
plugin to work around this somehow?
- I have no clue how to hint that "something is happening" to the user. Is 
there any way I could show some progress bar/message?
- I'd like to display an error page if something goes terribly wrong. Is it 
possible to use the standard error template or should I just push my own 
error page?

Thanks and regards,
Michael





More information about the kfm-devel mailing list