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
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
                                   //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) {
                    check->value = value;  //Overwrite value with newer
                    duplicate = 1;
            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 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:38:49 UTC