Possible fix for duplicate attribute problem in jtidy

For what it is worth, I'm experimenting with the following method (in the Clean
class of jtidy).  So far it seems to work, eliminating all but the first
instance of the duplicated attribute.  I'm invoking the method in Tidy.parse().

BTW, I am *not* a member of this list right now, so please send any comments on
to me directly.  I'd join, but I'm in too %$^$*# many groups right now and am
feeling overwhelmed by mail.

--arne

    /* This is a test to see how this stuff works... */

    private static void findAndRemoveDuplicateAttributes(Node n){

        while (n!=null){
            if (n.type == Node.StartTag){
                //Remove duplicate attributes, saving the first
                AttVal a=n.attributes;
                while (a!=null){
                    AttVal aCompare = a.next;
                    while (aCompare!=null){
                        if (Lexer.wstrcasecmp(a.attribute, aCompare.attribute)
== 0){
                        //Found a duplicate, remove it
                        System.out.println("Found duplicate attribute:
"+a.attribute+", in Element: "+n.element);
                        n.removeAttribute(a);
                        break;
                        }
                    aCompare=aCompare.next;
                    }
                a=a.next;
                }
            }
            findAndRemoveDuplicateAttributes(n.content);
            n=n.next;
        }
    }

    public static void removeDuplicateAttributes(Node n){
        while (n != null)
        {
            System.out.println("Experimental cleanup - removing duplicate
attributes");
            findAndRemoveDuplicateAttributes(n);
            n = n.next;
        }
    }

Received on Tuesday, 3 October 2000 14:40:50 UTC