luehe 2002/10/30 12:53:11 Modified: jasper2/src/share/org/apache/jasper/compiler TagFileProcessor.java jasper2/src/share/org/apache/jasper/resources messages.properties messages_es.properties messages_ja.properties Log: Enforce restriction that it is illegal to have a variable.name-given equal to an attribute.name in the same tag file translation unit. Revision Changes Path 1.35 +45 -10 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java Index: TagFileProcessor.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- TagFileProcessor.java 30 Oct 2002 17:41:22 -0000 1.34 +++ TagFileProcessor.java 30 Oct 2002 20:53:11 -0000 1.35 @@ -112,7 +112,7 @@ }; private static final JspUtil.ValidAttribute[] variableDirectiveAttrs = { - new JspUtil.ValidAttribute("name-given"), + new JspUtil.ValidAttribute("name-given", true), new JspUtil.ValidAttribute("variable-class"), new JspUtil.ValidAttribute("scope"), new JspUtil.ValidAttribute("declare"), @@ -131,9 +131,9 @@ private String smallIcon = null; private String largeIcon = null; private boolean dynamicAttributes = false; - - private Vector attributeVector = new Vector(); - private Vector variableVector = new Vector(); + + private Vector attributeVector; + private Vector variableVector; public TagFileDirectiveVisitor(Compiler compiler, TagLibraryInfo tagLibInfo, @@ -141,6 +141,8 @@ err = compiler.getErrorDispatcher(); this.tagLibInfo = tagLibInfo; this.name = name; + attributeVector = new Vector(); + variableVector = new Vector(); } public void visit(Node.TagDirective n) throws JasperException { @@ -233,6 +235,22 @@ scope)); } + /* + * Returns the vector of attributes corresponding to attribute + * directives. + */ + public Vector getAttributesVector() { + return attributeVector; + } + + /* + * Returns the vector of variables corresponding to variable + * directives. + */ + public Vector getVariablesVector() { + return variableVector; + } + public TagInfo getTagInfo() { if (name == null) { @@ -285,20 +303,37 @@ TagLibraryInfo tagLibInfo) throws JasperException { + ErrorDispatcher err = pc.getCompiler().getErrorDispatcher(); + Node.Nodes page = null; try { page = pc.parseTagFile(tagfile); } catch (FileNotFoundException e) { - pc.getCompiler().getErrorDispatcher().jspError( - "jsp.error.file.not.found", tagfile); + err.jspError("jsp.error.file.not.found", tagfile); } catch (IOException e) { - pc.getCompiler().getErrorDispatcher().jspError( - "jsp.error.file.not.found", tagfile); + err.jspError("jsp.error.file.not.found", tagfile); } TagFileDirectiveVisitor tagFileVisitor = new TagFileDirectiveVisitor(pc.getCompiler(), tagLibInfo, name); page.visit(tagFileVisitor); + + /* + * It is illegal to have a variable.name-given equal to an + * attribute.name in the same tag file translation unit. + */ + Iterator attrsIter = tagFileVisitor.getAttributesVector().iterator(); + while (attrsIter.hasNext()) { + TagAttributeInfo attrInfo = (TagAttributeInfo) attrsIter.next(); + Iterator varsIter = tagFileVisitor.getVariablesVector().iterator(); + while (varsIter.hasNext()) { + TagVariableInfo varInfo = (TagVariableInfo) varsIter.next(); + if (attrInfo.getName().equals(varInfo.getNameGiven())) { + err.jspError("jsp.error.tagfile.var_name_given_equals_attr_name", + tagfile, attrInfo.getName()); + } + } + } return tagFileVisitor.getTagInfo(); } 1.52 +2 -1 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.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- messages.properties 28 Oct 2002 22:01:34 -0000 1.51 +++ messages.properties 30 Oct 2002 20:53:11 -0000 1.52 @@ -301,3 +301,4 @@ jsp.error.attribute.non_rt_with_expr=According to TLD, attribute {0} does not accept any expressions jsp.error.scripting.variable.missing_name=Unable to determine scripting variable name from attribute {0} jasper.error.emptybodycontent.nonempty=According to TLD, tag {0} must be empty, but is not +jsp.error.tagfile.var_name_given_equals_attr_name=In tag file {0}, the name-given attribute ({1}) of a variable directive equals the name attribute of an attribute directive 1.19 +2 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_es.properties Index: messages_es.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_es.properties,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- messages_es.properties 28 Oct 2002 22:01:34 -0000 1.18 +++ messages_es.properties 30 Oct 2002 20:53:11 -0000 1.19 @@ -221,3 +221,4 @@ jsp.error.attribute.non_rt_with_expr= jsp.error.scripting.variable.missing_name= jasper.error.emptybodycontent.nonempty= +jsp.error.tagfile.var_name_given_equals_attr_name= 1.19 +2 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_ja.properties Index: messages_ja.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_ja.properties,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- messages_ja.properties 28 Oct 2002 22:01:34 -0000 1.18 +++ messages_ja.properties 30 Oct 2002 20:53:11 -0000 1.19 @@ -252,3 +252,4 @@ jsp.error.attribute.non_rt_with_expr= jsp.error.scripting.variable.missing_name= jasper.error.emptybodycontent.nonempty= +jsp.error.tagfile.var_name_given_equals_attr_name=
-- To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:tomcat-dev-help@;jakarta.apache.org>