tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kin...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java JspDocumentParser.java PageInfo.java
Date Fri, 01 Nov 2002 02:54:41 GMT
kinman      2002/10/31 18:54:41

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
                        JspDocumentParser.java PageInfo.java
  Log:
  - Generate an xml declaration if the JSP document (xml syntax) does not
    have <jsp:root> as its root element.  Take the encoding from the
    output contentType.
  
  Revision  Changes    Path
  1.116     +16 -3     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.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- Generator.java	1 Nov 2002 02:09:15 -0000	1.115
  +++ Generator.java	1 Nov 2002 02:54:41 -0000	1.116
  @@ -544,6 +544,18 @@
       }
   
       /**
  +     * Generates a XML declaration
  +     */
  +    private void generateXmlDeclaration(Node.Nodes page) {
  +	if (page.getRoot().isXmlSyntax() && ! pageInfo.hasJspRoot()) {
  +	    String cType = pageInfo.getContentType();
  +	    String charSet = cType.substring(cType.indexOf("charset=")+8);
  +	    out.printil("out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\"" +
  +		charSet + "\\\"?>\\n\");");
  +	}
  +    }
  +
  +    /**
        * Generates EL Function map section
        */
       private void generateELFunctionMap() 
  @@ -2840,6 +2852,7 @@
   	    gen.generateTagHandlerPostamble(  tagInfo );
   	} else {
   	    gen.generatePreamble(page);
  +	    gen.generateXmlDeclaration(page);
   	    gen.fragmentHelperClass.generatePreamble();
   	    page.visit(gen.new GenerateVisitor(gen.ctxt.isTagFile(),
   					       out,
  
  
  
  1.24      +9 -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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- JspDocumentParser.java	30 Oct 2002 18:20:21 -0000	1.23
  +++ JspDocumentParser.java	1 Nov 2002 02:54:41 -0000	1.24
  @@ -112,6 +112,7 @@
       private ErrorDispatcher err;
       private boolean isTagFile;
       private boolean directivesOnly;
  +    private boolean isTop;
   
       /*
        * Constructor
  @@ -130,6 +131,7 @@
   	this.inputSource = new InputSource(reader);
   	this.isTagFile = isTagFile;
   	this.directivesOnly = directivesOnly;
  +	this.isTop = true;
       }
   
       /*
  @@ -161,6 +163,7 @@
   		handler.addInclude(jspRoot,
   				   handler.pageInfo.getIncludePrelude());
   	    } else {
  +		handler.isTop = false;
   		handler.current = parent;
   	    }
   
  @@ -228,6 +231,9 @@
               // (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(
  
  
  
  1.13      +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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PageInfo.java	9 Oct 2002 17:41:13 -0000	1.12
  +++ PageInfo.java	1 Nov 2002 02:54:41 -0000	1.13
  @@ -97,6 +97,7 @@
       private boolean isXmlSpecified = false;	// true is there is a is-xml
   						// element in jsp-config
       private boolean hasTagFile = false;		// A custom tag is a tag file
  +    private boolean hasJspRoot = false;
       private Vector includePrelude;
       private Vector includeCoda;
   
  @@ -297,5 +298,13 @@
   
       public boolean hasTagFile() {
   	return hasTagFile;
  +    }
  +
  +    public void setHasJspRoot(boolean s) {
  +	hasJspRoot = s;
  +    }
  +
  +    public boolean hasJspRoot() {
  +	return hasJspRoot;
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message