Home
Subscribe to Stuff from Sigfrid LundbergSubscribe to my stuff
Subscribe to Stuff from Sigfrid LundbergSubscribe to discussion feed

stuff by category || year

NB

My name is Sigfrid Lundberg. The stuff I publish here may, or may not, be of interest for anyone else.

On this site there is material on photography, music, literature and other stuff I enjoy in life. However, most of it is related to my profession as an Internet programmer and software developer within the area of digital libraries at the Royal Library, Copenhagen (Denmark) and, before that, Lund university (Sweden).

The content here does not reflect the views of my past or present employers

Add footnotes to my pages -- a prototype text annotation interface

Sigfrid Lundberg's Stuff 2009-09-09

Show Anchors || Bookmark and Share

There is a link at the top of this page. It says Show Anchors . It's not a very user friendly description of what it does, but I cannot figure out a better term right now. If you click on it, there will appear a link after most words in the text. These are the annotation anchors. When visible, the anchors appears as a clickable asterisk '*'. Clicking on one of them activates the usual disqus.com forum.

Submitting a footnote works, but the script never get the acknowledgement from the disqus.com server. I don't know why, but it seems that the form doesn't like to live in an iframe.

My server retrieves the annotations from the disqus.com web services and print a list of notes at the end of the page. This is done server side, such that the discussions within the footnotes will be visible by search engines. The place of the annotation is marked as a note with a link to the notes. You may read the annotation when your mouse is over the link.

Is this a good idea? Do you like it? Should all my pages have user supplied foot notes?

How is it done

In order to add footnotes to a text, we need to be able to address individual positions in it. These positions are what I'd like to call annotation anchors. I've already briefly discussed the problem on how to create identifiers (see a A quotation is much more than an extract ). For this entry I've extended the xslt script such that it can tokenize html text embedded in atom entry documents. It can also add anchors (id attributes) on each individual word (produced by the tokenize function) in the whole text. We also implement a javascript which expose these anchors to users, and allow them to comment more or less arbitrary point in the text.

There is a big drawback in this procedure; once you have processed your text and the anchors are there, then you must not change them. Each word has become a resource on the internet. Please view the source of this document, before you use the stylesheet atom_anchor_id.xsl .

	<span id="anchor54764">Would</span>
	<span id="anchor54766">you</span>
	<span id="anchor54768">like</span>
	<span id="anchor54770">to</span>
	<span id="anchor54772">edit</span>
	<span id="anchor54774">this</span>
	<span id="anchor54778">text?</span>
      

See what I mean? I cannot author prose like that in my XML editor. You wouldn't suffer as much using WYSIWYG tools, but on the hand it would presumably destroy the ID-strings.

When preparing this text, I felt that I had to prepare some annotations of my own, and in order to do that I compiled the text, published it, made my annotation and then pasted the ID back into the source XML in order to be able to continue writing. Formbased proof reading of an existing digital text wouldn't be any problem, though.

Javascript & DOM scripting

You can find the possible anchors by clicking on the link Show anchors , and hide them again by clicking on Hide anchors at the same place (there is a toggle). There are two javascript functions handling the toggling. The possibly most interesting, but also, the most vulnerable, feature is the generation of javascript by XSLT from RSS for handling the readable notes. The code entering the notes into the text looks like this:

      <script type="text/javascript">
	    var usedAnchorIds = new Array();
	    var noteTexts     = new Array();
	    
	    usedAnchorIds[0]="anchor55402b10.359095368701543";

	    noteTexts[0]='I had problems obtaining unique id strings from the'
	    +'generate-id() function in XSLT. (siggelundberg, Fri, 18 Sep 2009'
	    +'17:46:27 -0000)';

	    usedAnchorIds[1]="anchor55018b510.584488500647474";

	    noteTexts[1]='This is an arbitrary point in my text. I find this'
	    +'really suitable for adding a footnote. (siggelundberg, Fri, 18 Sep
	    +'2009 03:27:16 -0000)';

	    printNotes(usedAnchorIds,noteTexts);

    </script>
      

The rest of the features are readily visible on this page. You have to reaload the page to see the new footnote -- if I implement this I'll will refresh those asynchronously.

Footnotes

  1. I haven't tried if this still works almost five years later. But we'll see

    (siggelundberg, Mon, 17 Feb 2014 07:03:44 -0000)

  2. less is more

    (siggelundberg, Thu, 24 Sep 2009 05:10:25 -0000)

  3. Oh yes, man. I like it.

    (Maria Kardinal, Sat, 19 Sep 2009 15:49:25 -0000)

  4. Test

    (Guest, Sat, 19 Sep 2009 14:35:43 -0000)

  5. This is how it looks like. There will be interesting effects when using markup in the note, since I am using just an ordinary title attribute on a link tag to do this. I need something more sofisticated. Markup works well in the notes at the end of the page.

    (siggelundberg, Sat, 19 Sep 2009 08:34:51 -0000)

  6. I had problems obtaining unique id strings from the generate-id() function in XSLT. I first believed this was due to some bug in libXSLT, but it seems to be more a feature than a bug. Still, it took me several journeys between Lund and copenhagen to figure out.

    (siggelundberg, Fri, 18 Sep 2009 17:46:27 -0000)

  7. This is an arbitrary point in my text. I find this really suitable for adding a footnote.

    (siggelundberg, Fri, 18 Sep 2009 03:27:16 -0000)

blog comments powered by Disqus