2002/css-validator/org/w3c/css/selectors/attributes AttributeExact.java,1.4,1.5

Update of /sources/public/2002/css-validator/org/w3c/css/selectors/attributes
In directory hutz:/tmp/cvs-serv10297

Modified Files:
	AttributeExact.java 
Log Message:
fixed bug http://www.w3.org/Bugs/Public/show_bug.cgi?id=5683
This is partial, the comparison of AttributeExact and AttributeBegin and Exact are OK
needs extra work for OneOf, and check other Attribute classes to match AttributeBegin and AttributeBegin, Begin with OneOf,
OneOf with OneOf...


Index: AttributeExact.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/attributes/AttributeExact.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- AttributeExact.java	13 Sep 2007 10:12:07 -0000	1.4
+++ AttributeExact.java	13 May 2008 09:32:05 -0000	1.5
@@ -54,19 +54,32 @@
     }
 
     public void applyAttribute(ApplContext ac, AttributeSelector attr) {
+	String name = getName();
 	if (attr instanceof AttributeExact) {
-	    if (!value.equals(((AttributeExact) attr).getValue())) {
-		ac.getFrame().addWarning("incompatible", new String[] { toString(), attr.toString() });
+	    // if we have the same name...
+	    if (name.equals(attr.getName())) {
+		// and not the same value, raise a warning
+		if (!value.equals(((AttributeExact) attr).getValue())) {
+		    ac.getFrame().addWarning("incompatible", new String[] { toString(), attr.toString() });
+		}
 	    }
-	}
-	else if(attr instanceof AttributeOneOf) {
-	    if (!value.equals(((AttributeOneOf) attr).getValue())) {
-		ac.getFrame().addWarning("incompatible", new String[] { toString(), attr.toString() });
+	} else if(attr instanceof AttributeOneOf) {
+	    if (name.equals(attr.getName())) {
+		// FIXME check that the parsed one of value are matching before doing the conclict check
+		// requires breaking down the OneOf
+		if (!value.equals(((AttributeOneOf) attr).getValue())) {
+		    ac.getFrame().addWarning("incompatible", new String[] { toString(), attr.toString() });
+		}
 	    }
-	}
-	else if(attr instanceof AttributeBegin) {
-	    if (!value.equals(((AttributeBegin) attr).getValue())) {
-		ac.getFrame().addWarning("incompatible", new String[] { toString(), attr.toString() });
+	} else if(attr instanceof AttributeBegin) {
+	    if (name.equals(attr.getName())) {
+		String othervalue = ((AttributeBegin) attr).getValue();
+		// check if [lang|=en][lang=fr-FR] are incompatible 
+		// form CSS3 selectors about AttributeBegin
+		// its value either being exactly "val" or beginning with "val" immediately followed by "-" (U+002D). 
+		if (!value.equals(othervalue) && !value.startsWith(othervalue+"-")) {
+		    ac.getFrame().addWarning("incompatible", new String[] { toString(), attr.toString() });
+		}
 	    }
 	}
     }

Received on Tuesday, 13 May 2008 09:32:41 UTC