Konqueror bookmark xml (xbel) files and its display in web browsers (Mozilla that is) using stylesheets (css or xsl)

Konqueror stores its bookmarks in an xml file (bookmarks.xml) of document type xbel (XML Bookmark Exchange Language). Because I want to have my bookmark file always online (a link from my homepage), I need a way to convert the XBEL file into an HTML file or make the browser display the XML file. Most browsers can display xml data, but they need a seperate style sheet document to do so. Thus I inserted into the bookmarks.xml file a reference to a css style sheet file (bookmarks.css):

<!DOCTYPE xbel> <?xml-stylesheet type="text/css" href="bookmarks.css"?>

I defined the different tags used in the bookmarks.xml file in the bookmarks.css stylesheet file:

title {display:block; font-weight:bold;} bookmark {display:inline; margin-left:40px;} folder {display:block;}

After that Mozilla was able to display the bookmarks.xml file. It looks terrible, but I just have to work on the stylesheets (especially how to make the links being links). Konqueror accepts the additonal line in the xml file and leaves it untouched. So I just have to write some nice-looking stylesheets.

Although it is possible to use a css stylesheet file to describe the layout of the xml file to the browser, the correct way is to use XSL files (eXtensible Stylesheet Language). I figured out that several people have been already writing XSL stylesheets for the rendering of XBEL files. Here is the link that describes how to to this. In this example a crontab entry executes xsltproc: xsltproc is a program from the libxslt package that can convert xml files into html files and that uses an xsl stylesheet which you write yourself. This html file is then uploaded via scp to the web server.

xsltproc -o /home/jeltsch/.kde/share/apps/konqueror/bookmarks.html /home/jeltsch/bin/bookmarks.xsl /home/jelsch/.kde/share/apps/konqueror/bookmarks.xml

This command makes the conversion from bookmarks.xml into bookmarks.html using the styles defined in bookmarks.xsl.

scp /home/jeltsch/.kde/share/apps/konqueror/bookmarks.html jeltsch.org:/var/www/html/vhosts/jeltsch.org/bookmarks.html

This uploads the bookmarks.html file to my server. The server asks for a password. If you want it to execute automatically from a crontab, you need to create a private/public keypair on both your computer and the webserver to allow passwordless execution of scp. Make sure to limit the authorized_keys2 to your computer!

0 * * * * /usr/bin/xsltproc -o /home/jeltsch/.kde/share/apps/konqueror/bookmarks.html /home/jeltsch/bin/bookmarks.xsl /home/jeltsch/.kde/share/apps/konqueror/bookmarks.xml && sudo -u jeltsch scp -q /home/jeltsch/.kde/share/apps/konqueror/bookmarks.html jeltsch.org:/var/www/html/vhosts/jeltsch.org/bookmarks.html

(For some reasons the scp command didn't work in SuSE 10.1 and I had to change it by removing the "sudo -u jeltsch" part and add the user to the server name ("jeltsch@jeltsch.org".)

The command above is from the crontab. Note that you have to execute the scp command as the user that has the passwordless login account on the server; the crontab executes by default as root.