Subject: copy-attributes+ From: "Maltby, David G" <david.g.maltby@xxxxxxxx> Date: Fri, 21 Apr 2000 08:25:33 -0400 |
In a script I have been writing transforming instances from our authoring DTD to our publishing DTD, I found I was forever wanting to get all the attributes from an element copied to the transformed element plus a few more derived from "the environment". James' famous (copy-attributes) handles arbitrary copies very well, great for maintainability when we add new attributes to our author DTD. But after the copy there was no way to bolt on my extra attributes. The below procedure accomplishes both goals. Usage: (element author (make element gi: "pub" attributes: (copy-attributes+ (list (list "new-name" "new-value"))) (process-children))) I am "tossing it over the wall" in case it might be valuable to others and, since I still feel new to DSSSL, for peer (and I use that word as humbly as I can) review. ;(copy-attributes+ extra-atts-list osnl) ; ;extra-atts-list: a list of lists, each of which consists of exactly two strings, ; the first specifying the attribute name and the second the ; attribute value, which are to be added to a copy of the ; attributes of osnl ;osnl: optional singleton node list ; ;Requires (copy-attributes) [http://www.jclark.com/jade/transform.htm] ; ;Returns a list of lists which consists of a copy of the attributes of osnl and ;the passed in extra attributes ; (define (copy-attributes+ extra-atts-list #!optional (osnl (current-node))) (let ( (copied-atts-list (copy-attributes osnl)) ) (if (not (list? extra-atts-list)) copied-atts-list (let loop ( (atts copied-atts-list) (ex-atts extra-atts-list) ) (if (null? ex-atts) atts (if (not (list? (car ex-atts))) (loop atts (cdr ex-atts)) (loop (cons (car ex-atts) atts) (cdr ex-atts)))))))) Regards, David Maltby, IETM Team, Lockheed Martin Space Systems Cocoa Beach, FL DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Looking for DSSSL stylesheets f, José Carlos Ramalho | Thread | Re: copy-attributes+, Brandon Ibach |
Re: Looking for DSSSL stylesheets f, José Carlos Ramalho | Date | bug or mistake ?, Jany Quintard |
Month |