XML Bookmarks

Update 2001-02-03: I finally sat down and read through the XBEL specification. I've decided that it is better than my attempt (surprise, surprise) and therefore I'm freezing this page.

Update 1999-11-14: I've been informed of another project, The XML Bookmarks Exchange Language. I will have a closer look at it and then decide if I shall adopt their DTD/approach or go with my own. The software still needs to be written sooner or later..


I've always been a sucker for standards and information sharing. Recently I've more and more come to face the problem of keeping web browser bookmarks in sync, not only between different computers running the same software, but also between platforms and different browsers. I want there to be a standard for bookmarks, and now that XML is really starting to get some momentum, I'd thought I'd try to do something about this growing problem.


A quick introduction to XML

Some short facts about XML:

If you are unfamiliar with XML you might want to take a couple of hours to learn [about] it. People new to XML often wish to compare it to HTML and the way XML relates to HTML is that both share the basic syntax of markup tags, but whereas HTML tags have a special innate meaning there is no such built-in meaning in XML tags. The tag <br> does not necessarily mean a "hard break" in a XML document. Instead you create your own tags and it's up to the reader to parse them. This might sound worthless, but actually it's quite a good idea. This way you can tag and store any kind of data, and with the help of a DTD - Document Type Definition - you can impose limits on which tags are valid, what kind of tags and data they may contain, what attributes are valid, and so on. With the help of the DTD you can then validate the document, which will tell you if it conforms with the specification of the DTD. When you write HTML your markup must conform with the HTML DTD (check the top of this documents source, you will see a reference to w3c's strict.dtd), else it is not valid and if it is not then you cannot assume a web browser will be able to read and parse it! I'm glossing over a whole lot here, for the facts on XML you should go to the W3 Consortium and for learning it you might be off to a good start by checking out my relevant links below.


The problem

Let me summarize what I perceive the problems to be:


My goals

I will summarize my project goals in this list:

In reality it boils down to this: I will try and create a good solid XML document definition and I will call it bookmarks, meaning the root element of a XMLBookmarks document is the <bookmarks>-tag. I will then write a XSL sheet to render a XMLBookmarks document into HTML/CSS which can be published on the web. After that I will write a program in java which can read proprietary bookmark files - I'll begin with the format used by Opera - and output a valid XMLBookmarks document. With luck this will catch on and the community will write converters for other web browsers too. This conversion is an intermediate step needed only because no browser currently use XML natively to store bookmarks. If they did not only would we be able to share these files between browsers and platforms, but we would also - most probably - be able to directly publish them on the web.


The DTD for XMLBookmarks

As I said, I do this partly to learn. This makes me a bad representative when it comes to setting a standard. However, I hope that any major errors will be spotted by the community (meaning you) and that this will indeed come to be a worthvile project. If all else fails, atleast I will benefit from it. All is not lost.

That said, have a look at what I've done so far:

My XMLBookmarks DTD (also available for download/viewing here).

<!DOCTYPE bookmarks [

   <!ELEMENT bookmarks (browser, (folder|url)*) >
   <!ATTLIST bookmarks
             name    CDATA   #REQUIRED>

   <!ELEMENT browser (version|id)* >
   <!ATTLIST browser
             name    CDATA   #REQUIRED>
   <!ELEMENT version (#PCDATA)>
   <!ELEMENT id      (#PCDATA)>

   <!ELEMENT folder  ( (folder) | (desc|created)* | (url) )* >
   <!ATTLIST folder
             name    CDATA    #REQUIRED
             public  (yes|no) #IMPLIED >

   <!ELEMENT url     (desc|created|visited|hits)* >
   <!ATTLIST url
             href    CDATA   #REQUIRED
             name    CDATA   #IMPLIED
             public  (yes|no) #IMPLIED >

   <!ELEMENT desc    (#PCDATA)>
   <!ELEMENT created (#PCDATA)>  <!-- (#DATE)  yyyy-mm-dd -->
   <!ELEMENT visited (#PCDATA)>  <!-- (#DATE)  yyyy-mm-dd -->
   <!ELEMENT hits    (#PCDATA)>  <!-- (digits)+ -->

   <!ENTITY h  'http://'>
   <!ENTITY hw 'http://www.'>
   <!ENTITY f  'ftp://'>
   <!ENTITY ff 'ftp://ftp.'>

My preliminary tests seems to suggest that this defines a document capable of representing a hierarchical hotlist as the one used in Opera. Some additional elements will be needed but this is a start. My big problem is that I want new elements in the folder and url tags to be allowed, but there doesn't seem to be a way to create the DTD to allow for that. Also, I would like to restrict the hits tag the tags containing dates on various ways, but alas, that seems impossible that too. Good documentation will have to make up for that.


Example of XMLBookmarks document

Here is a valid bookmarks document using my DTD (also available for download/viewing here).

<?xml version="1.0"?>
<!DOCTYPE bookmarks SYSTEM "http://hem2.passagen.se/eddy1/projects/bookmarks.dtd">

<bookmarks name="Eddy's Hotlist">

  <browser name="Opera">
   <id>Opera Hotlist v2.0</id>

  <folder name="programming">
   <desc>Programming related links</desc>

   <folder name="NDA/Developer Access" public="no">
    <url href="&f;eddy:q4rel!Z@ftp.dfr.gov"></url>
    <url href="&hw;spank-o-rama.perverts.org"></url>

   <folder name="Klopper" public="no">
    <url href="http://www.klopper.net" name="KlopperNet"></url>

   <url href="&hw;flipcode.com" name="flipCode">
    <desc>Good resource for game developers</desc>

   <url href="http://java.sun.com" name="SUN Java Developer Resource">
    <desc>Download the JDK and documentation from here</desc>


  <url href="http://hem2.passagen.se/eddy1/index.html" name="Eddy L O Jansson's Homepage">

  <url href="http://hem2.passagen.se/eddy1/projects/" name="Eddy's Projects">


My comments on this is forthcoming.


Software and documentation

Not yet available.


Relevant links

Some links relevant to this discussion. If you are new to XML/XSL, check out the beginners links.

XML - Extensible Markup Language
XSL - Extensible Stylesheet Language
XML v1.0 specification
XSL working draft
Webmonkeys introduction to XML (good for beginners)
Webmonkeys introduction to XSL (good for beginners)
XML on-line validation form.

Please, send your feedback to me.


(c)1999 Eddy L O Jansson. All rights reserved. All trademarks acknowledged.