Re: Re: find with XPath over file system
"Oleg A. Paraschenko" <[email protected]> Wed, 2 Feb 2005 11:11:34 +0300
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Organization | xmlhack.ru |
| Message-ID | <[email protected]> |
Hello Oleg, thank you for comments. On Mon, 31 Jan 2005 23:58:46 -0800 (PST) [email protected] wrote: > > > find with XPath over file system > > http://uucode.com/texts/xfind/index.html > > That is quite neat! > > > Actions (for example, printing file names) are executed after > > collecting files, not during tree traversal. > > Why? I can't do it with txpath. > > The converters (or transformers, whatever they are called) in sxpath > can be quite general. Any function node->nodelist should do. So you > can print as you traverse. The last snippet in > > http://sourceforge.net/mailarchive/forum.php?forum_id=599&viewmonth=200411&viewday=1&style=flat > > can be a good example. Actually, it would be even better if we write > it as > > ((sxpath `(// (div 1) > ,(lambda (node . rest) (write (strings-of-node node))))) > doc) > Yes, it's simple with sxpath. But I use txpath, and (txpath "//div[1]") gives one solid lambda which can't be affected. By the way, it's one of the reasons why I'd like to implement a method to compile XPath to Scheme source code: it would be possible to modify behaviour of XPath evaluation. > > > There are some differences between the file system tree and the XML > > tree. At first, the paths /bin and ../../../../bin may point to the > > same directory, but they look different for users. At second, we can > > lazily walk from the base directory to the root and at the same time > > descent from the root. A special attention should be paid to a meeting > > point. But I decided to ignore it due to the first issue, so nodes > > from relative and absolute XPaths are never equal. > > If both paths point within UFS, then taking stat() (or lstat) of both > and comparing stat.dev and stat.ino fields should tell if they are the > same. In UFS, the combination (stat.dev, stat.ino) is a unique > identifier. Yes, it's easy to check if two stat'ed files are the same. But what we should print to user: /bin or ../../../../bin? Well, it's not very important. Actually, the problem appeared due to my fault. I found the issue too late to fix it. I'll fix the bug in the new version. > Things are quite more problematic for NFS-mounted (and > remounted) and foreign-mounted file systems. > > > > In my applications, I'd like to represent tree-like structures as the > > real Scheme lists to Guile. There are two issues here: > > > > - structures are big enough. Making a full copy of data is overhead, > > so I'd like to instantiate tree branches on demand. > > - Scheme list functions such as car, cdr, for-each etc should > > work on exposed data. > > > > It's impossible to satisfy the both requirements. The problem is that > > list functions check the type of arguments, but we have to use a > > custom type for lazy instantiation of internal data as Scheme data. > > It is true that R5RS permits an implementation to do an implicit > `forcing' of a delayed computation It's interesting. I can't remember such things in R5RS. Would you please point me to it? > -- although only Gambit (with a > special compilation flag) actually does that. Thank you, now I'll know it. > But surely one can > accomplish `lazy' evaluation just by defining special functions like > fcar (to be a composition of car and force), fcdr, fnull, fmap, > ffor-each. Or may want to use the stream SRFI, > http://srfi.schemers.org/srfi-40/ > http://srfi.schemers.org/srfi-40/post-mail-archive/msg00006.html When using special functions, I have to modify source code of libraries. In my development, the sx-library is used without any modifications. > > > Cheers, > Oleg > -- Oleg ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl