luehe 2003/02/07 12:16:18 Modified: jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java jasper2/src/share/org/apache/jasper/resources messages.properties Log: Added translation error for invalid standard actions in XML syntax (translation error is already being thrown in standard syntax) Revision Changes Path 1.37 +129 -111 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java Index: JspDocumentParser.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspDocumentParser.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- JspDocumentParser.java 1 Feb 2003 02:41:13 -0000 1.36 +++ JspDocumentParser.java 7 Feb 2003 20:16:18 -0000 1.37 @@ -221,9 +221,6 @@ Mark start = new Mark(path, locator.getLineNumber(), locator.getColumnNumber()); - Attributes attrsCopy = null; - - Node node = null; // XXX - As of JSP 2.0, xmlns: can appear in any node (not just // <jsp:root>). The spec still needs clarification here. @@ -231,6 +228,7 @@ // is valid from that point forward. Redefinitions cause an // error. This isn't quite consistent with how xmlns: normally // works. + Attributes attrsCopy = null; try { attrsCopy = addCustomTagLibraries(attrs); } catch (JasperException je) { @@ -239,108 +237,12 @@ locator, je ); } - if (qName.equals(JSP_ROOT)) { - // give the <jsp:root> element the original attributes set - // (attrs) instead of the copy without the xmlns: elements - // (attrsCopy) - node = new Node.JspRoot(new AttributesImpl(attrs), start, current); - if (isTop) { - pageInfo.setHasJspRoot(true); - } - } else if (qName.equals(JSP_PAGE_DIRECTIVE)) { - if (isTagFile) { - throw new SAXParseException( - Localizer.getMessage("jsp.error.action.istagfile", qName), - locator); - } - node = new Node.PageDirective(attrsCopy, start, current); - String imports = attrs.getValue("import"); - // There can only be one 'import' attribute per page directive - if (imports != null) { - ((Node.PageDirective) node).addImport(imports); - } - } else if (qName.equals(JSP_INCLUDE_DIRECTIVE)) { - node = new Node.IncludeDirective(attrsCopy, start, current); - processIncludeDirective(attrsCopy.getValue("file"), node); - } else if (qName.equals(JSP_DECLARATION)) { - node = new Node.Declaration(start, current); - } else if (qName.equals(JSP_SCRIPTLET)) { - node = new Node.Scriptlet(start, current); - } else if (qName.equals(JSP_EXPRESSION)) { - node = new Node.Expression(start, current); - } else if (qName.equals(JSP_USE_BEAN)) { - node = new Node.UseBean(attrsCopy, start, current); - } else if (qName.equals(JSP_SET_PROPERTY)) { - node = new Node.SetProperty(attrsCopy, start, current); - } else if (qName.equals(JSP_GET_PROPERTY)) { - node = new Node.GetProperty(attrsCopy, start, current); - } else if (qName.equals(JSP_INCLUDE)) { - node = new Node.IncludeAction(attrsCopy, start, current); - } else if (qName.equals(JSP_FORWARD)) { - node = new Node.ForwardAction(attrsCopy, start, current); - } else if (qName.equals(JSP_PARAM)) { - node = new Node.ParamAction(attrsCopy, start, current); - } else if (qName.equals(JSP_PARAMS)) { - node = new Node.ParamsAction(start, current); - } else if (qName.equals(JSP_PLUGIN)) { - node = new Node.PlugIn(attrsCopy, start, current); - } else if (qName.equals(JSP_TEXT)) { - node = new Node.JspText(start, current); - } else if (qName.equals(JSP_BODY)) { - node = new Node.JspBody(start, current); - } else if (qName.equals(JSP_ATTRIBUTE)) { - node = new Node.NamedAttribute(attrsCopy, start, current); - } else if (qName.equals(JSP_OUTPUT)) { - node = new Node.JspOutput(attrsCopy, start, current); - } else if (qName.equals(JSP_TAG_DIRECTIVE)) { - if (!isTagFile) { - throw new SAXParseException( - Localizer.getMessage("jsp.error.action.isnottagfile", - qName), - locator); - } - node = new Node.TagDirective(attrsCopy, start, current); - String imports = attrs.getValue("import"); - // There can only be one 'import' attribute per tag directive - if (imports != null) { - ((Node.TagDirective) node).addImport(imports); - } - } else if (qName.equals(JSP_ATTRIBUTE_DIRECTIVE)) { - if (!isTagFile) { - throw new SAXParseException( - Localizer.getMessage("jsp.error.action.isnottagfile", - qName), - locator); - } - node = new Node.AttributeDirective(attrsCopy, start, current); - } else if (qName.equals(JSP_VARIABLE_DIRECTIVE)) { - if (!isTagFile) { - throw new SAXParseException( - Localizer.getMessage("jsp.error.action.isnottagfile", - qName), - locator); - } - node = new Node.VariableDirective(attrsCopy, start, current); - } else if (qName.equals(JSP_INVOKE)) { - if (!isTagFile) { - throw new SAXParseException( - Localizer.getMessage("jsp.error.action.isnottagfile", - qName), - locator); - } - node = new Node.InvokeAction(attrsCopy, start, current); - } else if (qName.equals(JSP_DO_BODY)) { - if (!isTagFile) { - throw new SAXParseException( - Localizer.getMessage("jsp.error.action.isnottagfile", - qName), - locator); - } - node = new Node.DoBodyAction(attrsCopy, start, current); - } else if (qName.equals(JSP_ELEMENT)) { - node = new Node.JspElement(attrsCopy, start, current); + Node node = null; + if (qName.startsWith("jsp:")) { + node = parseStandardAction(qName, attrs, attrsCopy, start, + current); } else { - node = getCustomTag(qName, attrsCopy, start, current); + node = parseCustomAction(qName, attrsCopy, start, current); if (node == null) { node = new Node.UninterpretedTag(attrsCopy, start, qName, current); @@ -580,14 +482,130 @@ //********************************************************************* // Private utility methods + private Node parseStandardAction(String qName, Attributes attrs, + Attributes attrsCopy, Mark start, + Node parent) + throws SAXException { + + Node node = null; + + if (qName.equals(JSP_ROOT)) { + // give the <jsp:root> element the original attributes set + // (attrs) instead of the copy without the xmlns: elements + // (attrsCopy) + node = new Node.JspRoot(new AttributesImpl(attrs), start, current); + if (isTop) { + pageInfo.setHasJspRoot(true); + } + } else if (qName.equals(JSP_PAGE_DIRECTIVE)) { + if (isTagFile) { + throw new SAXParseException( + Localizer.getMessage("jsp.error.action.istagfile", qName), + locator); + } + node = new Node.PageDirective(attrsCopy, start, current); + String imports = attrs.getValue("import"); + // There can only be one 'import' attribute per page directive + if (imports != null) { + ((Node.PageDirective) node).addImport(imports); + } + } else if (qName.equals(JSP_INCLUDE_DIRECTIVE)) { + node = new Node.IncludeDirective(attrsCopy, start, current); + processIncludeDirective(attrsCopy.getValue("file"), node); + } else if (qName.equals(JSP_DECLARATION)) { + node = new Node.Declaration(start, current); + } else if (qName.equals(JSP_SCRIPTLET)) { + node = new Node.Scriptlet(start, current); + } else if (qName.equals(JSP_EXPRESSION)) { + node = new Node.Expression(start, current); + } else if (qName.equals(JSP_USE_BEAN)) { + node = new Node.UseBean(attrsCopy, start, current); + } else if (qName.equals(JSP_SET_PROPERTY)) { + node = new Node.SetProperty(attrsCopy, start, current); + } else if (qName.equals(JSP_GET_PROPERTY)) { + node = new Node.GetProperty(attrsCopy, start, current); + } else if (qName.equals(JSP_INCLUDE)) { + node = new Node.IncludeAction(attrsCopy, start, current); + } else if (qName.equals(JSP_FORWARD)) { + node = new Node.ForwardAction(attrsCopy, start, current); + } else if (qName.equals(JSP_PARAM)) { + node = new Node.ParamAction(attrsCopy, start, current); + } else if (qName.equals(JSP_PARAMS)) { + node = new Node.ParamsAction(start, current); + } else if (qName.equals(JSP_PLUGIN)) { + node = new Node.PlugIn(attrsCopy, start, current); + } else if (qName.equals(JSP_TEXT)) { + node = new Node.JspText(start, current); + } else if (qName.equals(JSP_BODY)) { + node = new Node.JspBody(start, current); + } else if (qName.equals(JSP_ATTRIBUTE)) { + node = new Node.NamedAttribute(attrsCopy, start, current); + } else if (qName.equals(JSP_OUTPUT)) { + node = new Node.JspOutput(attrsCopy, start, current); + } else if (qName.equals(JSP_TAG_DIRECTIVE)) { + if (!isTagFile) { + throw new SAXParseException( + Localizer.getMessage("jsp.error.action.isnottagfile", + qName), + locator); + } + node = new Node.TagDirective(attrsCopy, start, current); + String imports = attrs.getValue("import"); + // There can only be one 'import' attribute per tag directive + if (imports != null) { + ((Node.TagDirective) node).addImport(imports); + } + } else if (qName.equals(JSP_ATTRIBUTE_DIRECTIVE)) { + if (!isTagFile) { + throw new SAXParseException( + Localizer.getMessage("jsp.error.action.isnottagfile", + qName), + locator); + } + node = new Node.AttributeDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_VARIABLE_DIRECTIVE)) { + if (!isTagFile) { + throw new SAXParseException( + Localizer.getMessage("jsp.error.action.isnottagfile", + qName), + locator); + } + node = new Node.VariableDirective(attrsCopy, start, current); + } else if (qName.equals(JSP_INVOKE)) { + if (!isTagFile) { + throw new SAXParseException( + Localizer.getMessage("jsp.error.action.isnottagfile", + qName), + locator); + } + node = new Node.InvokeAction(attrsCopy, start, current); + } else if (qName.equals(JSP_DO_BODY)) { + if (!isTagFile) { + throw new SAXParseException( + Localizer.getMessage("jsp.error.action.isnottagfile", + qName), + locator); + } + node = new Node.DoBodyAction(attrsCopy, start, current); + } else if (qName.equals(JSP_ELEMENT)) { + node = new Node.JspElement(attrsCopy, start, current); + } else { + throw new SAXParseException( + Localizer.getMessage("jsp.error.badStandardAction"), + locator); + } + + return node; + } + /* * Checks if the XML element with the given tag name is a custom action, * and returns the corresponding Node object. */ - private Node getCustomTag(String qName, - Attributes attrs, - Mark start, - Node parent) throws SAXException { + private Node parseCustomAction(String qName, + Attributes attrs, + Mark start, + Node parent) throws SAXException { int colon = qName.indexOf(':'); if (colon == -1) { return null; 1.89 +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.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- messages.properties 3 Feb 2003 20:33:36 -0000 1.88 +++ messages.properties 7 Feb 2003 20:16:18 -0000 1.89 @@ -304,7 +304,7 @@ 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 jsp.error.not.in.template={0} not allowed in a template text body. -jsp.error.badStandardAction=The action is not a recognizable standard action. +jsp.error.badStandardAction=Invalid standard action jsp.error.tagdirective.badbodycontent=Invalid body-content ({0}) in tag directive jsp.error.config_pagedir_encoding_mismatch=Page-encoding specified in jsp-property-group ({0}) is different from that specified in page directive ({1}) jsp.error.prolog_pagedir_encoding_mismatch=Page-encoding specified in XML prolog ({0}) is different from that specified in page directive ({1})
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]