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 JspDocumentParser.java
Date Fri, 16 Apr 2004 23:22:30 GMT
kinman      2004/04/16 16:22:30

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        JspDocumentParser.java
  Log:
  - Fix a bug where a custom tag with tagdependent body type is not
    handled correctly in XML syntax.  The fix would have been trivial if not
    for the cases where <jsp:attribute> and/or <jsp:body> is present.
  
  Revision  Changes    Path
  1.79      +97 -10    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.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- JspDocumentParser.java	13 Apr 2004 22:55:50 -0000	1.78
  +++ JspDocumentParser.java	16 Apr 2004 23:22:30 -0000	1.79
  @@ -102,13 +102,18 @@
       private boolean directivesOnly;
       private boolean isTop;
   
  +    // Nesting level of Tag dependent bodies
  +    private int tagDependentNesting = 0;
  +    // Flag set to delay incrmenting tagDependentNesting until jsp:body
  +    // is first encountered
  +    private boolean tagDependentPending = false;
  +
       /*
        * Constructor
        */
       public JspDocumentParser(
           ParserController pc,
           String path,
  -        JarFile jarFile,
           boolean isTagFile,
           boolean directivesOnly) {
           this.parserController = pc;
  @@ -139,7 +144,7 @@
           throws JasperException {
   
           JspDocumentParser jspDocParser =
  -            new JspDocumentParser(pc, path, jarFile, isTagFile, directivesOnly);
  +            new JspDocumentParser(pc, path, isTagFile, directivesOnly);
           Node.Nodes pageNodes = null;
   
           try {
  @@ -324,7 +329,52 @@
   
           Node node = null;
   
  -        if (JSP_URI.equals(uri)) {
  +        if (tagDependentPending && JSP_URI.equals(uri) &&
  +                     localName.equals(BODY_ACTION)) {
  +            tagDependentNesting++;
  +            current =
  +                parseStandardAction(
  +                    qName,
  +                    localName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    startMark,
  +                    current);
  +            tagDependentPending = false;
  +            return;
  +        }
  +
  +        if (tagDependentPending && JSP_URI.equals(uri) &&
  +                     localName.equals(ATTRIBUTE_ACTION)) {
  +            current =
  +                parseStandardAction(
  +                    qName,
  +                    localName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    startMark,
  +                    current);
  +            return;
  +        }
  +
  +        if (tagDependentPending) {
  +            tagDependentPending = false;
  +            tagDependentNesting++;
  +        }
  +
  +        if (tagDependentNesting > 0) {
  +            node =
  +                new Node.UninterpretedTag(
  +                    qName,
  +                    localName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    startMark,
  +                    current);
  +        } else if (JSP_URI.equals(uri)) {
               node =
                   parseStandardAction(
                       qName,
  @@ -357,17 +407,15 @@
                           current);
               } else {
                   // custom action
  -                Node.CustomTag custom = (Node.CustomTag) node;
  -	        String bodyType;
  -	        if (custom.getTagInfo() != null) {
  -	            bodyType = custom.getTagInfo().getBodyContent();
  -	        } else {
  -	            bodyType = custom.getTagFileInfo().getTagInfo().getBodyContent();
  -	        }
  +	        String bodyType = getBodyType((Node.CustomTag) node);
  +
                   if (scriptlessBodyNode == null
                           && bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS))
{
                       scriptlessBodyNode = node;
                   }
  +                else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType))
{
  +                    tagDependentPending = true;
  +                }
               }
           }
   
  @@ -425,6 +473,22 @@
                   }
               }
           }
  +
  +        if (!isAllSpace && tagDependentPending) {
  +            tagDependentPending = false;
  +            tagDependentNesting++;
  +        }
  +
  +        if (tagDependentNesting > 0) {
  +            if (charBuffer.length() > 0) {
  +                new Node.TemplateText(charBuffer.toString(), startMark, current);
  +            }
  +            startMark = new Mark(path, locator.getLineNumber(),
  +                                 locator.getColumnNumber());
  +            charBuffer = null;
  +            return;
  +        }
  +
           if ((current instanceof Node.JspText)
               || (current instanceof Node.NamedAttribute)
               || !isAllSpace) {
  @@ -571,6 +635,10 @@
               checkScriptingBody((Node.ScriptingElement)current);
           }
   
  +        if ( isTagDependent(current)) {
  +            tagDependentNesting--;
  +        }
  +
           if (current.getParent() != null) {
               current = current.getParent();
               if (scriptlessBodyNode != null
  @@ -1333,5 +1401,24 @@
           EnableDTDValidationException(String message, Locator loc) {
               super(message, loc);
           }
  +    }
  +
  +    private static String getBodyType(Node.CustomTag custom) {
  +
  +        if (custom.getTagInfo() != null) {
  +            return custom.getTagInfo().getBodyContent();
  +        }
  +
  +        return custom.getTagFileInfo().getTagInfo().getBodyContent();
  +    }
  +
  +    private boolean isTagDependent(Node n) {
  +
  +        if (n instanceof Node.CustomTag) {
  +            String bodyType = getBodyType((Node.CustomTag) n);
  +            return
  +                TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType);
  +        }
  +        return 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