ecarmich    2003/08/31 17:17:35

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        JspDocumentParser.java
  Log:
  Expand wildcard imports
  Remove unused imports
  Remove tabs
  
  Revision  Changes    Path
  1.69      +874 -644  
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.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- JspDocumentParser.java    29 Aug 2003 19:31:22 -0000      1.68
  +++ JspDocumentParser.java    1 Sep 2003 00:17:35 -0000       1.69
  @@ -57,22 +57,33 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - */ 
  + */
   package org.apache.jasper.compiler;
   
  -import java.io.*;
  -import java.util.*;
  +import java.io.CharArrayWriter;
  +import java.io.FileNotFoundException;
  +import java.io.IOException;
  +import java.util.Iterator;
  +import java.util.List;
   import java.util.jar.JarFile;
  -import javax.servlet.jsp.tagext.*;
  -import javax.xml.parsers.SAXParserFactory;
  -import javax.xml.parsers.ParserConfigurationException;
  +
  +import javax.servlet.jsp.tagext.TagFileInfo;
  +import javax.servlet.jsp.tagext.TagInfo;
  +import javax.servlet.jsp.tagext.TagLibraryInfo;
   import javax.xml.parsers.SAXParser;
  -import org.xml.sax.*;
  -import org.xml.sax.ext.LexicalHandler;
  -import org.xml.sax.helpers.DefaultHandler;
  -import org.xml.sax.helpers.AttributesImpl;
  +import javax.xml.parsers.SAXParserFactory;
  +
   import org.apache.jasper.JasperException;
   import org.apache.jasper.JspCompilationContext;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.Locator;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.SAXParseException;
  +import org.xml.sax.XMLReader;
  +import org.xml.sax.ext.LexicalHandler;
  +import org.xml.sax.helpers.AttributesImpl;
  +import org.xml.sax.helpers.DefaultHandler;
   
   /**
    * Class implementing a parser for a JSP document, that is, a JSP page in XML
  @@ -81,19 +92,21 @@
    * @author Jan Luehe
    */
   
  -class JspDocumentParser extends DefaultHandler
  -            implements LexicalHandler, TagConstants {
  +class JspDocumentParser
  +    extends DefaultHandler
  +    implements LexicalHandler, TagConstants {
   
       private static final String JSP_VERSION = "version";
  -    private static final String LEXICAL_HANDLER_PROPERTY
  -     = "http://xml.org/sax/properties/lexical-handler";;
  +    private static final String LEXICAL_HANDLER_PROPERTY =
  +        "http://xml.org/sax/properties/lexical-handler";;
   
  -    private static final EnableDTDValidationException 
ENABLE_DTD_VALIDATION_EXCEPTION
  -        = new EnableDTDValidationException("jsp.error.enable_dtd_validation",
  -                                           null);
  +    private static final EnableDTDValidationException 
ENABLE_DTD_VALIDATION_EXCEPTION =
  +        new EnableDTDValidationException(
  +            "jsp.error.enable_dtd_validation",
  +            null);
   
       private ParserController parserController;
  -    private JspCompilationContext ctxt;    
  +    private JspCompilationContext ctxt;
       private PageInfo pageInfo;
       private String path;
   
  @@ -115,11 +128,12 @@
       /*
        * Constructor
        */
  -    public JspDocumentParser(ParserController pc,
  -                          String path,
  -                          JarFile jarFile,
  -                          boolean isTagFile,
  -                          boolean directivesOnly) {
  +    public JspDocumentParser(
  +        ParserController pc,
  +        String path,
  +        JarFile jarFile,
  +        boolean isTagFile,
  +        boolean directivesOnly) {
           this.parserController = pc;
           this.ctxt = pc.getJspCompilationContext();
           this.pageInfo = pc.getCompiler().getPageInfo();
  @@ -135,77 +149,82 @@
        *
        * @throws JasperException
        */
  -    public static Node.Nodes parse(ParserController pc,
  -                                String path,
  -                                JarFile jarFile,
  -                                Node parent,
  -                                boolean isTagFile,
  -                                boolean directivesOnly,
  -                                String pageEnc,
  -                                String jspConfigPageEnc,
  -                                boolean isEncodingSpecifiedInProlog)
  -             throws JasperException {
  -
  -     JspDocumentParser jspDocParser = new JspDocumentParser(pc,
  -                                                               path,
  -                                                            jarFile,
  -                                                            isTagFile,
  -                                                            directivesOnly);
  -     Node.Nodes pageNodes = null;
  -
  -     try {
  -
  -         // Create dummy root and initialize it with given page encodings
  -         Node.Root dummyRoot = new Node.Root(null, parent, true);
  -         dummyRoot.setPageEncoding(pageEnc);
  -         dummyRoot.setJspConfigPageEncoding(jspConfigPageEnc);
  -         dummyRoot.setIsEncodingSpecifiedInProlog(isEncodingSpecifiedInProlog);
  -         jspDocParser.current = dummyRoot;
  -         if (parent == null) {
  -             jspDocParser.addInclude(dummyRoot,
  -                     jspDocParser.pageInfo.getIncludePrelude());
  -         } else {
  -             jspDocParser.isTop = false;
  -         }
  +    public static Node.Nodes parse(
  +        ParserController pc,
  +        String path,
  +        JarFile jarFile,
  +        Node parent,
  +        boolean isTagFile,
  +        boolean directivesOnly,
  +        String pageEnc,
  +        String jspConfigPageEnc,
  +        boolean isEncodingSpecifiedInProlog)
  +        throws JasperException {
  +
  +        JspDocumentParser jspDocParser =
  +            new JspDocumentParser(pc, path, jarFile, isTagFile, directivesOnly);
  +        Node.Nodes pageNodes = null;
  +
  +        try {
  +
  +            // Create dummy root and initialize it with given page encodings
  +            Node.Root dummyRoot = new Node.Root(null, parent, true);
  +            dummyRoot.setPageEncoding(pageEnc);
  +            dummyRoot.setJspConfigPageEncoding(jspConfigPageEnc);
  +            dummyRoot.setIsEncodingSpecifiedInProlog(
  +                isEncodingSpecifiedInProlog);
  +            jspDocParser.current = dummyRoot;
  +            if (parent == null) {
  +                jspDocParser.addInclude(
  +                    dummyRoot,
  +                    jspDocParser.pageInfo.getIncludePrelude());
  +            } else {
  +                jspDocParser.isTop = false;
  +            }
   
  -         // Parse the input
  +            // Parse the input
               SAXParser saxParser = getSAXParser(false, jspDocParser);
               try {
  -                saxParser.parse(jspDocParser.getInputSource(
  -                                                        path,
  -                                                        jarFile,
  -                                                        jspDocParser.ctxt,
  -                                                        jspDocParser.err),
  -                                jspDocParser);
  +                saxParser.parse(
  +                    jspDocParser.getInputSource(
  +                        path,
  +                        jarFile,
  +                        jspDocParser.ctxt,
  +                        jspDocParser.err),
  +                    jspDocParser);
               } catch (EnableDTDValidationException e) {
                   saxParser = getSAXParser(true, jspDocParser);
                   jspDocParser.isValidating = true;
  -                saxParser.parse(jspDocParser.getInputSource(
  -                                                        path,
  -                                                        jarFile,
  -                                                        jspDocParser.ctxt,
  -                                                        jspDocParser.err),
  -                                jspDocParser);
  -            }
  -
  -         if (parent == null) {
  -             jspDocParser.addInclude(dummyRoot,
  -                     jspDocParser.pageInfo.getIncludeCoda());
  -         }
  -
  -         // Create Node.Nodes from dummy root
  -         pageNodes = new Node.Nodes(dummyRoot);
  -
  -     } catch (IOException ioe) {
  -         jspDocParser.err.jspError("jsp.error.data.file.read", path, ioe);
  -     } catch (Exception e) {
  -         jspDocParser.err.jspError(
  -                new Mark(path, ((SAXParseException) e).getLineNumber(),
  -                         ((SAXParseException) e).getColumnNumber()),
  +                saxParser.parse(
  +                    jspDocParser.getInputSource(
  +                        path,
  +                        jarFile,
  +                        jspDocParser.ctxt,
  +                        jspDocParser.err),
  +                    jspDocParser);
  +            }
  +
  +            if (parent == null) {
  +                jspDocParser.addInclude(
  +                    dummyRoot,
  +                    jspDocParser.pageInfo.getIncludeCoda());
  +            }
  +
  +            // Create Node.Nodes from dummy root
  +            pageNodes = new Node.Nodes(dummyRoot);
  +
  +        } catch (IOException ioe) {
  +            jspDocParser.err.jspError("jsp.error.data.file.read", path, ioe);
  +        } catch (Exception e) {
  +            jspDocParser.err.jspError(
  +                new Mark(
  +                    path,
  +                    ((SAXParseException)e).getLineNumber(),
  +                    ((SAXParseException)e).getColumnNumber()),
                   e.getMessage());
  -     }
  +        }
   
  -     return pageNodes;
  +        return pageNodes;
       }
   
       /*
  @@ -215,20 +234,20 @@
        * subelements of the jsp-config element in web.xml
        */
       private void addInclude(Node parent, List files) throws SAXException {
  -     if (files != null) {
  -         Iterator iter = files.iterator();
  -         while (iter.hasNext()) {
  -             String file = (String) iter.next();
  -             AttributesImpl attrs = new AttributesImpl();
  -             attrs.addAttribute("", "file", "file", "CDATA", file);
  -
  -             // Create a dummy Include directive node
  -             Node includeDir = new Node.IncludeDirective(attrs, 
  -                                                        null, // XXX
  -                                                        parent);
  -             processIncludeDirective(file, includeDir);
  -         }
  -     }
  +        if (files != null) {
  +            Iterator iter = files.iterator();
  +            while (iter.hasNext()) {
  +                String file = (String)iter.next();
  +                AttributesImpl attrs = new AttributesImpl();
  +                attrs.addAttribute("", "file", "file", "CDATA", file);
  +
  +                // Create a dummy Include directive node
  +                    Node includeDir =
  +                        new Node.IncludeDirective(attrs, null, // XXX
  +    parent);
  +                processIncludeDirective(file, includeDir);
  +            }
  +        }
       }
   
       /*
  @@ -244,100 +263,123 @@
        * corresponding TagLibraryInfo object is added to the set of custom
        * tag libraries.
        */
  -    public void startElement(String uri,
  -                          String localName,
  -                          String qName,
  -                          Attributes attrs) throws SAXException {
  -
  -     AttributesImpl taglibAttrs = null;
  -     AttributesImpl nonTaglibAttrs = null;
  -     AttributesImpl nonTaglibXmlnsAttrs = null;
  -
  -     checkPrefixes(uri, qName, attrs);
  -
  -     if (directivesOnly && !localName.startsWith(DIRECTIVE_ACTION)) {
  -         return;
  -     }
  -
  -     // jsp:text must not have any subelements
  -     if (TEXT_ACTION.equals(current.getLocalName())) {
  -         throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.text.has_subelement"),
  -                 locator);
  -     }
  -
  -     Mark start = new Mark(path, locator.getLineNumber(),
  -                           locator.getColumnNumber());
  -
  -     if (attrs != null) {
  -         /*
  -          * Notice that due to a bug in the underlying SAX parser, the
  -          * attributes must be enumerated in descending order. 
  -          */
  -         boolean isTaglib = false;
  -         for (int i=attrs.getLength()-1; i>=0; i--) {
  -             isTaglib = false;
  -             String attrQName = attrs.getQName(i);
  -             if (!attrQName.startsWith("xmlns")) {
  -                 if (nonTaglibAttrs == null) {
  -                     nonTaglibAttrs = new AttributesImpl();
  -                 }
  -                 nonTaglibAttrs.addAttribute(attrs.getURI(i),
  -                                             attrs.getLocalName(i),
  -                                             attrs.getQName(i),
  -                                             attrs.getType(i),
  -                                             attrs.getValue(i));
  -             } else {
  -                 if (attrQName.startsWith("xmlns:jsp")) {
  -                     isTaglib = true;
  -                 } else {
  -                     String attrUri = attrs.getValue(i);
  -                     // TaglibInfo for this uri already established in
  -                     // startPrefixMapping
  -                     isTaglib = pageInfo.hasTaglib(attrUri);
  -                 }
  -                 if (isTaglib) {
  -                     if (taglibAttrs == null) {
  -                         taglibAttrs = new AttributesImpl();
  -                     }
  -                     taglibAttrs.addAttribute(attrs.getURI(i),
  -                                              attrs.getLocalName(i),
  -                                              attrs.getQName(i),
  -                                              attrs.getType(i),
  -                                              attrs.getValue(i));
  -                 } else {
  -                     if (nonTaglibXmlnsAttrs == null) {
  -                         nonTaglibXmlnsAttrs = new AttributesImpl();
  -                     }
  -                     nonTaglibXmlnsAttrs.addAttribute(attrs.getURI(i),
  -                                                      attrs.getLocalName(i),
  -                                                      attrs.getQName(i),
  -                                                      attrs.getType(i),
  -                                                      attrs.getValue(i));
  -                 }
  -             }
  -         }
  -     }
  -
  -     Node node = null;
  -
  -     if ("http://java.sun.com/JSP/Page".equals(uri)) {
  -         node = parseStandardAction(qName, localName, nonTaglibAttrs,
  -                                    nonTaglibXmlnsAttrs, taglibAttrs,
  -                                    start, current);
  -     } else {
  -         node = parseCustomAction(qName, localName, uri, nonTaglibAttrs,
  -                                  nonTaglibXmlnsAttrs, taglibAttrs, start,
  -                                  current);
  -         if (node == null) {
  -             node = new Node.UninterpretedTag(qName, localName,
  -                                              nonTaglibAttrs,
  -                                              nonTaglibXmlnsAttrs,
  -                                              taglibAttrs, start, current);
  -         }
  -     }
  +    public void startElement(
  +        String uri,
  +        String localName,
  +        String qName,
  +        Attributes attrs)
  +        throws SAXException {
  +
  +        AttributesImpl taglibAttrs = null;
  +        AttributesImpl nonTaglibAttrs = null;
  +        AttributesImpl nonTaglibXmlnsAttrs = null;
  +
  +        checkPrefixes(uri, qName, attrs);
  +
  +        if (directivesOnly && !localName.startsWith(DIRECTIVE_ACTION)) {
  +            return;
  +        }
  +
  +        // jsp:text must not have any subelements
  +        if (TEXT_ACTION.equals(current.getLocalName())) {
  +            throw new SAXParseException(
  +                Localizer.getMessage("jsp.error.text.has_subelement"),
  +                locator);
  +        }
  +
  +        Mark start =
  +            new Mark(path, locator.getLineNumber(), locator.getColumnNumber());
  +
  +        if (attrs != null) {
  +            /*
  +             * Notice that due to a bug in the underlying SAX parser, the
  +             * attributes must be enumerated in descending order. 
  +             */
  +            boolean isTaglib = false;
  +            for (int i = attrs.getLength() - 1; i >= 0; i--) {
  +                isTaglib = false;
  +                String attrQName = attrs.getQName(i);
  +                if (!attrQName.startsWith("xmlns")) {
  +                    if (nonTaglibAttrs == null) {
  +                        nonTaglibAttrs = new AttributesImpl();
  +                    }
  +                    nonTaglibAttrs.addAttribute(
  +                        attrs.getURI(i),
  +                        attrs.getLocalName(i),
  +                        attrs.getQName(i),
  +                        attrs.getType(i),
  +                        attrs.getValue(i));
  +                } else {
  +                    if (attrQName.startsWith("xmlns:jsp")) {
  +                        isTaglib = true;
  +                    } else {
  +                        String attrUri = attrs.getValue(i);
  +                        // TaglibInfo for this uri already established in
  +                        // startPrefixMapping
  +                        isTaglib = pageInfo.hasTaglib(attrUri);
  +                    }
  +                    if (isTaglib) {
  +                        if (taglibAttrs == null) {
  +                            taglibAttrs = new AttributesImpl();
  +                        }
  +                        taglibAttrs.addAttribute(
  +                            attrs.getURI(i),
  +                            attrs.getLocalName(i),
  +                            attrs.getQName(i),
  +                            attrs.getType(i),
  +                            attrs.getValue(i));
  +                    } else {
  +                        if (nonTaglibXmlnsAttrs == null) {
  +                            nonTaglibXmlnsAttrs = new AttributesImpl();
  +                        }
  +                        nonTaglibXmlnsAttrs.addAttribute(
  +                            attrs.getURI(i),
  +                            attrs.getLocalName(i),
  +                            attrs.getQName(i),
  +                            attrs.getType(i),
  +                            attrs.getValue(i));
  +                    }
  +                }
  +            }
  +        }
  +
  +        Node node = null;
  +
  +        if ("http://java.sun.com/JSP/Page".equals(uri)) {
  +            node =
  +                parseStandardAction(
  +                    qName,
  +                    localName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else {
  +            node =
  +                parseCustomAction(
  +                    qName,
  +                    localName,
  +                    uri,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +            if (node == null) {
  +                node =
  +                    new Node.UninterpretedTag(
  +                        qName,
  +                        localName,
  +                        nonTaglibAttrs,
  +                        nonTaglibXmlnsAttrs,
  +                        taglibAttrs,
  +                        start,
  +                        current);
  +            }
  +        }
   
  -     current = node;
  +        current = node;
       }
   
       /*
  @@ -349,145 +391,151 @@
        *
        * @throws SAXException
        */
  -    public void characters(char[] buf,
  -                        int offset,
  -                        int len) throws SAXException {
  -     /*
  -      * JSP.6.1.1: All textual nodes that have only white space are to be
  -      * dropped from the document, except for nodes in a jsp:text element,
  -      * and any leading and trailing white-space-only textual nodes in a
  -      * jsp:attribute whose 'trim' attribute is set to FALSE, which are to
  -      * be kept verbatim.
  -      * JSP.6.2.3 defines white space characters.
  -      */
  -     boolean isAllSpace = true;
  -     if (!(current instanceof Node.JspText)
  -             && !(current instanceof Node.NamedAttribute)) {
  -         for (int i=offset; i<offset+len; i++) {
  -             if (!(buf[i] == ' ' || buf[i] == '\n' || buf[i] == '\r' ||
  -                     buf[i] == '\t' )) {
  -                 isAllSpace = false;
  -                 break;
  -             }
  -         }
  -     }
  -     if ((current instanceof Node.JspText)
  -             || (current instanceof Node.NamedAttribute) || !isAllSpace) {
  -         Mark start = new Mark(path, locator.getLineNumber(),
  -                               locator.getColumnNumber());
  -
  -         CharArrayWriter ttext = new CharArrayWriter();
  -         int limit = offset + len;
  -         int lastCh = 0;
  -         for (int i = offset; i < limit; i++) {
  -             int ch = buf[i];
  -             if (lastCh == '$' && ch == '{') {
  -                 if (ttext.size() > 0) {
  -                     new Node.TemplateText(ttext.toString(), start,
  -                                           current);
  -                     ttext = new CharArrayWriter();
  -                 }
  -                 // following "${" to first unquoted "}"
  -                 i++;
  -                 boolean singleQ = false;
  -                 boolean doubleQ = false;
  -                 lastCh = 0;
  -                 for (; ; i++) {
  -                     if (i >= limit) {
  -                         throw new SAXParseException(
  -                             Localizer.getMessage("jsp.error.unterminated",
  -                                                  "${"),
  -                             locator);
  -
  -                     }
  -                     ch = buf[i];
  -                     if (lastCh == '\\' && (singleQ || doubleQ)) {
  -                         ttext.write(ch);
  -                         lastCh = 0;
  -                         continue;
  -                     }
  -                     if (ch == '}') {
  -                         new Node.ELExpression(ttext.toString(), start,
  -                                               current);
  -                         ttext = new CharArrayWriter();
  -                         break;
  -                     }
  -                     if (ch == '"')
  -                         doubleQ = !doubleQ;
  -                     else if (ch == '\'')
  -                         singleQ = !singleQ;
  -
  -                     ttext.write(ch);
  -                     lastCh = ch;
  -                 }
  -             } else {
  -                 if( (lastCh == '$') && (ch != '{') ) {
  -                        ttext.write( '$' );
  +    public void characters(char[] buf, int offset, int len)
  +        throws SAXException {
  +        /*
  +         * JSP.6.1.1: All textual nodes that have only white space are to be
  +         * dropped from the document, except for nodes in a jsp:text element,
  +         * and any leading and trailing white-space-only textual nodes in a
  +         * jsp:attribute whose 'trim' attribute is set to FALSE, which are to
  +         * be kept verbatim.
  +         * JSP.6.2.3 defines white space characters.
  +         */
  +        boolean isAllSpace = true;
  +        if (!(current instanceof Node.JspText)
  +            && !(current instanceof Node.NamedAttribute)) {
  +            for (int i = offset; i < offset + len; i++) {
  +                if (!(buf[i] == ' '
  +                    || buf[i] == '\n'
  +                    || buf[i] == '\r'
  +                    || buf[i] == '\t')) {
  +                    isAllSpace = false;
  +                    break;
  +                }
  +            }
  +        }
  +        if ((current instanceof Node.JspText)
  +            || (current instanceof Node.NamedAttribute)
  +            || !isAllSpace) {
  +            Mark start =
  +                new Mark(
  +                    path,
  +                    locator.getLineNumber(),
  +                    locator.getColumnNumber());
  +
  +            CharArrayWriter ttext = new CharArrayWriter();
  +            int limit = offset + len;
  +            int lastCh = 0;
  +            for (int i = offset; i < limit; i++) {
  +                int ch = buf[i];
  +                if (lastCh == '$' && ch == '{') {
  +                    if (ttext.size() > 0) {
  +                        new Node.TemplateText(ttext.toString(), start, current);
  +                        ttext = new CharArrayWriter();
  +                    }
  +                    // following "${" to first unquoted "}"
  +                    i++;
  +                    boolean singleQ = false;
  +                    boolean doubleQ = false;
  +                    lastCh = 0;
  +                    for (;; i++) {
  +                        if (i >= limit) {
  +                            throw new SAXParseException(
  +                                Localizer.getMessage(
  +                                    "jsp.error.unterminated",
  +                                    "${"),
  +                                locator);
  +
  +                        }
  +                        ch = buf[i];
  +                        if (lastCh == '\\' && (singleQ || doubleQ)) {
  +                            ttext.write(ch);
  +                            lastCh = 0;
  +                            continue;
  +                        }
  +                        if (ch == '}') {
  +                            new Node.ELExpression(
  +                                ttext.toString(),
  +                                start,
  +                                current);
  +                            ttext = new CharArrayWriter();
  +                            break;
  +                        }
  +                        if (ch == '"')
  +                            doubleQ = !doubleQ;
  +                        else if (ch == '\'')
  +                            singleQ = !singleQ;
  +
  +                        ttext.write(ch);
  +                        lastCh = ch;
                       }
  -                    if( ch != '$' ) {
  -                        ttext.write( ch );
  +                } else {
  +                    if ((lastCh == '$') && (ch != '{')) {
  +                        ttext.write('$');
  +                    }
  +                    if (ch != '$') {
  +                        ttext.write(ch);
                       }
                   }
                   lastCh = ch;
  -         }
  -         if (lastCh == '$') {
  -             ttext.write('$');
  -         }
  -         if (ttext.size() > 0) {
  -             new Node.TemplateText(ttext.toString(), start, current);
  -         }
  -     }
  +            }
  +            if (lastCh == '$') {
  +                ttext.write('$');
  +            }
  +            if (ttext.size() > 0) {
  +                new Node.TemplateText(ttext.toString(), start, current);
  +            }
  +        }
       }
   
       /*
        * Receives notification of the end of an element.
        */
  -    public void endElement(String uri,
  -                        String localName,
  -                        String qName) throws SAXException {
  -
  -     if (directivesOnly && !localName.startsWith(DIRECTIVE_ACTION)) {
  -         return;
  -     }
  -
  -     if (current instanceof Node.NamedAttribute) {
  -         boolean isTrim = ((Node.NamedAttribute) current).isTrim();
  -         Node.Nodes subElems = ((Node.NamedAttribute) current).getBody();
  -         for (int i=0; subElems != null && i<subElems.size(); i++) {
  -             Node subElem = subElems.getNode(i);
  -             if (!(subElem instanceof Node.TemplateText)) {
  -                 continue;
  -             }
  -             // Ignore any whitespace (including spaces, carriage returns,
  -             // line feeds, and tabs, that appear at the beginning and at
  -             // the end of the body of the <jsp:attribute> action, if the
  -             // action's 'trim' attribute is set to TRUE (default).
  -             // In addition, any textual nodes in the <jsp:attribute> that
  -             // have only white space are dropped from the document, with
  -             // the exception of leading and trailing white-space-only
  -             // textual nodes in a <jsp:attribute> whose 'trim' attribute
  -             // is set to FALSE, which must be kept verbatim.
  -             if (i == 0) {
  -                 if (isTrim) {
  -                     ((Node.TemplateText) subElem).ltrim();
  -                 }
  -             } else if (i == subElems.size()-1) {
  -                 if (isTrim) {
  -                     ((Node.TemplateText) subElem).rtrim();
  -                 }
  -             } else {
  -                 if (((Node.TemplateText) subElem).isAllSpace()) {
  -                     subElems.remove(subElem);
  -                 }
  -             }
  -         }
  -     } else if (current instanceof Node.ScriptingElement) {
  -         checkScriptingBody((Node.ScriptingElement) current);
  -     }
  -
  -     if (current.getParent() != null) {
  -         current = current.getParent();
  -     }
  +    public void endElement(String uri, String localName, String qName)
  +        throws SAXException {
  +
  +        if (directivesOnly && !localName.startsWith(DIRECTIVE_ACTION)) {
  +            return;
  +        }
  +
  +        if (current instanceof Node.NamedAttribute) {
  +            boolean isTrim = ((Node.NamedAttribute)current).isTrim();
  +            Node.Nodes subElems = ((Node.NamedAttribute)current).getBody();
  +            for (int i = 0; subElems != null && i < subElems.size(); i++) {
  +                Node subElem = subElems.getNode(i);
  +                if (!(subElem instanceof Node.TemplateText)) {
  +                    continue;
  +                }
  +                // Ignore any whitespace (including spaces, carriage returns,
  +                // line feeds, and tabs, that appear at the beginning and at
  +                // the end of the body of the <jsp:attribute> action, if the
  +                // action's 'trim' attribute is set to TRUE (default).
  +                // In addition, any textual nodes in the <jsp:attribute> that
  +                // have only white space are dropped from the document, with
  +                // the exception of leading and trailing white-space-only
  +                // textual nodes in a <jsp:attribute> whose 'trim' attribute
  +                // is set to FALSE, which must be kept verbatim.
  +                if (i == 0) {
  +                    if (isTrim) {
  +                        ((Node.TemplateText)subElem).ltrim();
  +                    }
  +                } else if (i == subElems.size() - 1) {
  +                    if (isTrim) {
  +                        ((Node.TemplateText)subElem).rtrim();
  +                    }
  +                } else {
  +                    if (((Node.TemplateText)subElem).isAllSpace()) {
  +                        subElems.remove(subElem);
  +                    }
  +                }
  +            }
  +        } else if (current instanceof Node.ScriptingElement) {
  +            checkScriptingBody((Node.ScriptingElement)current);
  +        }
  +
  +        if (current.getParent() != null) {
  +            current = current.getParent();
  +        }
       }
   
       /*
  @@ -496,66 +544,69 @@
        * @param locator the document locator
        */
       public void setDocumentLocator(Locator locator) {
  -     this.locator = locator;
  +        this.locator = locator;
       }
   
       /*
        * See org.xml.sax.ext.LexicalHandler.
        */
       public void comment(char[] buf, int offset, int len) throws SAXException {
  -     // ignore comments in the DTD
  -     if (!inDTD) {
  -         Mark start = new Mark(path, locator.getLineNumber(),
  -                               locator.getColumnNumber());
  -         new Node.Comment(new String(buf, offset, len), start, current);
  -     }
  +        // ignore comments in the DTD
  +        if (!inDTD) {
  +            Mark start =
  +                new Mark(
  +                    path,
  +                    locator.getLineNumber(),
  +                    locator.getColumnNumber());
  +            new Node.Comment(new String(buf, offset, len), start, current);
  +        }
       }
   
       /*
        * See org.xml.sax.ext.LexicalHandler.
        */
       public void startCDATA() throws SAXException {
  -     // do nothing
  +        // do nothing
       }
   
       /*
        * See org.xml.sax.ext.LexicalHandler.
        */
       public void endCDATA() throws SAXException {
  -     // do nothing
  +        // do nothing
       }
   
       /*
        * See org.xml.sax.ext.LexicalHandler.
        */
       public void startEntity(String name) throws SAXException {
  -     // do nothing
  +        // do nothing
       }
   
       /*
        * See org.xml.sax.ext.LexicalHandler.
        */
       public void endEntity(String name) throws SAXException {
  -     // do nothing
  +        // do nothing
       }
   
       /*
        * See org.xml.sax.ext.LexicalHandler.
        */
  -    public void startDTD(String name, String publicId,
  -                      String systemId) throws SAXException {
  +    public void startDTD(String name, String publicId, String systemId)
  +        throws SAXException {
           if (!isValidating) {
               fatalError(ENABLE_DTD_VALIDATION_EXCEPTION);
           }
  - 
  -     inDTD = true;
  +
  +        inDTD = true;
       }
  -          
  +
       /*
        * See org.xml.sax.ext.LexicalHandler.
        */
       public void endDTD() throws SAXException {
  -     inDTD = false;
  +        inDTD = false;
       }
   
       /*
  @@ -576,14 +627,15 @@
        * Receives notification of the start of a Namespace mapping. 
        */
       public void startPrefixMapping(String prefix, String uri)
  -          throws SAXException {
  +        throws SAXException {
           TagLibraryInfo taglibInfo;
           try {
               taglibInfo = getTaglibInfo(prefix, uri);
           } catch (JasperException je) {
               throw new SAXParseException(
                   Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
  -                locator, je);
  +                locator,
  +                je);
           }
   
           if (taglibInfo != null) {
  @@ -592,239 +644,399 @@
           } else {
               pageInfo.pushPrefixMapping(prefix, null);
           }
  -     }
  +    }
   
  -     /*
  -      * Receives notification of the end of a Namespace mapping. 
  -      */
  +    /*
  +     * Receives notification of the end of a Namespace mapping. 
  +     */
       public void endPrefixMapping(String prefix) throws SAXException {
           pageInfo.popPrefixMapping(prefix);
       }
   
  -
       //*********************************************************************
       // Private utility methods
   
  -    private Node parseStandardAction(String qName, String localName,
  -                                  Attributes nonTaglibAttrs,
  -                                  Attributes nonTaglibXmlnsAttrs,
  -                                  Attributes taglibAttrs,
  -                                  Mark start, Node parent)
  -             throws SAXException {
  +    private Node parseStandardAction(
  +        String qName,
  +        String localName,
  +        Attributes nonTaglibAttrs,
  +        Attributes nonTaglibXmlnsAttrs,
  +        Attributes taglibAttrs,
  +        Mark start,
  +        Node parent)
  +        throws SAXException {
   
  -     Node node = null;
  +        Node node = null;
   
  -     if (localName.equals(ROOT_ACTION)) {
  +        if (localName.equals(ROOT_ACTION)) {
               if (!(current instanceof Node.Root)) {
                   throw new SAXParseException(
                       Localizer.getMessage("jsp.error.nested_jsproot"),
                       locator);
               }
  -            node = new Node.JspRoot(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs,
  -                                 taglibAttrs, start, current);
  -         if (isTop) {
  -             pageInfo.setHasJspRoot(true);
  -         }
  -     } else if (localName.equals(PAGE_DIRECTIVE_ACTION)) {
  -         if (isTagFile) {
  -             throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.action.istagfile",
  -                                      localName),
  -                 locator);
  -         }
  -         node = new Node.PageDirective(qName, nonTaglibAttrs,
  -                                       nonTaglibXmlnsAttrs, taglibAttrs,
  -                                       start, current);
  -         String imports = nonTaglibAttrs.getValue("import");
  -         // There can only be one 'import' attribute per page directive
  -         if (imports != null) {
  -             ((Node.PageDirective) node).addImport(imports);
  -         }
  -     } else if (localName.equals(INCLUDE_DIRECTIVE_ACTION)) {
  -         node = new Node.IncludeDirective(qName, nonTaglibAttrs,
  -                                          nonTaglibXmlnsAttrs, taglibAttrs,
  -                                          start, current);
  -         processIncludeDirective(nonTaglibAttrs.getValue("file"), node);
  -     } else if (localName.equals(DECLARATION_ACTION)) {
  -         node = new Node.Declaration(qName, nonTaglibXmlnsAttrs,
  -                                     taglibAttrs, start, current);
  -     } else if (localName.equals(SCRIPTLET_ACTION)) {
  -         node = new Node.Scriptlet(qName, nonTaglibXmlnsAttrs, taglibAttrs,
  -                                   start, current);
  -     } else if (localName.equals(EXPRESSION_ACTION)) {
  -         node = new Node.Expression(qName, nonTaglibXmlnsAttrs, taglibAttrs,
  -                                    start, current);
  -     } else if (localName.equals(USE_BEAN_ACTION)) {
  -         node = new Node.UseBean(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs,
  -                                 taglibAttrs, start, current);
  -     } else if (localName.equals(SET_PROPERTY_ACTION)) {
  -         node = new Node.SetProperty(qName, nonTaglibAttrs,
  -                                     nonTaglibXmlnsAttrs, taglibAttrs,
  -                                     start, current);
  -     } else if (localName.equals(GET_PROPERTY_ACTION)) {
  -         node = new Node.GetProperty(qName, nonTaglibAttrs,
  -                                     nonTaglibXmlnsAttrs, taglibAttrs,
  -                                     start, current);
  -     } else if (localName.equals(INCLUDE_ACTION)) {
  -         node = new Node.IncludeAction(qName, nonTaglibAttrs,
  -                                       nonTaglibXmlnsAttrs, taglibAttrs,
  -                                       start, current);
  -     } else if (localName.equals(FORWARD_ACTION)) {
  -         node = new Node.ForwardAction(qName, nonTaglibAttrs,
  -                                       nonTaglibXmlnsAttrs, taglibAttrs,
  -                                       start, current);
  -     } else if (localName.equals(PARAM_ACTION)) {
  -         node = new Node.ParamAction(qName, nonTaglibAttrs,
  -                                     nonTaglibXmlnsAttrs, taglibAttrs,
  -                                     start, current);
  -     } else if (localName.equals(PARAMS_ACTION)) {
  -         node = new Node.ParamsAction(qName, nonTaglibXmlnsAttrs,
  -                                      taglibAttrs, start, current);
  -     } else if (localName.equals(PLUGIN_ACTION)) {
  -         node = new Node.PlugIn(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs,
  -                                taglibAttrs, start, current);
  -     } else if (localName.equals(TEXT_ACTION)) {
  -         node = new Node.JspText(qName, nonTaglibXmlnsAttrs, taglibAttrs,
  -                                 start, current);
  -     } else if (localName.equals(BODY_ACTION)) {
  -         node = new Node.JspBody(qName, nonTaglibXmlnsAttrs, taglibAttrs,
  -                                 start, current);
  -     } else if (localName.equals(ATTRIBUTE_ACTION)) {
  -         node = new Node.NamedAttribute(qName, nonTaglibAttrs,
  -                                        nonTaglibXmlnsAttrs, taglibAttrs,
  -                                        start, current);
  -     } else if (localName.equals(OUTPUT_ACTION)) {
  -         node = new Node.JspOutput(qName, nonTaglibAttrs,
  -                                   nonTaglibXmlnsAttrs, taglibAttrs,
  -                                   start, current);
  -     } else if (localName.equals(TAG_DIRECTIVE_ACTION)) {
  -         if (!isTagFile) {
  -             throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.action.isnottagfile",
  -                                      localName),
  -                 locator);
  -         }
  -         node = new Node.TagDirective(qName, nonTaglibAttrs,
  -                                      nonTaglibXmlnsAttrs, taglibAttrs,
  -                                      start, current);
  -         String imports = nonTaglibAttrs.getValue("import");
  -         // There can only be one 'import' attribute per tag directive
  -         if (imports != null) {
  -             ((Node.TagDirective) node).addImport(imports);
  -         }
  -     } else if (localName.equals(ATTRIBUTE_DIRECTIVE_ACTION)) {
  -         if (!isTagFile) {
  -             throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.action.isnottagfile",
  -                                      localName),
  -                 locator);
  -         }
  -         node = new Node.AttributeDirective(qName, nonTaglibAttrs,
  -                                            nonTaglibXmlnsAttrs,
  -                                            taglibAttrs, start, current);
  -     } else if (localName.equals(VARIABLE_DIRECTIVE_ACTION)) {
  -         if (!isTagFile) {
  -             throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.action.isnottagfile",
  -                                      localName),
  -                 locator);
  -         }
  -         node = new Node.VariableDirective(qName, nonTaglibAttrs,
  -                                           nonTaglibXmlnsAttrs,
  -                                           taglibAttrs, start, current);
  -     } else if (localName.equals(INVOKE_ACTION)) {
  -         if (!isTagFile) {
  -             throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.action.isnottagfile",
  -                                      localName),
  -                 locator);
  -         }
  -         node = new Node.InvokeAction(qName, nonTaglibAttrs,
  -                                      nonTaglibXmlnsAttrs, taglibAttrs,
  -                                      start, current);
  -     } else if (localName.equals(DOBODY_ACTION)) {
  -         if (!isTagFile) {
  -             throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.action.isnottagfile",
  -                                      localName),
  -                 locator);
  -         }
  -         node = new Node.DoBodyAction(qName, nonTaglibAttrs,
  -                                      nonTaglibXmlnsAttrs, taglibAttrs,
  -                                      start, current);
  -     } else if (localName.equals(ELEMENT_ACTION)) {
  -         node = new Node.JspElement(qName, nonTaglibAttrs,
  -                                    nonTaglibXmlnsAttrs, taglibAttrs,
  -                                    start, current);
  -     } else if (localName.equals(FALLBACK_ACTION)) {
  -         node = new Node.FallBackAction(qName, nonTaglibXmlnsAttrs,
  -                                        taglibAttrs, start, current);
  -     } else {
  -         throw new SAXParseException(
  -                 Localizer.getMessage("jsp.error.xml.badStandardAction",
  -                                      localName),
  -                 locator);
  -     }
  +            node =
  +                new Node.JspRoot(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +            if (isTop) {
  +                pageInfo.setHasJspRoot(true);
  +            }
  +        } else if (localName.equals(PAGE_DIRECTIVE_ACTION)) {
  +            if (isTagFile) {
  +                throw new SAXParseException(
  +                    Localizer.getMessage(
  +                        "jsp.error.action.istagfile",
  +                        localName),
  +                    locator);
  +            }
  +            node =
  +                new Node.PageDirective(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +            String imports = nonTaglibAttrs.getValue("import");
  +            // There can only be one 'import' attribute per page directive
  +            if (imports != null) {
  +                ((Node.PageDirective)node).addImport(imports);
  +            }
  +        } else if (localName.equals(INCLUDE_DIRECTIVE_ACTION)) {
  +            node =
  +                new Node.IncludeDirective(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +            processIncludeDirective(nonTaglibAttrs.getValue("file"), node);
  +        } else if (localName.equals(DECLARATION_ACTION)) {
  +            node =
  +                new Node.Declaration(
  +                    qName,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(SCRIPTLET_ACTION)) {
  +            node =
  +                new Node.Scriptlet(
  +                    qName,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(EXPRESSION_ACTION)) {
  +            node =
  +                new Node.Expression(
  +                    qName,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(USE_BEAN_ACTION)) {
  +            node =
  +                new Node.UseBean(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(SET_PROPERTY_ACTION)) {
  +            node =
  +                new Node.SetProperty(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(GET_PROPERTY_ACTION)) {
  +            node =
  +                new Node.GetProperty(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(INCLUDE_ACTION)) {
  +            node =
  +                new Node.IncludeAction(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(FORWARD_ACTION)) {
  +            node =
  +                new Node.ForwardAction(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(PARAM_ACTION)) {
  +            node =
  +                new Node.ParamAction(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(PARAMS_ACTION)) {
  +            node =
  +                new Node.ParamsAction(
  +                    qName,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(PLUGIN_ACTION)) {
  +            node =
  +                new Node.PlugIn(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(TEXT_ACTION)) {
  +            node =
  +                new Node.JspText(
  +                    qName,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(BODY_ACTION)) {
  +            node =
  +                new Node.JspBody(
  +                    qName,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(ATTRIBUTE_ACTION)) {
  +            node =
  +                new Node.NamedAttribute(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(OUTPUT_ACTION)) {
  +            node =
  +                new Node.JspOutput(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(TAG_DIRECTIVE_ACTION)) {
  +            if (!isTagFile) {
  +                throw new SAXParseException(
  +                    Localizer.getMessage(
  +                        "jsp.error.action.isnottagfile",
  +                        localName),
  +                    locator);
  +            }
  +            node =
  +                new Node.TagDirective(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +            String imports = nonTaglibAttrs.getValue("import");
  +            // There can only be one 'import' attribute per tag directive
  +            if (imports != null) {
  +                ((Node.TagDirective)node).addImport(imports);
  +            }
  +        } else if (localName.equals(ATTRIBUTE_DIRECTIVE_ACTION)) {
  +            if (!isTagFile) {
  +                throw new SAXParseException(
  +                    Localizer.getMessage(
  +                        "jsp.error.action.isnottagfile",
  +                        localName),
  +                    locator);
  +            }
  +            node =
  +                new Node.AttributeDirective(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(VARIABLE_DIRECTIVE_ACTION)) {
  +            if (!isTagFile) {
  +                throw new SAXParseException(
  +                    Localizer.getMessage(
  +                        "jsp.error.action.isnottagfile",
  +                        localName),
  +                    locator);
  +            }
  +            node =
  +                new Node.VariableDirective(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(INVOKE_ACTION)) {
  +            if (!isTagFile) {
  +                throw new SAXParseException(
  +                    Localizer.getMessage(
  +                        "jsp.error.action.isnottagfile",
  +                        localName),
  +                    locator);
  +            }
  +            node =
  +                new Node.InvokeAction(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(DOBODY_ACTION)) {
  +            if (!isTagFile) {
  +                throw new SAXParseException(
  +                    Localizer.getMessage(
  +                        "jsp.error.action.isnottagfile",
  +                        localName),
  +                    locator);
  +            }
  +            node =
  +                new Node.DoBodyAction(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(ELEMENT_ACTION)) {
  +            node =
  +                new Node.JspElement(
  +                    qName,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else if (localName.equals(FALLBACK_ACTION)) {
  +            node =
  +                new Node.FallBackAction(
  +                    qName,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    current);
  +        } else {
  +            throw new SAXParseException(
  +                Localizer.getMessage(
  +                    "jsp.error.xml.badStandardAction",
  +                    localName),
  +                locator);
  +        }
   
  -     return node;
  +        return node;
       }
   
       /*
        * Checks if the XML element with the given tag name is a custom action,
        * and returns the corresponding Node object.
        */
  -    private Node parseCustomAction(String qName,
  -                                String localName,
  -                                String uri,
  -                                Attributes nonTaglibAttrs,
  -                                Attributes nonTaglibXmlnsAttrs,
  -                                Attributes taglibAttrs,
  -                                Mark start,
  -                                Node parent) throws SAXException {
  +    private Node parseCustomAction(
  +        String qName,
  +        String localName,
  +        String uri,
  +        Attributes nonTaglibAttrs,
  +        Attributes nonTaglibXmlnsAttrs,
  +        Attributes taglibAttrs,
  +        Mark start,
  +        Node parent)
  +        throws SAXException {
   
  -     // Check if this is a user-defined (custom) tag
  +        // Check if this is a user-defined (custom) tag
           TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
           if (tagLibInfo == null) {
               return null;
  -     }
  +        }
   
  -     TagInfo tagInfo = tagLibInfo.getTag(localName);
  +        TagInfo tagInfo = tagLibInfo.getTag(localName);
           TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName);
  -     if (tagInfo == null && tagFileInfo == null) {
  -         throw new SAXException(Localizer.getMessage("jsp.error.xml.bad_tag",
  -                                                     localName, uri));
  -     }
  -     Class tagHandlerClass = null;
  -     if (tagInfo != null) {
  -         String handlerClassName = tagInfo.getTagClassName();
  -         try {
  -             tagHandlerClass = ctxt.getClassLoader().loadClass(handlerClassName);
  -         } catch (Exception e) {
  -             throw new SAXException(
  -                     Localizer.getMessage("jsp.error.loadclass.taghandler",
  -                                          handlerClassName, qName));
  -         }
  -     }
  -
  -     String prefix = "";
  -     int colon = qName.indexOf(':');
  -     if (colon != -1) {
  -         prefix = qName.substring(0, colon);
  -     }
  -       
  -     Node.CustomTag ret = null;
  -     if (tagInfo != null) {
  -         ret = new Node.CustomTag(qName, prefix, localName, uri,
  -                                  nonTaglibAttrs, nonTaglibXmlnsAttrs,
  -                                  taglibAttrs, start, parent, tagInfo,
  -                                  tagHandlerClass);
  -     } else {
  -         ret = new Node.CustomTag(qName, prefix, localName, uri,
  -                                  nonTaglibAttrs, nonTaglibXmlnsAttrs,
  -                                  taglibAttrs, start, parent, tagFileInfo);
  -     }
  +        if (tagInfo == null && tagFileInfo == null) {
  +            throw new SAXException(
  +                Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri));
  +        }
  +        Class tagHandlerClass = null;
  +        if (tagInfo != null) {
  +            String handlerClassName = tagInfo.getTagClassName();
  +            try {
  +                tagHandlerClass =
  +                    ctxt.getClassLoader().loadClass(handlerClassName);
  +            } catch (Exception e) {
  +                throw new SAXException(
  +                    Localizer.getMessage(
  +                        "jsp.error.loadclass.taghandler",
  +                        handlerClassName,
  +                        qName));
  +            }
  +        }
  +
  +        String prefix = "";
  +        int colon = qName.indexOf(':');
  +        if (colon != -1) {
  +            prefix = qName.substring(0, colon);
  +        }
  +
  +        Node.CustomTag ret = null;
  +        if (tagInfo != null) {
  +            ret =
  +                new Node.CustomTag(
  +                    qName,
  +                    prefix,
  +                    localName,
  +                    uri,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    parent,
  +                    tagInfo,
  +                    tagHandlerClass);
  +        } else {
  +            ret =
  +                new Node.CustomTag(
  +                    qName,
  +                    prefix,
  +                    localName,
  +                    uri,
  +                    nonTaglibAttrs,
  +                    nonTaglibXmlnsAttrs,
  +                    taglibAttrs,
  +                    start,
  +                    parent,
  +                    tagFileInfo);
  +        }
   
  -     return ret;
  +        return ret;
       }
   
       /*
  @@ -837,39 +1049,50 @@
        * @return The tag library associated with the given uri namespace
        */
       private TagLibraryInfo getTaglibInfo(String prefix, String uri)
  -                throws JasperException {
  +        throws JasperException {
   
  -     TagLibraryInfo result = null;
  +        TagLibraryInfo result = null;
   
  -     if (uri.startsWith(URN_JSPTAGDIR)) {
  -         // uri (of the form "urn:jsptagdir:path") references tag file dir
  -         String tagdir = uri.substring(URN_JSPTAGDIR.length());
  -         result = new ImplicitTagLibraryInfo(ctxt, parserController, prefix,
  -                                             tagdir, err);
  -     } else {
  -         // uri references TLD file
  -         boolean isPlainUri = false;
  -         if (uri.startsWith(URN_JSPTLD)) {
  -             // uri is of the form "urn:jsptld:path"
  -             uri = uri.substring(URN_JSPTLD.length());
  -         } else {
  -             isPlainUri = true;
  -         }
  -
  -         String[] location = ctxt.getTldLocation(uri);
  -         if (location != null || !isPlainUri) {
  -             /*
  -              * If the uri value is a plain uri, a translation error must
  -              * not be generated if the uri is not found in the taglib map.
  -              * Instead, any actions in the namespace defined by the uri
  -              * value must be treated as uninterpreted.
  -              */
  -             result = new TagLibraryInfoImpl(ctxt, parserController, prefix,
  -                                             uri, location, err);
  -         }
  -     }
  +        if (uri.startsWith(URN_JSPTAGDIR)) {
  +            // uri (of the form "urn:jsptagdir:path") references tag file dir
  +            String tagdir = uri.substring(URN_JSPTAGDIR.length());
  +            result =
  +                new ImplicitTagLibraryInfo(
  +                    ctxt,
  +                    parserController,
  +                    prefix,
  +                    tagdir,
  +                    err);
  +        } else {
  +            // uri references TLD file
  +            boolean isPlainUri = false;
  +            if (uri.startsWith(URN_JSPTLD)) {
  +                // uri is of the form "urn:jsptld:path"
  +                uri = uri.substring(URN_JSPTLD.length());
  +            } else {
  +                isPlainUri = true;
  +            }
   
  -     return result;
  +            String[] location = ctxt.getTldLocation(uri);
  +            if (location != null || !isPlainUri) {
  +                /*
  +                 * If the uri value is a plain uri, a translation error must
  +                 * not be generated if the uri is not found in the taglib map.
  +                 * Instead, any actions in the namespace defined by the uri
  +                 * value must be treated as uninterpreted.
  +                 */
  +                result =
  +                    new TagLibraryInfoImpl(
  +                        ctxt,
  +                        parserController,
  +                        prefix,
  +                        uri,
  +                        location,
  +                        err);
  +            }
  +        }
  +
  +        return result;
       }
   
       /*
  @@ -881,25 +1104,26 @@
        * scripting element has been reached.
        */
       private void checkScriptingBody(Node.ScriptingElement scriptingElem)
  -                         throws SAXException {
  -     Node.Nodes body = scriptingElem.getBody();
  -     if (body != null) {
  -         int size = body.size();
  -         for (int i=0; i<size; i++) {
  -             Node n = body.getNode(i);
  -             if (!(n instanceof Node.TemplateText)) {
  -                 String elemType = SCRIPTLET_ACTION;
  -                 if (scriptingElem instanceof Node.Declaration)
  -                     elemType = DECLARATION_ACTION;
  -                 if (scriptingElem instanceof Node.Expression)
  -                     elemType = EXPRESSION_ACTION;
  -                 String msg = Localizer.getMessage(
  -                        "jsp.error.parse.xml.scripting.invalid.body",
  -                     elemType);
  -                 throw new SAXException(msg);
  -             }
  -         }
  -     }
  +        throws SAXException {
  +        Node.Nodes body = scriptingElem.getBody();
  +        if (body != null) {
  +            int size = body.size();
  +            for (int i = 0; i < size; i++) {
  +                Node n = body.getNode(i);
  +                if (!(n instanceof Node.TemplateText)) {
  +                    String elemType = SCRIPTLET_ACTION;
  +                    if (scriptingElem instanceof Node.Declaration)
  +                        elemType = DECLARATION_ACTION;
  +                    if (scriptingElem instanceof Node.Expression)
  +                        elemType = EXPRESSION_ACTION;
  +                    String msg =
  +                        Localizer.getMessage(
  +                            "jsp.error.parse.xml.scripting.invalid.body",
  +                            elemType);
  +                    throw new SAXException(msg);
  +                }
  +            }
  +        }
       }
   
       /*
  @@ -909,22 +1133,23 @@
        * 'file' attribute of the include directive
        * @param parent The Node representing the include directive
        */
  -    private void processIncludeDirective(String fname, Node parent) 
  -             throws SAXException {
  +    private void processIncludeDirective(String fname, Node parent)
  +        throws SAXException {
   
  -     if (fname == null) {
  -         return;
  -     }
  -
  -     try {
  -         parserController.parse(fname, parent, null);
  -     } catch (FileNotFoundException fnfe) {
  -         throw new SAXParseException(
  -                    Localizer.getMessage("jsp.error.file.not.found", fname),
  -                 locator, fnfe);
  -     } catch (Exception e) {
  -         throw new SAXException(e);
  -     }
  +        if (fname == null) {
  +            return;
  +        }
  +
  +        try {
  +            parserController.parse(fname, parent, null);
  +        } catch (FileNotFoundException fnfe) {
  +            throw new SAXParseException(
  +                Localizer.getMessage("jsp.error.file.not.found", fname),
  +                locator,
  +                fnfe);
  +        } catch (Exception e) {
  +            throw new SAXException(e);
  +        }
       }
   
       /*
  @@ -937,13 +1162,13 @@
        * @param attrs The element's attributes
        */
       private void checkPrefixes(String uri, String qName, Attributes attrs) {
  -     
  -     checkPrefix(uri, qName);
   
  -     int len = attrs.getLength();
  -     for (int i=0; i<len; i++) {
  -         checkPrefix(attrs.getURI(i), attrs.getQName(i));
  -     }
  +        checkPrefix(uri, qName);
  +
  +        int len = attrs.getLength();
  +        for (int i = 0; i < len; i++) {
  +            checkPrefix(attrs.getURI(i), attrs.getQName(i));
  +        }
       }
   
       /*
  @@ -956,14 +1181,14 @@
        */
       private void checkPrefix(String uri, String qName) {
   
  -     int index = qName.indexOf(':');
  -     if (index != -1) {
  -         String prefix = qName.substring(0, index);
  -         pageInfo.addPrefix(prefix);
  -         if ("jsp".equals(prefix) && !JSP_URI.equals(uri)) {
  -             pageInfo.setIsJspPrefixHijacked(true);
  -         }
  -     }
  +        int index = qName.indexOf(':');
  +        if (index != -1) {
  +            String prefix = qName.substring(0, index);
  +            pageInfo.addPrefix(prefix);
  +            if ("jsp".equals(prefix) && !JSP_URI.equals(uri)) {
  +                pageInfo.setIsJspPrefixHijacked(true);
  +            }
  +        }
       }
   
       /*
  @@ -975,18 +1200,21 @@
        *
        * @return The SAXParser
        */
  -    private static SAXParser getSAXParser(boolean validating,
  -                                          JspDocumentParser jspDocParser)
  -            throws Exception {
  -          
  +    private static SAXParser getSAXParser(
  +        boolean validating,
  +        JspDocumentParser jspDocParser)
  +        throws Exception {
  +
           SAXParserFactory factory = SAXParserFactory.newInstance();
           factory.setNamespaceAware(true);
   
           // Preserve xmlns attributes
  -        factory.setFeature("http://xml.org/sax/features/namespace-prefixes";,
  -                           true);
  -        factory.setFeature("http://xml.org/sax/features/validation";,
  -                           validating);
  +        factory.setFeature(
  +            "http://xml.org/sax/features/namespace-prefixes";,
  +            true);
  +        factory.setFeature(
  +            "http://xml.org/sax/features/validation";,
  +            validating);
   
           // Configure the parser
           SAXParser saxParser = factory.newSAXParser();
  @@ -1009,24 +1237,26 @@
        *
        * @return An InputSource to the requested JSP document or tag file
        */
  -    private InputSource getInputSource(String path,
  -                                       JarFile jarFile,
  -                                       JspCompilationContext ctxt,
  -                                       ErrorDispatcher err)
  -            throws Exception {
  +    private InputSource getInputSource(
  +        String path,
  +        JarFile jarFile,
  +        JspCompilationContext ctxt,
  +        ErrorDispatcher err)
  +        throws Exception {
   
  -     return new InputSource(JspUtil.getInputStream(path, jarFile, ctxt,
  -                                                   err));
  +        return new InputSource(
  +            JspUtil.getInputStream(path, jarFile, ctxt, err));
       }
   
       /*
        * Exception indicating that a DOCTYPE declaration is present, but
        * validation is turned off.
        */
  -    private static class EnableDTDValidationException extends SAXParseException {
  +    private static class EnableDTDValidationException
  +        extends SAXParseException {
   
           EnableDTDValidationException(String message, Locator loc) {
               super(message, loc);
           }
  -    }  
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to