tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler ParserController.java
Date Wed, 02 Apr 2003 03:45:08 GMT
luehe       2003/04/01 19:45:08

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        ParserController.java
  Log:
  A file included via the include directive is assumed to use the same
  syntax as the including file (that is, the standard and XML syntaxes
  cannot be mixed and matched)
  
  Revision  Changes    Path
  1.37      +40 -41    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java
  
  Index: ParserController.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- ParserController.java	25 Mar 2003 00:57:46 -0000	1.36
  +++ ParserController.java	2 Apr 2003 03:45:08 -0000	1.37
  @@ -85,8 +85,7 @@
       private ErrorDispatcher err;
   
       /*
  -     * Document information which tells us what
  -     * kind of document we are dealing with.
  +     * Indicates the syntax (XML or standard) of the file being processed
        */
       private boolean isXml;
   
  @@ -102,12 +101,6 @@
        */
       private static final String JSP_ROOT_TAG = "<jsp:root";
   
  -    /*
  -     * Tells if the file being processed is the "top" file in the translation
  -     * unit.
  -     */
  -    private boolean isTopFile = true;
  -
       private boolean isEncodingSpecifiedInProlog;
   
       private String sourceEnc;
  @@ -167,7 +160,6 @@
        */
       public Node.Nodes parseTagFileDirectives(String inFileName)
   	        throws FileNotFoundException, JasperException, IOException {
  -	isTopFile = true;
   	return parse(inFileName, null, true, true,
   		     (JarFile) ctxt.getTagFileJars().get(inFileName));
       }
  @@ -200,7 +192,13 @@
   
   	// Figure out what type of JSP document and encoding type we are
   	// dealing with
  -	determineSyntaxAndEncoding(absFileName, jarFile, jspConfigPageEnc);
  +	determineSyntaxAndEncoding(absFileName, jarFile, jspConfigPageEnc,
  +				   parent);
  +
  +	if (parent != null) {
  +	    // Included resource, add to dependent list
  +	    compiler.getPageInfo().addDependant(absFileName);
  +	}
   
   	if (isXml && isEncodingSpecifiedInProlog) {
   	    /*
  @@ -217,12 +215,6 @@
   	    }
   	}
   
  -	if (isTopFile) {
  -	    isTopFile = false;
  -	} else {
  -	    compiler.getPageInfo().addDependant(absFileName);
  -	}
  -
   	// Dispatch to the appropriate parser
   	if (isXml) {
   	    // JSP document (XML syntax)
  @@ -291,31 +283,28 @@
       }
   
       /**
  -     * Determines the properties of the given page or tag file.
  -     * The properties to be determined are:
  -     *
  -     *   - Syntax (JSP or XML).
  -     *     This information is supplied by setting the 'isXml' instance
  -     *     variable.
  +     * Determines the syntax (standard or XML) and page encoding properties
  +     * for the given file, and stores them in the 'isXml' and 'sourceEnc'
  +     * instance variables, respectively.
        *
  -     *   - Source Encoding.
  -     *     This information is supplied by setting the 'sourceEnc' instance
  -     *     variable.
  -     *
  -     * If these properties are already specified in the jsp-config element
  -     * in web.xml, then they are used.
  +     * The properties may already be specified in a JSP property group: notice
  +     * that while the 'isXml' property applies to an entire translation unit
  +     * (and therefore needs to be checked only for the top-level file), the
  +     * 'page-encoding' property must be checked separately for the top-level
  +     * and each of its included files, unless they're in XML syntax.
        */
       private void determineSyntaxAndEncoding(String absFileName,
   					    JarFile jarFile,
  -					    String jspConfigPageEnc)
  +					    String jspConfigPageEnc,
  +					    Node parent)
   	        throws JasperException, IOException {
   
   	isXml = false;
   
   	/*
  -	 * 'true' if the syntax of the page (XML or standard) is identified by
  -	 * external information: either via a JSP configuration element or
  -	 * the ".jspx" suffix
  +	 * 'true' if the syntax (XML or standard) of the file is given
  +	 * from external information: either via a JSP configuration element,
  +	 * the ".jspx" suffix, or the enclosing file (for included resources)
   	 */
   	boolean isExternal = false;
   
  @@ -325,13 +314,24 @@
   	 */
   	boolean revert = false;
   
  -	if (pageInfo.isXmlConfigSpecified()) {
  -	    // If <is-xml> is specified in a <jsp-property-group>, it is used.
  -	    isXml = pageInfo.isXmlConfig();
  -	    isExternal = true;
  -	} else if (absFileName.endsWith(".jspx")
  +	if (parent == null) {
  +	    // top-level file
  +	    if (pageInfo.isXmlConfigSpecified()) {
  +		// If <is-xml> is specified in a <jsp-property-group>, it is
  +		// used.
  +		isXml = pageInfo.isXmlConfig();
  +		isExternal = true;
  +	    } else if (absFileName.endsWith(".jspx")
   		       || absFileName.endsWith(".tagx")) {
  -	    isXml = true;
  +		isXml = true;
  +		isExternal = true;
  +	    }
  +	} else {
  +	    /*
  +	     * We're an included resource and, therefore, assumed to use the
  +	     * same syntax as the including file.
  +	     */
  +	    isXml = parent.getRoot().isXmlSyntax();
   	    isExternal = true;
   	}
   	
  @@ -356,7 +356,7 @@
   	    if (!isXml && sourceEnc.equals("UTF-8")) {
   		/*
   		 * We don't know if we're dealing with XML or standard syntax.
  -		 * Therefore, we need to check and see if the page contains
  +		 * Therefore, we need to check to see if the page contains
   		 * a <jsp:root> element.
   		 *
   		 * We need to be careful, because the page may be encoded in
  @@ -405,8 +405,7 @@
   	    Mark mark = jspReader.skipUntil(JSP_ROOT_TAG);
   	    if (mark != null) {
   	        isXml = true;
  -		if (revert) 
  -		    sourceEnc = "UTF-8";
  +		if (revert) sourceEnc = "UTF-8";
   		return;
   	    } else {
   	        isXml = false;
  
  
  

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


Mime
View raw message