Hi all, We have a client who required a website with a related document function. This means that each document in a collection contains keywords, and when the document is displayed, it also shows a list of other documents that contain one or more of the same keywords.
There are a lot of documents in this collection, and although they are stored in an XML database, I didn't really feel like querying them in real-time. I really wanted something lean and mean. So in XP fashion, I picked the simplest datatype to express relations, java.util.Map, and went from there. The keys in the map are the keywords from the document collection, the values it returns are URLs pointing to the documents that contain this keyword. So I ended up with two components: - MapManager - initializes one or more maps from a ( cocoon ) xml-source, which is constructed according to a specific DTD. The datatype stored in the map can currently be one of String, Set or SortedSet ( in case results are sorted by relevance ). - MapTransformer - looks for <key> elements in a specific namespace, and transforms the value(s) returned by the map into the <key> element. The names are a little confusing because the use of 'map' in cocoon usually refers to the sitemap, but a change is just a simple refactoring away. If anyone is interested in this functionality I'd be happy to donate it. If you think this is not the right way, or there are other ways to do this in Cocoon, let me know. --- [RT] I tried to make this mapping very generic. It could be keyword > related document, keyword > explanation, document > related document, or url > metadata. A first extension would be keys with wildcards or RE's although that would force me to loose the map model. Googleing xml and relations quickly brought me another subject that I haven't seen discussed much here - XML topic maps. On of the big advantages of topic maps over my simple mapping is the amount of semantics that topic maps allow. Topic maps allow one thing to be related to another, and also describe what the one thing is, what the other thing is, and what kind of relation they have. So the next step would be to implement a topic map transformer. There is a apache-license topic map project at http://sourceforge.net/projects/tm4j. I'm definitely going to look into it myself, but need to do some reading first, and I would like to discuss it. By the way, if you don't like topic maps, I would like to know too - I wasn't able to find any criticism on the matter (googleing 'why topic maps are bad' or 'topic maps suck' didn't help) With kind regards / Met vriendelijke groeten, Rogier Peters --------------------------------------------------------- Content Management Department Hippo Webworks Rogier(at)hippo(dot)nl / www.hippo.nl
