You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2002/08/23 18:35:07 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java

kinman      2002/08/23 09:35:07

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        JspDocumentParser.java
  Log:
  - Submitted by Mark Roth
  
      - Now accepts "xmlns:" in root node of any JSP File configured with
        is-xml="true".  PFD spec says it should also accept "xmlns:" on
        any subelement and it should be scoped to that subelement.
        There are a nubmer of spec issues that need to be further analyzed
        before implementing this.
  
  Revision  Changes    Path
  1.15      +35 -17    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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JspDocumentParser.java	22 Aug 2002 23:41:37 -0000	1.14
  +++ JspDocumentParser.java	23 Aug 2002 16:35:07 -0000	1.15
  @@ -175,27 +175,39 @@
   
   	Mark start = new Mark(path, locator.getLineNumber(),
   			      locator.getColumnNumber());
  -	Attributes attrsCopy = new AttributesImpl(attrs);
  +	Attributes attrsCopy;
   
   	Node node = null;
   
   	if (!qName.equals(JSP_ROOT) && !rootSeen) {
   	    // create dummy <jsp:root> element
  -	    rootSeen = true;
   	    AttributesImpl rootAttrs = new AttributesImpl();
   	    rootAttrs.addAttribute("", "", "version", "CDATA", "2.0");
   	    node = new Node.JspRoot(rootAttrs, null, current, true);
   	    current = node;
   	}
   
  -	if (qName.equals(JSP_ROOT)) {
  +	if (!rootSeen) {
   	    rootSeen = true;
  -	    node = new Node.JspRoot(attrsCopy, start, current, false);
  -	    try {
  -		addCustomTagLibraries(attrsCopy);
  -	    } catch (JasperException je) {
  -		throw new SAXException(je);
  -	    }
  +            // XXX - As of JSP 2.0, xmlns: can appear on the top node (either
  +            // <jsp:root> or another top node.  The spec needs clarification 
  +            // here.
  +            try {
  +                attrsCopy = addCustomTagLibraries(attrs);
  +            } catch (JasperException je) {
  +                throw new SAXException(je);
  +            }
  +        }
  +        else {
  +            attrsCopy = new AttributesImpl(attrs);
  +        }
  +
  +	if (qName.equals(JSP_ROOT)) {
  +            // give the <jsp:root> element the original attributes set
  +            // (attrs) instead of the copy without the xmlns: elements 
  +            // (attrsCopy)
  +	    node = new Node.JspRoot(new AttributesImpl( attrs ), start, 
  +                current, false);
   	} else if (qName.equals(JSP_PAGE_DIRECTIVE)) {
   	    if (isTagFile) {
   		throw new SAXParseException(
  @@ -497,14 +509,18 @@
       /*
        * Parses the xmlns:prefix attributes from the jsp:root element and adds 
        * the corresponding TagLibraryInfo objects to the set of custom tag
  -     * libraries.
  +     * libraries.  In the process, returns a new Attributes object that does
  +     * not contain any of the xmlns: attributes.
        */
  -    private void addCustomTagLibraries(Attributes attrs)
  -	        throws JasperException {
  +    private Attributes addCustomTagLibraries(Attributes attrs)
  +	        throws JasperException 
  +    {
  +        AttributesImpl result = new AttributesImpl( attrs );
           int len = attrs.getLength();
  -        for (int i=0; i<len; i++) {
  +        for (int i=len-1; i>=0; i--) {
   	    String qName = attrs.getQName(i);
  -	    if (!qName.startsWith(XMLNS_JSP)
  +	    if (qName.startsWith( XMLNS ) 
  +                        && !qName.startsWith(XMLNS_JSP)
   		        && !qName.startsWith(JSP_VERSION)) {
   
   		// get the prefix
  @@ -533,8 +549,10 @@
   						uri, location, err);
                   }
   		taglibs.put(prefix, tl);
  +                result.removeAttribute( i );
   	    }
           }
  +        return result;
       }
   
       /*
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>