Subject: searching for closest previous element From: stephenng@xxxxxxxxxxxx Date: Wed, 18 Mar 1998 11:57:46 +0000 |
Here's the side-effect thread all over again. When handling element "X", I would like to find the closest previous occurrence of element "Y" in the document, because I need to look up some attribute of element "Y". For perverse reasons, elements "X" and "Y" can occur anywhere in the document, at any level, so the occurrence of "Y" that I need to look up would be the closest previous element if you flattened the whole tree. I have a routine to do this, but it's really really slow. In a language with side-effects, every time I ran across "Y" I would set a global "LastY", which I could reference when I process "X". In DSSSL, however, I have to rummage through the tree over and over again every time I hit an "X". I've structured my tree-search so that it (recursively) searches the last node first by calling "reverse" on the node list. "Reverse" takes a lot of time with many elements. But there seems no way around it: there's no quick way to access the last node in a node list, so that I can walk the tree list backwards. Is the short answer that I shouldn't have a document structured like this? If the "Y" I was interested in was an ancestor of "X", then I wouldn't have these problems. Perhaps I should write a Jade program to create a new document that has this property? Is this similar to the footnote numbering problem? TIA, Steve DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: The DSSSList Digest V1 #261, Norman Walsh | Thread | Re: searching for closest previous , Norman Walsh |
RE: Convert DTD to IDL ?, Reynolds, Gregg | Date | RE: Convert DTD to IDL ?, Gavin Nicol |
Month |