Re: simplifying following-sibling and preceding-sibling
"Oleg A. Paraschenko" <[email protected]> Mon, 17 Jan 2005 07:53:16 +0300
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Organization | xmlhack.ru |
| Message-ID | <[email protected]> |
Hello Dmitry, thank you very much for comments! On Fri, 14 Jan 2005 17:54:29 +0300 "Dmitry Lizorkin" <[email protected]> wrote: > Hello! > > Well, with the simplifications you suggested your implementation for > "sxml:following-sibling" and "sxml:preceding-sibling" calls the child > axis twice on the parent node of the context node: > a) the first time the child axis is called when locating the parent of > the > context node, i.e. in the body of "sxml:parent"; > b) the second time the child axis is called when you select siblings of > the > context node. > > The "tricky enough code" you mentioned in the implementation for > following-sibling and preceding-sibling axes provided in > "sxpath-ext.scm" is designed to eliminate the duplicate call to the > child axis considered above. Thank you for the explanation. I understand how sxml:following-sibling works in general, but I've missed the elimination trick. Anyway, in my case (I hope to make a posting about it soon) I'll use my variant, slightly modified: ... ; Get all siblings which are the kids of the parent, ; find the node position and filter the rest (let* ( (kids ((sxml:child sxml:node?) (nsxml:parent node))) (inkids (memq node kids))) (if inkids ((sxml:filter test-pred?) (cdr inkids)) '())))))) Usage of "nsxml:parent" is explicit here. The function "nsxml:parent" stands for "native sxml parent". It knows how to get parents very fast, and I'd like to exploit it. ... > > Regards, > Dmitry > Regards, Oleg ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt