luehe       2002/10/28 15:21:08

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        JspDocumentParser.java ParserController.java
                        TagConstants.java
  Log:
  Added support for tag files in XML syntax
  
  Revision  Changes    Path
  1.22      +34 -21    
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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JspDocumentParser.java    28 Oct 2002 19:25:47 -0000      1.21
  +++ JspDocumentParser.java    28 Oct 2002 23:21:08 -0000      1.22
  @@ -113,6 +113,7 @@
   
       private ErrorDispatcher err;
       private boolean isTagFile;
  +    private boolean directivesOnly;
   
       /*
        * Constructor
  @@ -120,7 +121,8 @@
       public JspDocumentParser(ParserController pc,
                             String path,
                             InputStreamReader reader,
  -                          boolean isTagFile) {
  +                          boolean isTagFile,
  +                          boolean directivesOnly) {
        this.parserController = pc;
        this.ctxt = pc.getJspCompilationContext();
        this.pageInfo = pc.getCompiler().getPageInfo();
  @@ -129,6 +131,7 @@
        this.path = path;
        this.inputSource = new InputSource(reader);
        this.isTagFile = isTagFile;
  +     this.directivesOnly = directivesOnly;
       }
   
       /*
  @@ -140,10 +143,13 @@
                                   String path,
                                   InputStreamReader reader,
                                   Node parent,
  -                                boolean isTagFile) throws JasperException {
  +                                boolean isTagFile,
  +                                boolean directivesOnly)
  +             throws JasperException {
   
        JspDocumentParser handler = new JspDocumentParser(pc, path, reader,
  -                                                       isTagFile);
  +                                                       isTagFile,
  +                                                       directivesOnly);
        Node.Nodes pageNodes = null;
        Node.JspRoot jspRoot = null;
   
  @@ -196,24 +202,28 @@
                             String qName,
                             Attributes attrs) throws SAXException {
   
  +     if (directivesOnly && !qName.startsWith(JSP_DIRECTIVE)) {
  +         return;
  +     }
  +
        Mark start = new Mark(path, locator.getLineNumber(),
                              locator.getColumnNumber());
  -     Attributes attrsCopy;
  +     Attributes attrsCopy = null;
   
        Node node = null;
   
  -        // XXX - As of JSP 2.0, xmlns: can appear in any node (not just
  -        // <jsp:root>).  The spec still needs clarification here.
  -        // What we implement is that it can appear in any node and
  -        // is valid from that point forward.  Redefinitions cause an
  -        // error.  This isn't quite consistent with how xmlns: normally
  -        // works.
  -        try {
  -            attrsCopy = addCustomTagLibraries(attrs);
  -        } catch (JasperException je) {
  -            throw new SAXParseException( err.getString(
  +     // XXX - As of JSP 2.0, xmlns: can appear in any node (not just
  +     // <jsp:root>).  The spec still needs clarification here.
  +     // What we implement is that it can appear in any node and
  +     // is valid from that point forward.  Redefinitions cause an
  +     // error.  This isn't quite consistent with how xmlns: normally
  +     // works.
  +     try {
  +         attrsCopy = addCustomTagLibraries(attrs);
  +     } catch (JasperException je) {
  +         throw new SAXParseException( err.getString(
                   "jsp.error.could.not.add.taglibraries" ), locator, je );
  -        }
  +     }
   
        if (qName.equals(JSP_ROOT)) {
               // give the <jsp:root> element the original attributes set
  @@ -352,6 +362,11 @@
       public void endElement(String uri,
                           String localName,
                           String qName) throws SAXException {
  +
  +     if (directivesOnly && !qName.startsWith(JSP_DIRECTIVE)) {
  +         return;
  +     }
  +
        if (current instanceof Node.NamedAttribute
                && ((Node.NamedAttribute) current).isTrim()) {
            // Ignore any whitespace (including spaces, carriage returns,
  @@ -366,9 +381,7 @@
            if (lastNode instanceof Node.TemplateText) {
                ((Node.TemplateText) lastNode).rtrim();
            }
  -     }
  -
  -     if (current instanceof Node.ScriptingElement) {
  +     } else if (current instanceof Node.ScriptingElement) {
            checkScriptingBody((Node.ScriptingElement) current);
        }
   
  
  
  
  1.23      +2 -1      
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java
  
  Index: ParserController.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ParserController.java     21 Oct 2002 20:13:32 -0000      1.22
  +++ ParserController.java     28 Oct 2002 23:21:08 -0000      1.23
  @@ -218,7 +218,8 @@
               if (isXml) {
                   parsedPage = JspDocumentParser.parse(this, absFileName,
                                                     reader, parent,
  -                                                  isTagFile);
  +                                                  isTagFile,
  +                                                  directivesOnly);
               } else {
                JspReader r = new JspReader(ctxt, absFileName, encoding,
                                            reader, err);
  
  
  
  1.6       +5 -3      
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java
  
  Index: TagConstants.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagConstants.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TagConstants.java 22 Aug 2002 21:31:28 -0000      1.5
  +++ TagConstants.java 28 Oct 2002 23:21:08 -0000      1.6
  @@ -61,6 +61,8 @@
   package org.apache.jasper.compiler;
   
   public interface TagConstants {
  +
  +    public static final String JSP_DIRECTIVE = "jsp:directive.";
       public static final String JSP_ROOT = "jsp:root";
       public static final String JSP_ROOT_END = "</jsp:root>";
       public static final String JSP_PAGE_DIRECTIVE = "jsp:directive.page";
  
  
  

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

Reply via email to