Re: copying of selected attributes

Subject: Re: copying of selected attributes
From: Daniel Speck <dspeck@xxxxxxx>
Date: Wed, 28 Apr 1999 09:33:59 -0400

If all you want to do is not copy certain attributes, you might try writing
a modified version of the (copy-attributes) function provided in the Jade
documentation under the SGML transform item. Here is a possible (untested)

(define (copy-attributes #!optional (nd (current-node)) (excluded-attrnames
  (let loop ((atts (named-node-list-names (attributes nd))))
    (if (null? atts)
        (let* ((name (car atts))
               (value (attribute-string name nd)))
          (if (and value (not (member name excludded-attrnames)))
              (cons (list name value)
                    (loop (cdr atts)))
              (loop (cdr atts)))))))

You would then use this function as before but provide a list of names of
attributes you don't wish to include, e.g., (copy-attributes (current-node)


Steffen Heinrich wrote:

> Hi,
> I'm doing some SGML transformation into HTML and have difficulties to
> accomplish selective attribute copying, even after I spent some time
> trying (yet not succeeding) to understand the (copy-attributes)
> function. (list, cons, car and cdr startet to loop in my brain.)
> Here is the problem:
> The source DTD defines a TABLE element with almost the same attlist
> like the target DTD (HTML). All attributes are implied and the
> sources additional ID-attribute (optional) has to be transformed
> into an <A>-element with respective NAME-attribute.
> So, all but the ID-attribute have to be copied to the target TABLE-
> element.
> Yet the following code produces errors on any lacking values, of
> course:
> (element TABLE
>   (make element gi:"P"
>     (if (attribute-string "ID")
>       (make element gi:"A"
>             attributes: (list (list "NAME" (attribute-string "ID")))
>         (make element gi:"TABLE"
>               attributes: (list
>                 (list "ALIGN" (attribute-string "ALIGN"))
>                 (list "WIDTH" (attribute-string "WIDTH"))
>                 (list "BORDER" (attribute-string "BORDER"))
>                 (list "CELLSPACING" (attribute-string "CELLSPACING"))
>                 (list "CELLPADDING" (attribute-string "CELLPADDING")))
>           (process-children)))
>       (make element gi:"TABLE"
>             attributes: (list
>               (list "ALIGN" (attribute-string "ALIGN"))
>               (list "WIDTH" (attribute-string "WIDTH"))
>               (list "BORDER" (attribute-string "BORDER"))
>               (list "CELLSPACING" (attribute-string "CELLSPACING"))
>               (list "CELLPADDING" (attribute-string "CELLPADDING")))
>         (process-children)))))
> How can this be done properly, and maybe more economically?
> Thank you,
>                      steffen
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Steffen Heinrich, Peschkestr.14, D-12161 Berlin
> Tel (0)49-030- 851 86 53, heinrich@xxxxxxxxxxxx
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  DSSSList info and archive:

Daniel Speck
Bureau of National Affairs, Inc.               Voice: +1 202.452.6596
1231 25th Street, NW                             Fax: +1 202.331.5178
Washington, DC 20037                          e-mail:  dspeck@xxxxxxx

 DSSSList info and archive:

Current Thread