pierred     00/12/05 03:05:30

  Modified:    jasper/src/share/org/apache/jasper/compiler
                        DelegatingListener.java JspParseEventListener.java
                        ParseEventListener.java ParserXJspSax.java
                        ParserXJspSaxHandler.java
  Log:
  Changes from JSP1.2 PD1 to JSP1.2 PFD that were not explicitely flagged
  in the PFD changes section:
  - Template text not accepted anymore if it is not encapsultated within
    the <jsp:cdata> element
  - Tag Libraries used by a JSP document in XML syntax are defined via
    the <jsp:root> xmlns attributes (no jsp:directive.taglib anymore)
  
  Revision  Changes    Path
  1.6       +12 -8     
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/DelegatingListener.java
  
  Index: DelegatingListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/DelegatingListener.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DelegatingListener.java   2000/11/30 21:47:48     1.5
  +++ DelegatingListener.java   2000/12/05 11:05:19     1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/DelegatingListener.java,v
 1.5 2000/11/30 21:47:48 pierred Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/11/30 21:47:48 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/DelegatingListener.java,v
 1.6 2000/12/05 11:05:19 pierred Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/12/05 11:05:19 $
    *
    * ====================================================================
    * 
  @@ -227,13 +227,17 @@
           return delegate.getTagLibraries();
       }
   
  -    public void handleRootBegin(Attributes attrs) {}
  +    public void handleRootBegin(Attributes attrs) throws JasperException {}
       public void handleRootEnd() {}
   
  -    public void handleUninterpretedTagBegin(Mark start,Mark stop,String 
rawName,Attributes attrs) throws JasperException {}
  -
  +    public void handleUninterpretedTagBegin(Mark start, Mark stop,
  +                                            String rawName,Attributes attrs) 
  +        throws JasperException {}
       public void handleUninterpretedTagEnd(Mark start, Mark stop,
  -                                       String rawName)
  -     throws JasperException {}
  +                                          String rawName, char[] data)
  +        throws JasperException {}
  +
  +    public void handleJspCdata(Mark start, Mark stop, char[] data)
  +        throws JasperException {}
   }
   
  
  
  
  1.14      +40 -20    
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java
  
  Index: JspParseEventListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JspParseEventListener.java        2000/11/30 21:47:54     1.13
  +++ JspParseEventListener.java        2000/12/05 11:05:19     1.14
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
 1.13 2000/11/30 21:47:54 pierred Exp $
  - * $Revision: 1.13 $
  - * $Date: 2000/11/30 21:47:54 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspParseEventListener.java,v
 1.14 2000/12/05 11:05:19 pierred Exp $
  + * $Revision: 1.14 $
  + * $Date: 2000/12/05 11:05:19 $
    *
    * ====================================================================
    *
  @@ -742,21 +742,6 @@
               throw new CompileException(start, Constants.getString(
                                        "jsp.error.page.bad_b_and_a_combo"));
   
  -     if (directive.equals("taglib")) {
  -            String uri = attrs.getValue("uri");
  -            String prefix = attrs.getValue("prefix");
  -         TagLibraryInfo tl = null;
  -
  -         String[] location = 
  -             ctxt.getTldLocation(uri);
  -         if (location == null) {
  -             tl = new TagLibraryInfoImpl(ctxt, prefix, uri);
  -         } else {
  -             tl = new TagLibraryInfoImpl(ctxt, prefix, uri, location);
  -         }
  -         libraries.addTagLibrary(prefix, tl);
  -     }
  -
        if (directive.equals("include")) {
            String file = attrs.getValue("file");
            String encoding = attrs.getValue("encoding");
  @@ -1046,7 +1031,33 @@
        xo.append("jsp:root");
       }
       
  -    public void handleRootBegin(Attributes attrs) {
  +    public void handleRootBegin(Attributes attrs) 
  +     throws JasperException 
  +    {
  +        int attrsLength = attrs.getLength();
  +        for (int i = 0; i < attrsLength; i++) {
  +         String qName = attrs.getQName(i);
  +         if (qName.startsWith("xmlns:")) {
  +             String prefix = qName.substring(6);
  +             if (!prefix.equals("jsp")) {
  +                 String uri = attrs.getValue(i);
  +                 System.out.println("prefix: " + prefix);
  +                 System.out.println("uri: " + uri);
  +                 if (uri.startsWith("urn:jsptld:")) {
  +                     uri = uri.substring(11);
  +                 }
  +                 TagLibraryInfo tl = null;
  +                 String[] location = 
  +                     ctxt.getTldLocation(uri);
  +                 if (location == null) {
  +                     tl = new TagLibraryInfoImpl(ctxt, prefix, uri);
  +                 } else {
  +                     tl = new TagLibraryInfoImpl(ctxt, prefix, uri, location);
  +                 }
  +                 libraries.addTagLibrary(prefix, tl);
  +             }
  +         }
  +        }
           xo.addRootAttrs(attrs);
       }
       
  @@ -1062,14 +1073,23 @@
       }
   
       public void handleUninterpretedTagEnd(Mark start, Mark stop,
  -                                       String rawName)
  +                                       String rawName, char[] data)
        throws JasperException
       {
  +     if (data != null) {
  +         handleCharData(start, stop, data);
  +     }
           UninterpretedTagEndGenerator gen = 
            new UninterpretedTagEndGenerator(rawName);
           Generator genWrapper = new GeneratorWrapper(gen, start, stop);
        addGenerator(genWrapper);
           xo.append(rawName);
  +    }
  +
  +    public void handleJspCdata(Mark start, Mark stop, char[] data)
  +     throws JasperException
  +    {
  +     handleCharData(start, stop, data);
       }
   
       /**
  
  
  
  1.6       +46 -32    
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParseEventListener.java
  
  Index: ParseEventListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParseEventListener.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ParseEventListener.java   2000/11/30 21:47:56     1.5
  +++ ParseEventListener.java   2000/12/05 11:05:20     1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParseEventListener.java,v
 1.5 2000/11/30 21:47:56 pierred Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/11/30 21:47:56 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParseEventListener.java,v
 1.6 2000/12/05 11:05:20 pierred Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/12/05 11:05:20 $
    *
    * ====================================================================
    * 
  @@ -92,25 +92,36 @@
   
       void handleComment(Mark start, Mark stop, char[] text) throws JasperException;
       void handleDirective(String directive, 
  -                      Mark start, Mark stop, 
  -                      Attributes attrs) throws JasperException;
  -    void handleDeclaration(Mark start, Mark stop, Attributes attrs, char[] text) 
throws JasperException;
  -    void handleScriptlet(Mark start, Mark stop, Attributes attrs, char[] text) 
throws JasperException;
  -    void handleExpression(Mark start, Mark stop, Attributes attrs, char[] text) 
throws JasperException;
  +                         Mark start, Mark stop, 
  +                         Attributes attrs) 
  +        throws JasperException;
  +    void handleDeclaration(Mark start, Mark stop, Attributes attrs, char[] text) 
  +        throws JasperException;
  +    void handleScriptlet(Mark start, Mark stop, Attributes attrs, char[] text) 
  +        throws JasperException;
  +    void handleExpression(Mark start, Mark stop, Attributes attrs, char[] text)
  +        throws JasperException;
       void handleBean(Mark start, Mark stop, Attributes attrs) 
  -     throws JasperException;
  +        throws JasperException;
       void handleBean(Mark start, Mark stop, Attributes attrs, boolean isXml) 
  -     throws JasperException;
  +        throws JasperException;
       void handleBeanEnd (Mark start, Mark stop, Attributes attrs)
  -     throws JasperException;
  -    void handleGetProperty(Mark start, Mark stop, Attributes attrs) throws 
JasperException;
  -    void handleSetProperty(Mark start, Mark stop, Attributes attrs) throws 
JasperException;
  -    void handleSetProperty(Mark start, Mark stop, Attributes attrs, boolean isXml) 
throws JasperException;
  +        throws JasperException;
  +    void handleGetProperty(Mark start, Mark stop, Attributes attrs) 
  +        throws JasperException;
  +    void handleSetProperty(Mark start, Mark stop, Attributes attrs) 
  +        throws JasperException;
  +    void handleSetProperty(Mark start, Mark stop, Attributes attrs, 
  +                           boolean isXml) 
  +        throws JasperException;
       void handlePlugin(Mark start, Mark stop, Attributes attrs, Hashtable param, 
  -                     String fallback) throws JasperException;
  +                      String fallback) 
  +        throws JasperException;
       void handlePlugin(Mark start, Mark stop, Attributes attrs, Hashtable param, 
  -                     String fallback, boolean isXml) throws JasperException;
  -    void handleCharData(Mark start, Mark stop, char[] chars) throws JasperException;
  +                      String fallback, boolean isXml) 
  +        throws JasperException;
  +    void handleCharData(Mark start, Mark stop, char[] chars) 
  +        throws JasperException;
   
   
       /*
  @@ -124,35 +135,38 @@
        * stop: can be null if the body contained JSP tags... 
        */
       void handleTagBegin(Mark start, Mark stop, Attributes attrs, String prefix, 
String shortTagName,
  -                     TagLibraryInfo tli, TagInfo ti) 
  -     throws JasperException;
  +                        TagLibraryInfo tli, TagInfo ti) 
  +        throws JasperException;
       void handleTagBegin(Mark start, Mark stop, Attributes attrs, String prefix, 
String shortTagName,
  -                     TagLibraryInfo tli, TagInfo ti, boolean isXml) 
  -     throws JasperException;
  +                        TagLibraryInfo tli, TagInfo ti, boolean isXml) 
  +        throws JasperException;
   
       void handleTagEnd(Mark start, Mark stop, String prefix, String shortTagName,
  -                   Attributes attrs, TagLibraryInfo tli, TagInfo ti)
  -     throws JasperException;
  +                      Attributes attrs, TagLibraryInfo tli, TagInfo ti)
  +        throws JasperException;
   
       void handleForward(Mark start, Mark stop, Attributes attrs, Hashtable param)
  -     throws JasperException;
  +        throws JasperException;
       void handleForward(Mark start, Mark stop, Attributes attrs, Hashtable param, 
boolean isXml)
  -     throws JasperException;
  +        throws JasperException;
       void handleInclude(Mark start, Mark stop, Attributes attrs, Hashtable param)
  -     throws JasperException;
  +        throws JasperException;
       void handleInclude(Mark start, Mark stop, Attributes attrs, Hashtable param, 
boolean isXml)
  -     throws JasperException;
  +        throws JasperException;
   
       void endPageProcessing() throws JasperException;
   
  -    public void handleRootBegin(Attributes attrs);
  +    public void handleRootBegin(Attributes attrs) throws JasperException;
       public void handleRootEnd();
   
       public void handleUninterpretedTagBegin(Mark start, Mark stop,
  -                                         String rawName, Attributes attrs)
  -     throws JasperException;
  +                                            String rawName, Attributes attrs)
  +        throws JasperException;
       public void handleUninterpretedTagEnd(Mark start, Mark stop,
  -                                       String rawName)
  -     throws JasperException;
  +                                          String rawName, char[] data)
  +        throws JasperException;
  +
  +    public void handleJspCdata(Mark start, Mark stop, char[] data)
  +        throws JasperException;
   }
   
  
  
  
  1.3       +1 -3      
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParserXJspSax.java
  
  Index: ParserXJspSax.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParserXJspSax.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParserXJspSax.java        2000/10/12 23:34:13     1.2
  +++ ParserXJspSax.java        2000/12/05 11:05:21     1.3
  @@ -140,6 +140,7 @@
       // Parse
       
       public void parse() throws JasperException {
  +     //System.out.println("in ParserXJspSax");
           try {
            SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
            SAXParser saxParser = saxParserFactory.newSAXParser();
  @@ -195,9 +196,6 @@
           } catch (SAXException ex) {
            Exception ex2 = ex;
            if (ex.getException() != null) ex2 = ex.getException();
  -         System.out.println("**** ICI ***");
  -         System.out.println(ex2.getMessage());
  -         System.out.println(ex2.getClass().getName());
            throw new JasperException(ex2);
           }
       }
  
  
  
  1.5       +33 -38    
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParserXJspSaxHandler.java
  
  Index: ParserXJspSaxHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParserXJspSaxHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ParserXJspSaxHandler.java 2000/11/30 21:47:57     1.4
  +++ ParserXJspSaxHandler.java 2000/12/05 11:05:22     1.5
  @@ -77,7 +77,6 @@
    *
    * @@@ TODO
    * - make sure validation is in sync with Parser (jsp syntax)
  - * - fix the node.validate()
    */
   class ParserXJspSaxHandler 
       extends DefaultHandler implements LexicalHandler 
  @@ -169,30 +168,16 @@
       public void characters(char[] ch, int start, int length)
           throws SAXException
       {
  -     // @@@ have startMark computed from stopMark
  -     Mark stopMark = new Mark(filePath, locator.getLineNumber(),
  -                              locator.getColumnNumber());
  -
        //p("\n*** characters");
        //printLocation();
        //p("|" + String.valueOf(ch, start, length) + "|");
   
        Node node = (Node)stack.peek();
  -     if (node.isRoot() || node.isUninterpretedTag()) {
  -         // template data in <jsp:root>.
  -         //p("these chars are added directly in jsp:root");
  -         try {
  -             jspHandler.handleCharData(stopMark, stopMark,
  -                                       makeCharArray(ch, start, length)); 
  -         } catch (Exception ex) {
  -             throw new SAXException(ex);
  -         }
  -     } else {
  -         // characters added to the body content of the element
  -         // at the top of the stack
  -         //p("these chars are added to node " + node.rawName + " in stack");
  -         node.addText(ch, start, length);
  -     }
  +
  +     // characters added to the body content of the element
  +     // at the top of the stack
  +     //p("these chars are added to node " + node.rawName + " in stack");
  +     node.addText(ch, start, length);
       }
   
       public void ignorableWhitespace(char[] ch,
  @@ -294,7 +279,6 @@
        //p("namespaceURI: " + namespaceURI);
        //p("localName: " + localName);
        //p("rawName: " + rawName);
  -     //p("attrs: " + attrs.toString());
   
        Mark stop = new Mark(filePath, locator.getLineNumber(),
                             locator.getColumnNumber());
  @@ -305,19 +289,19 @@
   
        try {
            if (name.equals("jsp:root")) {
  +             node.validate(true, false);
                jspHandler.handleRootEnd();
  +         } else if (name.equals("jsp:cdata")) {
  +             node.validate(false, true);
  +             jspHandler.handleJspCdata(node.start, stop, node.getText());
            } else if (name.equals("jsp:directive.include")) {
                node.validate(true, false);
                jspHandler.handleDirective("include", node.start, stop, 
  -                        node.attrs);
  +                                        node.attrs);
            } else if (name.equals("jsp:directive.page")) {
                node.validate(true, false);
                jspHandler.handleDirective("page", node.start, stop, 
  -                        node.attrs);
  -         } else if (name.equals("jsp:directive.taglib")) {
  -             node.validate(true, false);
  -             jspHandler.handleDirective("taglib", node.start, stop,
  -                        node.attrs);
  +                                        node.attrs);
            } else if (name.equals("jsp:declaration")) {
                node.validate(false, true);
                jspHandler.handleDeclaration(
  @@ -346,7 +330,7 @@
                    params = popParams();
                    node = (Node)stack.pop();
                }
  -             node.validate(true, true); //@@@
  +             node.validate(true, false);
                jspHandler.handleInclude(node.start, stop, node.attrs, params, true);
            } else if (name.equals("jsp:forward")) {
                Hashtable params = null;
  @@ -356,16 +340,16 @@
                    params = popParams();
                    node = (Node)stack.pop();
                }
  -             node.validate(true, true);
  +             node.validate(true, false);
                jspHandler.handleForward(node.start, stop, node.attrs, params, true);
            } else if (name.equals("jsp:useBean")) {
  -             node.validate(true, true); // @@@
  +             node.validate(true, false);
                jspHandler.handleBeanEnd(node.start, stop, node.attrs);
            } else if (name.equals("jsp:getProperty")) {
  -             node.validate(true, true); // @@@
  +             node.validate(true, false);
                jspHandler.handleGetProperty(node.start, stop, node.attrs);
            } else if (name.equals("jsp:setProperty")) {
  -             node.validate(true, true); // @@@
  +             node.validate(true, false);
                jspHandler.handleSetProperty(node.start, stop, node.attrs, true);
            } else if (name.equals("jsp:plugin")) {
                //@@@ test jsp parser to see if fallback can come first?
  @@ -382,22 +366,27 @@
                    params = popParams();
                    node = (Node)stack.pop();
                }
  -             node.validate(true, true);
  +             node.validate(true, false);
                //p(node);
                jspHandler.handlePlugin(node.start, stop, node.attrs, params, 
                           fallback, true);
            } else {
                if (node.isUninterpretedTag()) {
                    // this is an 'uninterpreted' tag
  -                 jspHandler.handleUninterpretedTagEnd(stop, stop, rawName);
  +                 jspHandler.handleUninterpretedTagEnd(stop, stop, rawName,
  +                                                      node.getText());
                } else {
                    // this is a custom tag
  +                 node.validate(true, false);
                    processCustomTagEnd((NodeTag)node, stop);
                }
            }
        } catch (Exception ex) {
  -         ex.printStackTrace();
  -         throw new SAXException(ex);
  +         if (ex instanceof SAXException) {
  +             throw (SAXException)ex;
  +         } else {
  +             throw new SAXException(ex);
  +         }
        }
       }
   
  @@ -639,10 +628,16 @@
                                       rawName + " cannot have attributes.");
            }
            if (!canHaveText && text != null) {
  -             throw new SAXException("VALIDATE ERROR: " +
  -                                    rawName + " cannot have text.");
  +             String data = text.toString().trim();
  +             if (data.length() > 0) {
  +             throw new SAXException(
  +                 Constants.getString(
  +                     "jspx.error.templateDataNotInJspCdata",
  +                     new Object[]{rawName, JspUtil.escapeXml(data)}));
  +             }
            }
        }
  +
        public void display() {
            p("NODE: " + rawName);
            for (int i=0; i<attrs.getLength(); i++) {
  
  
  

Reply via email to