Bug 35252 - jasper2 produced malformed expanded XML view
Summary: jasper2 produced malformed expanded XML view
Status: RESOLVED DUPLICATE of bug 39557
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.5.12
Hardware: All All
: P2 normal with 2 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-07 07:36 UTC by Rahul
Modified: 2006-10-01 20:46 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rahul 2005-06-07 07:36:43 UTC
The FirstPassVisitor in org.apache.jasper.compiler.PageDataImpl adds all 
attributes (except "version") of jsp:root elements of included JSPs to 
jsp:root of expanded XML view. The expanded XML view is thus, often malformed.

Any entity, such as a TagLibraryValidator, that tries to subsequently parse 
the malformed expanded XML view, fails. For example:

main.jspx (using Jakarta Taglibs "standard" JSTL impl):
--------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" 
 xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0" >
    <jsp:directive.include file="one.jspx"/>
</jsp:root>

where one.jspx is:
----------------------
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" />

gives:
<top-of-stack-trace>
org.apache.jasper.JasperException: <h3>Validation error messages from 
TagLibraryValidator for c</h3><p>null: org.xml.sax.SAXParseException: 
Attribute "jsp" bound to namespace "http://www.w3.org/2000/xmlns/" was already 
specified for element "jsp:root".</p>
</top-of-stack-trace>

as, in this scenario, attribute xmlns:jsp gets added twice.

[Problem reported by "Dino Klein" <zagzag@speakeasy.net> on taglibs-dev@j.a.o]

I'm proposing a patch that causes FirstPassVisitor to only add those 
attributes to the jsp:root of the expanded XML view that have not been already 
added.

Index: PageDataImpl.java
===================================================================
RCS file: /usr/local/cvsroot/apache/jakarta-tomcat-5.0.28-src/jakarta-tomcat-
jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
retrieving revision 1.1
diff -c -r1.1 PageDataImpl.java
*** PageDataImpl.java	7 Jun 2005 02:29:52 -0000	1.1
--- PageDataImpl.java	7 Jun 2005 02:33:19 -0000
***************
*** 205,218 ****
  	    if (attrs != null) {
  		int len = attrs.getLength();
  		for (int i=0; i<len; i++) {
! 		    if ("version".equals(attrs.getQName(i))) {
  			continue;
  		    }
! 		    rootAttrs.addAttribute(attrs.getURI(i),
  					   attrs.getLocalName(i),
! 					   attrs.getQName(i),
  					   attrs.getType(i),
  					   attrs.getValue(i));
  		}
  	    }
  	}
--- 205,221 ----
  	    if (attrs != null) {
  		int len = attrs.getLength();
  		for (int i=0; i<len; i++) {
! 		    String qName = attrs.getQName(i);
! 		    if ("version".equals(qName)) {
  			continue;
  		    }
! 		    if (rootAttrs.getIndex(qName) == -1) {
! 		    	rootAttrs.addAttribute(attrs.getURI(i),
  					   attrs.getLocalName(i),
! 					   qName,
  					   attrs.getType(i),
  					   attrs.getValue(i));
+ 		    }
  		}
  	    }
  	}
Comment 1 Dino 2005-10-16 06:58:55 UTC
This is still a problem with 5.5.12.
Perhaps the version in this bug should be changed in order to reflect that.
Comment 2 Yoav Shapira 2005-10-16 07:04:07 UTC
Updated versions (which by the way anyone can do), will fix right now.
Comment 3 Yoav Shapira 2005-10-16 07:20:42 UTC
Fixed.
Comment 4 n nemer 2006-01-27 21:49:34 UTC
is this really fixed?  i have tomcat 5.5.15 and get the exact same error:  
org.apache.jasper.JasperException: Error on line 1 of document  : Attribute
"star" bound to namespace "http://www.w3.org/2000/xmlns/" was already specified
for element "star:content-block". Nested exception: Attribute "star" bound to
namespace "http://www.w3.org/2000/xmlns/" was already specified for element
"star:content-block".

thanks.
nn
Comment 5 Fabio Grassi 2006-04-27 14:21:16 UTC
It looks fixed in 5.5.16. Is it really? Should the bug be closed?
Fabio.
Comment 6 Mark Thomas 2006-10-01 20:46:00 UTC
The duplicate has more info on how to reproduce.

*** This bug has been marked as a duplicate of 39557 ***