Collect nodes with unique attribute ¿?

Subject: Collect nodes with unique attribute ¿?
From: Reyes Garcia Rosado <reyes.garcia@xxxxxxxxxx>
Date: Thu, 07 Oct 1999 11:30:01 +0200
Hello again!

I need to take from a tree (SGML instance) all the nodes that have a
specified gi and with unique value for a specified attribute.
I explin it:
I have a SGML instance from a DTD like this:

				   |-- SON-AA
		   |-- SON-A-----|-- *BETRSTOFF(#ANKER)
		   |		   |-- *SON-AB
		   |
     INSTAND-----|-- SON-B
		   |
		   |		   |-- SON-CA-----BETRSTOFF(#ANKER)
		   |-- SON-C-----|-- *SON-CB
		   		   |		     |-- SON-CCA
		   		   |-- *SON-CC-----|
						     |-- *BETRSTOFF(#ANKER)

and I want to make, with Jade, a SGML instance from the next DTD:

		   |-- COLLECT-BETRSTOFF------ *BETRSTOFF(#ANKER)
		   |
		   |		   |-- SON-AA
		   |-- SON-A-----|-- *BETRSTOFF
		   |		   |-- *SON-AB
     INSTAND-----|
		   |-- SON-B
		   |
		   |		   |-- SON-CA-----BETRSTOFF
		   |-- SON-C-----|-- *SON-CB
		   		   |		     |-- SON-CCA
		   		   |-- *SON-CC-----|
						     |-- *BETRSTOFF


I can collect the BETRSTOFF, thas isn't a problem ( Before now I have
spooken with "you" )
My problem is collect all the tags with the gi "BETRSTOFF" but if there are
two with the same attribute ( "ANKER" in this case) it must be only one
time stored. 
I have made two procedures (they work good):

(element INSTAND 
   (make element gi: (string-append "IB-" (gi (current-node)))
      (make element gi: "COLLECT-BETRSTOFF"
         (process-node-list (unique "BETRSTOFF" "ANKER"))
      )
      (process-children)
   )
)

(define (unique tag att)
   (unique-node-att (select-elements (descendants (current-node)) tag) att)
)

(define (unique-node-att list-tag att)
   (let loop ((result (empty-node-list)) (nl list-tag) (list-att '()))
             (if (node-list-empty? nl)
		   result
		   (if (member (attribute-string att (node-list-first nl)) list-att)
			(loop result (node-list-rest nl) list-att)
			(loop (node-list result (node-list-first nl)) 
			      (node-list-rest nl) 
			      (list list-att (attribute-string att (node-list-first nl)))
			)
		   )
		)
   )
)

But, there is a direct way to make this?

Thanks,
	 Reyes



 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread