luehe 2003/02/24 10:09:38 Modified: jasper2/src/share/org/apache/jasper/compiler Generator.java Node.java Validator.java jasper2/src/share/org/apache/jasper/resources messages.properties Log: Fixed 17052: jsp:element name attribute clobbered by nested jsp:attribute Revision Changes Path 1.165 +14 -23 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java Index: Generator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v retrieving revision 1.164 retrieving revision 1.165 diff -u -r1.164 -r1.165 --- Generator.java 23 Feb 2003 20:57:05 -0000 1.164 +++ Generator.java 24 Feb 2003 18:09:36 -0000 1.165 @@ -1700,9 +1700,9 @@ public void visit(Node.JspElement n) throws JasperException { - // Hashtable for storing attribute name/value combinations + // Compute attribute value string for XML-style and named + // attributes Hashtable map = new Hashtable(); - Node.JspAttribute[] attrs = n.getJspAttributes(); for (int i=0; i<attrs.length; i++) { String attrStr = null; @@ -1710,34 +1710,25 @@ attrStr = generateNamedAttributeValue( attrs[i].getNamedAttributeNode()); } else { - if ("name".equals(attrs[i].getName())) { - attrStr = attributeValue(attrs[i], false, String.class, - "null"); - } else { - attrStr = attributeValue(attrs[i], false, Object.class, - "null"); - } - } - String s = null; - if ("name".equals(attrs[i].getName())) { - s = " + " + attrStr; - } else { - s = " + \" " + attrs[i].getName() + "=\\\"\" + " - + attrStr + " + \"\\\"\""; + attrStr = attributeValue(attrs[i], false, Object.class, + "null"); } + String s = " + \" " + attrs[i].getName() + "=\\\"\" + " + + attrStr + " + \"\\\"\""; map.put(attrs[i].getName(), s); } // Write begin tag out.printin("out.write(\"<\""); - // Write 'name' attribute - out.print((String) map.get("name")); + + // Write XML-style 'name' attribute + out.print(" + " + attributeValue(n.getNameAttribute(), false, + String.class, "null")); + // Write remaining attributes Enumeration enum = map.keys(); while (enum.hasMoreElements()) { String attrName = (String) enum.nextElement(); - if ("name".equals(attrName)) - continue; out.print((String) map.get(attrName)); } 1.62 +18 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java Index: Node.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- Node.java 23 Feb 2003 20:57:05 -0000 1.61 +++ Node.java 24 Feb 2003 18:09:37 -0000 1.62 @@ -1052,6 +1052,7 @@ public static class JspElement extends Node { private JspAttribute[] jspAttrs; + private JspAttribute nameAttr; public JspElement(Attributes attrs, Mark start, Node parent) { this(JSP_ELEMENT_ACTION, attrs, null, start, parent); @@ -1072,6 +1073,20 @@ public JspAttribute[] getJspAttributes() { return jspAttrs; + } + + /* + * Sets the XML-style 'name' attribute + */ + public void setNameAttribute(JspAttribute nameAttr) { + this.nameAttr = nameAttr; + } + + /* + * Gets the XML-style 'name' attribute + */ + public JspAttribute getNameAttribute() { + return this.nameAttr; } } 1.79 +25 -26 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java Index: Validator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v retrieving revision 1.78 retrieving revision 1.79 diff -u -r1.78 -r1.79 --- Validator.java 23 Feb 2003 20:57:05 -0000 1.78 +++ Validator.java 24 Feb 2003 18:09:37 -0000 1.79 @@ -896,19 +896,22 @@ public void visit(Node.JspElement n) throws JasperException { Attributes attrs = n.getAttributes(); - Node.Nodes namedAttributeNodes = n.getNamedAttributeNodes(); - Node.JspAttribute[] jspAttrs - = new Node.JspAttribute[attrs.getLength() - + namedAttributeNodes.size()]; + Node.Nodes namedAttrs = n.getNamedAttributeNodes(); + int xmlAttrLen = attrs.getLength(); + Node.JspAttribute[] jspAttrs = new Node.JspAttribute[xmlAttrLen-1 + + namedAttrs.size()]; - boolean nameSpecified = false; - for (int i=0; i<attrs.getLength(); i++) { - if ("name".equals(attrs.getQName(i))) { - nameSpecified = true; - jspAttrs[i] = getJspAttribute("name", null, null, - n.getAttributeValue("name"), - java.lang.String.class, null, - n, false); + // Process XML-style attributes + for (int i=0; i<xmlAttrLen && i<jspAttrs.length; i++) { + if ("name".equals(attrs.getLocalName(i))) { + n.setNameAttribute(getJspAttribute(attrs.getQName(i), + attrs.getURI(i), + "name", + n.getAttributeValue("name"), + java.lang.String.class, + null, + n, + false)); } else { jspAttrs[i] = getJspAttribute(attrs.getQName(i), attrs.getURI(i), @@ -920,18 +923,14 @@ false); } } - for (int i=0; i<namedAttributeNodes.size(); i++) { - Node.NamedAttribute na = - (Node.NamedAttribute) namedAttributeNodes.getNode(i); - if ("name".equals(na.getName())) { - nameSpecified = true; - } - jspAttrs[attrs.getLength() + i] - = new Node.JspAttribute(na, false); + if (n.getNameAttribute() == null) { + err.jspError(n, "jsp.error.jspelement.missing.name"); } - if (!nameSpecified) { - err.jspError(n, "jsp.error.jspelement.missing.name"); + // Process named attributes + for (int i=0; i<namedAttrs.size(); i++) { + Node.NamedAttribute na = (Node.NamedAttribute) namedAttrs.getNode(i); + jspAttrs[xmlAttrLen-1 + i] = new Node.JspAttribute(na, false); } n.setJspAttributes(jspAttrs); 1.95 +2 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties Index: messages.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages.properties,v retrieving revision 1.94 retrieving revision 1.95 diff -u -r1.94 -r1.95 --- messages.properties 14 Feb 2003 01:36:32 -0000 1.94 +++ messages.properties 24 Feb 2003 18:09:38 -0000 1.95 @@ -301,7 +301,7 @@ jsp.error.missing_var_or_varReader=Missing \'var\' or \'varReader\' attribute jsp.warning.bad.urlpattern.propertygroup=Bad value {0} in the url-pattern subelement in web.xml jsp.error.unknown_attribute_type=Unknown attribute type ({1}) for attribute {0}. -jsp.error.jspelement.missing.name=Mandatory attribute 'name' missing in jsp:element +jsp.error.jspelement.missing.name=Mandatory XML-style \'name\' attribute missing jsp.error.xmlns.redefinition.notimplemented=Internal error: Attempt to redefine xmlns:{0}. Redefinition of namespaces is not implemented. jsp.error.could.not.add.taglibraries=Could not add one or more tag libraries. jsp.error.duplicate.name.jspattribute=The attribute {0} specified in the standard or custom action also appears as the value of the name attribute in the enclosed jsp:attribute
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]