kinman 2003/08/14 14:16:52 Modified: jasper2/src/share/org/apache/jasper/compiler ErrorDispatcher.java Generator.java PageInfo.java Validator.java jasper2/src/share/org/apache/jasper/resources messages.properties messages_es.properties messages_fr.properties messages_ja.properties Log: - Add attibutes doctype-root-element, doctype-system and doctype-public to <jsp:output> for outputing a DOCTYPE declartion in xml documents, per latest spec change. Revision Changes Path 1.13 +24 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java Index: ErrorDispatcher.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ErrorDispatcher.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ErrorDispatcher.java 11 Aug 2003 21:11:07 -0000 1.12 +++ ErrorDispatcher.java 14 Aug 2003 21:16:52 -0000 1.13 @@ -240,7 +240,7 @@ * resource bundle for localized error messages, it is used as the error * message. * - * @param n Node that caused the error + * @param where Error location * @param errCode Error code * @param arg1 First argument for parametric replacement * @param arg2 Second argument for parametric replacement @@ -269,6 +269,26 @@ public void jspError(Node n, String errCode, String arg1, String arg2) throws JasperException { dispatch(n.getStart(), errCode, new Object[] {arg1, arg2}, null); + } + + /* + * Dispatches the given JSP parse error to the configured error handler. + * + * The given error code is localized. If it is not found in the + * resource bundle for localized error messages, it is used as the error + * message. + * + * @param n Node that caused the error + * @param errCode Error code + * @param arg1 First argument for parametric replacement + * @param arg2 Second argument for parametric replacement + * @param arg3 Third argument for parametric replacement + */ + + public void jspError(Node n, String errCode, String arg1, String arg2, + String arg3) + throws JasperException { + dispatch(n.getStart(), errCode, new Object[] {arg1, arg2, arg3}, null); } /* 1.195 +40 -11 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.194 retrieving revision 1.195 diff -u -r1.194 -r1.195 --- Generator.java 9 Aug 2003 19:19:37 -0000 1.194 +++ Generator.java 14 Aug 2003 21:16:52 -0000 1.195 @@ -594,14 +594,18 @@ } /** - * Generates an XML declaration, under the following conditions: - * - * - 'omit-xml-declaration' attribute of <jsp:output> action is set to - * "no" or "false" - * - JSP document without a <jsp:root> + * Generates an XML Prolog, which includes an XML declaration and + * an XML doctype declaration. */ - private void generateXmlDeclaration(Node.Nodes page) { + private void generateXmlProlog(Node.Nodes page) { + /* + * An XML declaration is generated under the following conditions: + * + * - 'omit-xml-declaration' attribute of <jsp:output> action is set to + * "no" or "false" + * - JSP document without a <jsp:root> + */ String omitXmlDecl = pageInfo.getOmitXmlDecl(); if ((omitXmlDecl != null && !JspUtil.booleanValue(omitXmlDecl)) || (omitXmlDecl == null && page.getRoot().isXmlSyntax() @@ -611,6 +615,31 @@ out.printil("out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\"" + charSet + "\\\"?>\\n\");"); } + + /* + * Output a DOCTYPE declaration if the doctype-root-element appears. + * If doctype-public appears: + * <!DOCTYPE name PUBLIC "doctypePublic" "doctypeSystem"> + * else + * <!DOCTYPE name SYSTEM "doctypeSystem" > + */ + + String doctypeName = pageInfo.getDoctypeName(); + if (doctypeName != null) { + String doctypePublic = pageInfo.getDoctypePublic(); + String doctypeSystem = pageInfo.getDoctypeSystem(); + out.printin("out.write(\"<!DOCTYPE "); + out.print(doctypeName); + if (doctypePublic == null) { + out.print(" SYSTEM \\\""); + } else { + out.print(" PUBLIC \\\""); + out.print(doctypePublic); + out.print("\\\" \\\""); + } + out.print(doctypeSystem); + out.println("\\\">\\n\");"); + } } /* @@ -2916,7 +2945,7 @@ return; } - gen.generateXmlDeclaration(page); + gen.generateXmlProlog(page); gen.fragmentHelperClass.generatePreamble(); page.visit(gen.new GenerateVisitor(gen.ctxt.isTagFile(), out, @@ -2927,7 +2956,7 @@ gen.generateTagHandlerPostamble(tagInfo); } else { gen.generatePreamble(page); - gen.generateXmlDeclaration(page); + gen.generateXmlProlog(page); gen.fragmentHelperClass.generatePreamble(); page.visit(gen.new GenerateVisitor(gen.ctxt.isTagFile(), out, 1.39 +29 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageInfo.java Index: PageInfo.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageInfo.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- PageInfo.java 8 Aug 2003 22:22:09 -0000 1.38 +++ PageInfo.java 14 Aug 2003 21:16:52 -0000 1.39 @@ -105,6 +105,9 @@ private String isELIgnoredValue; private boolean isELIgnored = false; private String omitXmlDecl = null; + private String doctypeName = null; + private String doctypePublic = null; + private String doctypeSystem = null; private boolean isJspPrefixHijacked; @@ -227,6 +230,29 @@ omitXmlDecl = omit; } + public String getDoctypeName() { + return doctypeName; + } + + public void setDoctypeName(String doctypeName) { + this.doctypeName = doctypeName; + } + + public String getDoctypeSystem() { + return doctypeSystem; + } + + public void setDoctypeSystem(String doctypeSystem) { + this.doctypeSystem = doctypeSystem; + } + + public String getDoctypePublic() { + return doctypePublic; + } + + public void setDoctypePublic(String doctypePublic) { + this.doctypePublic = doctypePublic; + } /* Tag library and XML namespace management methods */ 1.113 +60 -8 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.112 retrieving revision 1.113 diff -u -r1.112 -r1.113 --- Validator.java 4 Aug 2003 22:55:44 -0000 1.112 +++ Validator.java 14 Aug 2003 21:16:52 -0000 1.113 @@ -408,7 +408,10 @@ new JspUtil.ValidAttribute("scope") }; private static final JspUtil.ValidAttribute[] jspOutputAttrs = { - new JspUtil.ValidAttribute("omit-xml-declaration") }; + new JspUtil.ValidAttribute("omit-xml-declaration"), + new JspUtil.ValidAttribute("doctype-root-element"), + new JspUtil.ValidAttribute("doctype-public"), + new JspUtil.ValidAttribute("doctype-system") }; /* * Constructor @@ -813,12 +816,61 @@ err.jspError(n, "jsp.error.jspoutput.nonemptybody"); } - if (pageInfo.getOmitXmlDecl() != null) { - err.jspError(n, "jsp.error.multiple.jspoutput"); + String omitXmlDecl = n.getAttributeValue("omit-xml-declaration"); + String doctypeName = n.getAttributeValue("doctype-root-element"); + String doctypePublic = n.getAttributeValue("doctype-public"); + String doctypeSystem = n.getAttributeValue("doctype-system"); + + String omitXmlDeclOld = pageInfo.getOmitXmlDecl(); + String doctypeNameOld = pageInfo.getDoctypeName(); + String doctypePublicOld = pageInfo.getDoctypePublic(); + String doctypeSystemOld = pageInfo.getDoctypeSystem(); + + if (omitXmlDecl != null && omitXmlDeclOld != null && + !omitXmlDecl.equals(omitXmlDeclOld) ) { + err.jspError(n, "jsp.error.jspoutput.conflict", + "omit-xml-declaration", omitXmlDeclOld, omitXmlDecl); + } + + if (doctypeName != null && doctypeNameOld != null && + !doctypeName.equals(doctypeNameOld) ) { + err.jspError(n, "jsp.error.jspoutput.conflict", + "doctype-root-element", doctypeNameOld, doctypeName); + } + + if (doctypePublic != null && doctypePublicOld != null && + !doctypePublic.equals(doctypePublicOld) ) { + err.jspError(n, "jsp.error.jspoutput.conflict", + "doctype-public", doctypePublicOld, doctypePublic); + } + + if (doctypeSystem != null && doctypeSystemOld != null && + !doctypeSystem.equals(doctypeSystemOld) ) { + err.jspError(n, "jsp.error.jspoutput.conflict", + "doctype-system", doctypeSystemOld, doctypeSystem); } - pageInfo.setOmitXmlDecl( - n.getAttributeValue("omit-xml-declaration")); + if (doctypeName == null && doctypeSystem != null || + doctypeName != null && doctypeSystem == null) { + err.jspError(n, "jsp.error.jspoutput.doctypenamesystem"); + } + + if (doctypePublic != null && doctypeSystem == null) { + err.jspError(n, "jsp.error.jspoutput.doctypepulicsystem"); + } + + if (omitXmlDecl != null) { + pageInfo.setOmitXmlDecl(omitXmlDecl); + } + if (doctypeName != null) { + pageInfo.setDoctypeName(doctypeName); + } + if (doctypeSystem != null) { + pageInfo.setDoctypeSystem(doctypeSystem); + } + if (doctypePublic != null) { + pageInfo.setDoctypePublic(doctypePublic); + } } public void visit(Node.InvokeAction n) throws JasperException { 1.130 +5 -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.129 retrieving revision 1.130 diff -u -r1.129 -r1.130 --- messages.properties 12 Aug 2003 19:11:45 -0000 1.129 +++ messages.properties 14 Aug 2003 21:16:52 -0000 1.130 @@ -372,7 +372,10 @@ jsp.error.xml.closeQuoteMissingInTextDecl = closing quote in the value following \"{0}\" in the text declaration is missing. jsp.error.xml.closeQuoteMissingInXMLDecl = closing quote in the value following \"{0}\" in the XML declaration is missing. jsp.error.xml.invalidHighSurrogate = High surrogate bits in UTF-8 sequence must not exceed 0x10 but found 0x{0}. -jsp.error.multiple.jspoutput = Cannot have multiple occurrences of <jsp:output> +jsp.error.multiple.jsp = Cannot have multiple specifications of +jsp.error.jspoutput.conflict=<jsp:output>: illegal to have multiple occurrences of \"{0}\" with different values (old: {1}, new: {2}) +jsp.error.jspoutput.doctypenamesystem=<jsp:output>: 'doctype-root-element' and 'doctype-system' attributes must appear together +jsp.error.jspoutput.doctypepulicsystem=<jsp:output>: 'doctype-system' attribute must appear if 'doctype-public' attribute appears jsp.error.jspoutput.nonemptybody=<jsp:output> must not have a body jsp.error.jspoutput.invalidUse=<jsp:output> must not be used in standard syntax jsp.error.attributes.not.allowed = {0} must not have any attributes 1.43 +7 -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.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- messages_es.properties 11 Aug 2003 21:11:07 -0000 1.42 +++ messages_es.properties 14 Aug 2003 21:16:52 -0000 1.43 @@ -256,3 +256,9 @@ jsp.error.coda.xml= jsp.error.jsptext.badcontent= jsp.error.prefix.refined= +jsp.error.jspoutput.conflict= +jsp.error.jspoutput.doctypenamesystem= +jsp.error.jspoutput.doctypepulicsystem= +jsp.error.jspoutput.nonemptybody= +jsp.error.jspoutput.invalidUse= + 1.28 +7 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_fr.properties Index: messages_fr.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/resources/messages_fr.properties,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- messages_fr.properties 11 Aug 2003 21:11:07 -0000 1.27 +++ messages_fr.properties 14 Aug 2003 21:16:52 -0000 1.28 @@ -293,3 +293,9 @@ jsp.error.coda.xml= jsp.error.jsptext.badcontent= jsp.error.prefix.refined= +jsp.error.jspoutput.conflict= +jsp.error.jspoutput.doctypenamesystem= +jsp.error.jspoutput.doctypepulicsystem= +jsp.error.jspoutput.nonemptybody= +jsp.error.jspoutput.invalidUse= + 1.44 +7 -2 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.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- messages_ja.properties 11 Aug 2003 21:11:07 -0000 1.43 +++ messages_ja.properties 14 Aug 2003 21:16:52 -0000 1.44 @@ -334,7 +334,6 @@ jsp.error.xml.closeQuoteMissingInTextDecl = \u30c6\u30ad\u30b9\u30c8\u5ba3\u8a00\u4e2d\u306e\"{0}\"\u306b\u7d9a\u304f\u5024\u306e\u4e2d\u306e\u6700\u5f8c\u306e\u30af\u30aa\u30fc\u30c8\u304c\u3042\u308a\u307e\u305b\u3093 jsp.error.xml.closeQuoteMissingInXMLDecl = XML\u5ba3\u8a00\u4e2d\u306e\"{0}\"\u306b\u7d9a\u304f\u5024\u306e\u4e2d\u306e\u6700\u5f8c\u306e\u30af\u30aa\u30fc\u30c8\u304c\u3042\u308a\u307e\u305b\u3093 jsp.error.xml.invalidHighSurrogate = UTF-8\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u30cf\u30a4\u30b5\u30ed\u30b2\u30fc\u30c8\u30d3\u30c3\u30c8\u306f0x10\u3092\u8d8a\u3048\u3066\u306f\u3044\u3051\u307e\u305b\u3093\u304c\u30010x{0}\u304c\u898b\u3064\u304b\u308a\u307e\u3057\u305f -jsp.error.multiple.jspoutput = <jsp:output>\u3092\u8907\u6570\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093 jsp.error.attributes.not.allowed = {0} \u306f\u5c5e\u6027\u3092\u6301\u3064\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093 jsp.error.tagfile.badSuffix=\u30bf\u30b0\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9 {0} \u306e\u4e2d\u306b\".tag\" \u62e1\u5f35\u5b50\u304c\u3042\u308a\u307e\u305b\u3093 jsp.error.tagfile.illegalPath=\u4e0d\u6b63\u306a\u30bf\u30b0\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3067\u3059: {0}\u3001\u3053\u308c\u306f\"/WEB-INF/tags\"\u307e\u305f\u306f\"/META-INF/tags\"\u3067\u59cb\u307e\u3089\u306a\u3051\u308c\u3070\u3044\u3051\u307e\u305b\u3093 @@ -348,3 +347,9 @@ jsp.error.prelude.xml=JSP\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8 {0} \u306f\u305d\u308c\u306b\u95a2\u9023\u3057\u305f\u5c0e\u5165\u90e8 ({1}) \u3092\u6301\u3063\u3066\u3044\u307e\u3059 jsp.error.coda.xml=JSP\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8 {0} \u306f\u305d\u308c\u306b\u95a2\u9023\u3057\u305f\u7d42\u7d50\u90e8 ({1}) \u3092\u6301\u3063\u3066\u3044\u307e\u3059 jsp.error.prefix.refined= +jsp.error.jspoutput.conflict= +jsp.error.jspoutput.doctypenamesystem= +jsp.error.jspoutput.doctypepulicsystem= +jsp.error.jspoutput.nonemptybody= +jsp.error.jspoutput.invalidUse= +
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]