W3C home > Mailing lists > Public > html-tidy@w3.org > April to June 2001

Fixing duplicate definitions of an attribute

From: Daniel Lieuwen <lieuwen@research.bell-labs.com>
Date: Wed, 11 Apr 2001 12:49:37 -0400
Message-ID: <3AD48B21.B370D047@research.bell-labs.com>
To: html-tidy@w3.org
I suggest that duplicate definitions of an attribute, e.g.,

<foo num=7 num=8 y=9 num=3>

not simply be flagged with a warning, but repaired to the appropriate
value
using the last attribute definition---in other words this should become

<foo num="3" y="9">

I would advocate modifying lexer.c's function

AttVal *ParseAttrs(Lexer *lexer, Bool *isempty

to add

        { //Require a new block to declare new variables
            AttVal * check = list; //Check if attribute repeated in
list,
                                   //If so keep only the later value
            char duplicate = 0; //Is this a duplicate attr?
            for(; check != null; check = check->next) {
                if(strcmp(check->attribute, attribute) == 0) {
                    MemFree(check->value);
                    MemFree(attribute);
                    check->value = value;  //Overwrite value with newer
value
                    duplicate = 1;
                    break;
                }
            }
            if (duplicate) continue; //process remaining attributes
        }

right after

        value = ParseValue(lexer, attribute, no, isempty, &delim);

to do this.
Received on Wednesday, 11 April 2001 12:50:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:45 GMT