IMPORTANT: The following journal is intended for the use and viewing of approved persons only and may contain information that is confidential, privileged or unsuitable for overly sensitive persons with low self-esteem, no sense of humour or irrational religious beliefs. Any dissemination, distribution or copying of this work is not authorised (either explicitly or implicitly) and constitutes an irritating social faux pas. Unless the word ‘absquatulation’ has been used in its correct context somewhere other than in this warning, it does not have any legal or grammatical use and may be ignored. No animals were harmed in the creation of this journal and a minimum of Microsoft software was used. Those of you with an overwhelming fear of the unknown will be gratified to learn that there is no hidden message revealed by reading this warning backwards.

Year View| Summary| Highlights| Month View| Sunday 11 July 2004 (Day View)

11.07.2004Sunday 11 July – XSLT, Recursion & Hay Fever

It’s been raining, or sprinkling, most of the day. I slept in extraordinarily, which is probably not surprising considering I stayed up late last night. Now I have bad hay fever, and because of the rain, I can’t walk around outside – the only temporary relief, apart from sleeping and eating, that I am aware of, even if it doesn’t work that well.
I stayed up all night redesigning my journal. I wanted to add automatic acronym replacement, but using XSLT results in an amazingly convoluted and inefficient method, so I’ve changed my journal so that it statically caches each day – meaning they only have to be generated once. I tried for a while to figure out how to replace acronyms myself, and ended up having to ask for help on the XSLT mailing list – it’s quite recursively complex, although I had it nearly right, sort of.
  I store the list of acronyms to be replaced as a fragment tree, and then I check against the first acronym. If the input text doesn’t contain this acronym, I recursively call the template again, passing it the input text and the rest of the acronyms – that is, all the acronyms but not the first one. If the input text does contains the first acronym in that list, I break the text into two parts – the text before the first occurrence of the acronym, which by definition doesn’t contain that acronym, and the text after the first occurrence of the acronym, which could contain that acronym again. I then recursively call the template again with the text before the first occurrence of the acronym, passing it the remainder of the acronyms, that is, all but the first acronym. Then I generate the acronym itself, and recursively call the template again, passing it the text after the first occurrence of the acronym, and all the acronyms – as this part could still contain any acronym. Once I got my mind around the terribly recursive things this does, it actually made sense.
  As if this wasn’t already horribly inefficient enough, I then call the entire acronym replace template itself recursively, from within my replace new lines with HTML breaks template, which also calls itself recursively – it’s a bit like a nightmare, except in XML. However, it does work, although I’ve not yet thought of any good way to test that an acronym isn’t within another acronym. Currently I’m just ensuring that the acronym is the correct case, and has a trailing space, period, comma or bracket. This appears to work for all cases except that where the acronym is the last term in a sentence and isn’t followed by a period – which I guess, should never happen.
  It was actually surprisingly easy to convert my journal into a statically caching system. Now, if someone attempts to view a day that hasn’t been statically cached, it will create it and cache it, and if it has already been statically cached, it will simply show the cached version – meaning that the acronym replacer should only have to run once per day. This has broken my private entry authentication system, as that was dynamically handled in XSLT, and I haven’t yet bothered fixing it – but that shouldn’t be too hard. Staying up all night probably wasn’t the best idea, but the more engrossed I got, the more my hay fever went away – either that or it was just going away anyway.

Add your comments

You may leave a short comment, not longer than 800 characters.

Be Amused

Printed on 100% recycled electrons
W3C CSS 2.0