Subject: Re: Problems with attributes. From: Brandon Ibach <bibach@xxxxxxxxxxxxxx> Date: Tue, 19 Oct 1999 15:44:48 -0500 |
Quoting Reyes <reyes.garcia@xxxxxxxxxx>: > Hello, > I want to collect all the "WERK" tags that have a child with > gi "SONW" and attribute unique "ANKER". I have made the next macro, > but don't work, I don't know why : > Well, the element rule looks fine, so let's examine "unique-son". I've reformatted it a bit to make it more compact, but it is the same, otherwise. > (define (unique-son node tag son att) > (let loop ((result (empty-node-list)) > (nl (select-elements (descendants node) tag)) (list-att '())) > (if (node-list-empty? nl) result > (if (node-list-empty? (unique (node-list-first nl) son att)) > (loop result (node-list-rest nl) list-att) I'm not sure what "unique" does, but I suspect that this (if) construct is unnecessary, as it appears to duplicate the function of the (let), below. > (let son-loop ((son-nl (select-elements > (descendants (node-list-first nl)) son))) > (if (node-list-empty? son-nl) > (loop result (node-list-rest nl) list-att) > (if (member (attribute-string att > (node-list-first son-nl)) list-att) > (son-loop (node-list-rest son-nl)) > (loop (node-list result (node-list-first nl)) > (node-list-rest nl) > (list list-att (attribute-string att > (node-list-first > son-nl))))))))))) I'm not sure of the circumstances of your application, but it may be that this (loop) at the end should be (son-loop), depending on how you want it to work. Suppose you have two WERK tags. The first has two SONW tags with ANKER attributes set to "A" and "B", respectively. The second WERK has one SONW tag with ANKER set to "B". As your code stands, the second WERK would be collected, because processing on the first WERK would stop after finding the "A" SONW, thus not adding the "B" SONW to the list. Also, you'll want to replace the (list) call at the end with a (cons), and reverse the arguments. As it stands, you'll be building something like ((("A") "B") "C") instead of ("A" "B" "C"). You didn't really say what *does* happen with the current version of this, but I'd guess that the uniqueness test is not working correctly, which is due to this. Let me know if these suggestions solve your problem. -Brandon :) DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Problems with attributes., Reyes | Thread | Re: Problems with attributes., Reyes |
Re: Hopefully simple -- include a q, Daniel Speck | Date | Re: processing RTF documents, Sebastian Rahtz |
Month |