From: Marc P. <ma...@an...> - 2003-04-21 12:04:06
|
On Sun, 20 Apr 2003 12:48:26 -0700, Brian Goetz <br...@qu...> wrote: >> Take an RSS news feed for example, typically these can contain up to 15 >> news items. You may only want to display five of them. As the item nodes >> are usually under a channel node, this would be rather awkward to >> implement with a generic tree traversal directive. > > This is a good example, since it would be a common usage of any DOM > traversal in WM and is pretty simple. > > Option 1: preprocess with a servlet and extract what you want. This As is probably abundantly clear, I do not favour options like this. This is because in many cases, particularly with the possible expansion of the WM user base to pure web-heads with no Java skills (via the webapp), people will need to / should be able to do stuff like this without coding Java. > Option 2: Introduce a context tool that knows how to flatten trees into > linear streams of SAX-like events: Yuck-ish. A flattened tree is better than this, I think. As long as your node objects have a getParent() mechanism you can get an idea of your current node's relationship. The only problem here is that getting full parentage information would be difficult because we have no #break or #while loop. > Option 3: Use XPath for selection. Use an XPath select to whittle Yes, or a similar mechanism > Option 4: Some sort of traversal directive, which is going to end up > looking a lot like XSL. Combining it with XPath could be a win. Yes - it doesn't have to be like XSL. One of the biggest problems with XML is its XSL template based non-linear approach. Very confusing for the author. Have you seen XQuery? That is a template language for presenting XML data. It has a special syntax for expanding nodes by XPath query, based on the current node context. Of course I'm not proposing a new syntax for this, just showing what's out there. In XQuery you just write: This is the title node under the current para node: $currentNode/$title ...interesingly XQuery is VERY like WM in some of its syntax! I would suggest an XQuery directive where you can embed XQuery script in a WM template, but the differences in syntax would be VERY annoying. http://www.w3.org/TR/xquery/ Also, I am writing another message on these issues with a new thread subject... -- Marc Palmer (Wangjammer5) http://www.wangjammers.org Java Consultants |