kinman 2002/11/08 11:55:47 Modified: jasper2/src/share/org/apache/jasper/compiler Generator.java JspDocumentParser.java Node.java PageInfo.java TagConstants.java Validator.java jasper2/src/share/org/apache/jasper/resources messages.properties Log: - Implemented <jsp:output>. - Suppress xml declaration if <jsp:output>'s omit-xml-declaration attribute is true Revision Changes Path 1.124 +6 -4 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.123 retrieving revision 1.124 diff -u -r1.123 -r1.124 --- Generator.java 8 Nov 2002 19:42:55 -0000 1.123 +++ Generator.java 8 Nov 2002 19:55:47 -0000 1.124 @@ -552,7 +552,9 @@ * Generates a XML declaration */ private void generateXmlDeclaration(Node.Nodes page) { - if (page.getRoot().isXmlSyntax() && ! pageInfo.hasJspRoot()) { + if (page.getRoot().isXmlSyntax() && ! pageInfo.hasJspRoot() && + (pageInfo.getOmitXmlDecl() == null /* not specified */ || + ! JspUtil.booleanValue(pageInfo.getOmitXmlDecl()))) { String cType = pageInfo.getContentType(); String charSet = cType.substring(cType.indexOf("charset=")+8); out.printil("out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\"" + 1.28 +5 -3 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.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- JspDocumentParser.java 8 Nov 2002 19:42:55 -0000 1.27 +++ JspDocumentParser.java 8 Nov 2002 19:55:47 -0000 1.28 @@ -277,6 +277,8 @@ 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( 1.39 +21 -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.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- Node.java 8 Nov 2002 19:42:55 -0000 1.38 +++ Node.java 8 Nov 2002 19:55:47 -0000 1.39 @@ -904,6 +904,20 @@ } /** + * Represents a <jsp:output>. + */ + public static class JspOutput extends Node { + + public JspOutput(Attributes attrs, Mark start, Node parent) { + super(attrs, start, parent); + } + + public void accept(Visitor v) throws JasperException { + v.visit(this); + } + } + + /** * Collected information about child elements. Used by nodes like * CustomTag, JspBody, and NamedAttribute. The information is * set in the Collector. @@ -1724,6 +1738,10 @@ } public void visit(TemplateText n) throws JasperException { + doVisit(n); + } + + public void visit(JspOutput n) throws JasperException { doVisit(n); } } 1.16 +12 -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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PageInfo.java 7 Nov 2002 22:19:13 -0000 1.15 +++ PageInfo.java 8 Nov 2002 19:55:47 -0000 1.16 @@ -102,6 +102,7 @@ private boolean elIgnored = false; private boolean elIgnoredSpecified = false; private boolean isXml = false; + private String omitXmlDecl = null; // true is there is a is-xml element in jsp-config private boolean isXmlSpecified = false; @@ -326,5 +327,13 @@ public boolean hasJspRoot() { return hasJspRoot; + } + + public String getOmitXmlDecl() { + return omitXmlDecl; + } + + public void setOmitXmlDecl(String omit) { + omitXmlDecl = omit; } } 1.8 +4 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java Index: TagConstants.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- TagConstants.java 30 Oct 2002 18:20:21 -0000 1.7 +++ TagConstants.java 8 Nov 2002 19:55:47 -0000 1.8 @@ -92,6 +92,7 @@ public static final String JSP_ATTRIBUTE = "jsp:attribute"; public static final String JSP_BODY = "jsp:body"; public static final String JSP_ELEMENT = "jsp:element"; + public static final String JSP_OUTPUT = "jsp:output"; /* * Tag Files 1.55 +17 -3 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.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- Validator.java 8 Nov 2002 19:42:55 -0000 1.54 +++ Validator.java 8 Nov 2002 19:55:47 -0000 1.55 @@ -434,6 +434,9 @@ new JspUtil.ValidAttribute("varReader"), new JspUtil.ValidAttribute("scope") }; + private static final JspUtil.ValidAttribute[] jspOutputAttrs = { + new JspUtil.ValidAttribute("omit-xml-declaration", true) }; + /* * Constructor */ @@ -844,6 +847,17 @@ n.setJspAttributes(jspAttrs); visitBody(n); + } + + public void visit(Node.JspOutput n) throws JasperException { + JspUtil.checkAttributes("jsp:output", n, jspOutputAttrs, err); + + if (pageInfo.getOmitXmlDecl() != null) { + err.jspError(n, "jsp.error.multiple.jspoutput"); + } + + pageInfo.setOmitXmlDecl( + n.getAttributeValue("omit-xml-declaration")); } /** 1.58 +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.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- messages.properties 8 Nov 2002 19:42:56 -0000 1.57 +++ messages.properties 8 Nov 2002 19:55:47 -0000 1.58 @@ -332,4 +332,5 @@ 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.attributes.not.allowed = {0} must not have any attributes
-- To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:tomcat-dev-help@;jakarta.apache.org>