tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java Node.java PageDataImpl.java
Date Wed, 19 Feb 2003 23:39:16 GMT
luehe       2003/02/19 15:39:16

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        JspDocumentParser.java Node.java PageDataImpl.java
  Log:
  Preserve xmlns:prefix attributes in XML view.
  This also fixes 17204: jsp:element generates incorrect output when
  used in a JSP Document and the element includes an xmlns attribute
  
  Revision  Changes    Path
  1.39      +158 -113  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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- JspDocumentParser.java	13 Feb 2003 02:41:26 -0000	1.38
  +++ JspDocumentParser.java	19 Feb 2003 23:39:15 -0000	1.39
  @@ -169,7 +169,7 @@
   		// create dummy <jsp:root> element
   		AttributesImpl rootAttrs = new AttributesImpl();
   		rootAttrs.addAttribute("", "", "version", "CDATA", "2.0");
  -		jspRoot = new Node.JspRoot(rootAttrs, null, null);
  +		jspRoot = new Node.JspRoot(rootAttrs, null, null, null);
   		handler.current = jspRoot;
   	    } else {
   		handler.isTop = false;
  @@ -228,24 +228,33 @@
   	// is valid from that point forward.  Redefinitions cause an
   	// error.  This isn't quite consistent with how xmlns: normally
   	// works.
  -	Attributes attrsCopy = null;
  -	try {
  -	    attrsCopy = addCustomTagLibraries(attrs);
  -	} catch (JasperException je) {
  -	    throw new SAXParseException(
  -                    Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
  -		    locator, je );
  +	AttributesImpl attrsCopy = null;
  +	Attributes xmlnsAttrs = null;
  +	if (attrs != null) {
  +	    attrsCopy = new AttributesImpl(attrs);
  +	    xmlnsAttrs = getXmlnsAttributes(attrsCopy);
  +	    if (xmlnsAttrs != null) {
  +		try {
  +		    addCustomTagLibraries(xmlnsAttrs);
  +		} catch (JasperException je) {
  +		    throw new SAXParseException(
  +		        Localizer.getMessage(
  +                            "jsp.error.could.not.add.taglibraries"),
  +			locator, je);
  +		}
  +	    }
   	}
   
   	Node node = null;
   	if (qName.startsWith("jsp:")) {
  -	    node = parseStandardAction(qName, attrs, attrsCopy, start,
  +	    node = parseStandardAction(qName, attrsCopy, xmlnsAttrs, start,
   				       current);
   	} else {
  -	    node = parseCustomAction(qName, attrsCopy, start, current);
  +	    node = parseCustomAction(qName, attrsCopy, xmlnsAttrs, start,
  +				     current);
   	    if (node == null) {
  -		node = new Node.UninterpretedTag(attrsCopy, start, qName,
  -						 current);
  +		node = new Node.UninterpretedTag(qName, attrsCopy, xmlnsAttrs,
  +						 start, current);
   	    }
   	}
   
  @@ -483,7 +492,7 @@
       // Private utility methods
   
       private Node parseStandardAction(String qName, Attributes attrs,
  -				     Attributes attrsCopy, Mark start,
  +				     Attributes xmlnsAttrs, Mark start,
   				     Node parent)
   	        throws SAXException {
   
  @@ -493,7 +502,7 @@
               // 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);
  +	    node = new Node.JspRoot(attrs, xmlnsAttrs, start, current);
   	    if (isTop) {
   		pageInfo.setHasJspRoot(true);
   	    }
  @@ -503,45 +512,46 @@
   		    Localizer.getMessage("jsp.error.action.istagfile", qName),
   		    locator);
   	    }
  -	    node = new Node.PageDirective(attrsCopy, start, current);
  +	    node = new Node.PageDirective(attrs, xmlnsAttrs, start, current);
   	    String imports = attrs.getValue("import");
   	    // There can only be one 'import' attribute per page directive
   	    if (imports != null) {
   		((Node.PageDirective) node).addImport(imports);
   	    }
   	} else if (qName.equals(JSP_INCLUDE_DIRECTIVE)) {
  -	    node = new Node.IncludeDirective(attrsCopy, start, current);
  -	    processIncludeDirective(attrsCopy.getValue("file"), node);
  +	    node = new Node.IncludeDirective(attrs, xmlnsAttrs, start,
  +					     current);
  +	    processIncludeDirective(attrs.getValue("file"), node);
   	} else if (qName.equals(JSP_DECLARATION)) {
  -	    node = new Node.Declaration(start, current);
  +	    node = new Node.Declaration(xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_SCRIPTLET)) {
  -	    node = new Node.Scriptlet(start, current);
  +	    node = new Node.Scriptlet(xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_EXPRESSION)) {
  -	    node = new Node.Expression(start, current);
  +	    node = new Node.Expression(xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_USE_BEAN)) {
  -	    node = new Node.UseBean(attrsCopy, start, current);
  +	    node = new Node.UseBean(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_SET_PROPERTY)) {
  -	    node = new Node.SetProperty(attrsCopy, start, current);
  +	    node = new Node.SetProperty(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_GET_PROPERTY)) {
  -	    node = new Node.GetProperty(attrsCopy, start, current);
  +	    node = new Node.GetProperty(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_INCLUDE)) {
  -	    node = new Node.IncludeAction(attrsCopy, start, current);
  +	    node = new Node.IncludeAction(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_FORWARD)) {
  -	    node = new Node.ForwardAction(attrsCopy, start, current);
  +	    node = new Node.ForwardAction(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_PARAM)) {
  -	    node = new Node.ParamAction(attrsCopy, start, current);
  +	    node = new Node.ParamAction(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_PARAMS)) {
  -	    node = new Node.ParamsAction(start, current);
  +	    node = new Node.ParamsAction(xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_PLUGIN)) {
  -	    node = new Node.PlugIn(attrsCopy, start, current);
  +	    node = new Node.PlugIn(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_TEXT)) {
  -	    node = new Node.JspText(start, current);
  +	    node = new Node.JspText(xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_BODY)) {
  -	    node = new Node.JspBody(start, current);
  +	    node = new Node.JspBody(xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_ATTRIBUTE)) {
  -	    node = new Node.NamedAttribute(attrsCopy, start, current);
  +	    node = new Node.NamedAttribute(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_OUTPUT)) {
  -	    node = new Node.JspOutput(attrsCopy, start, current);
  +	    node = new Node.JspOutput(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_TAG_DIRECTIVE)) {
   	    if (!isTagFile) {
   		throw new SAXParseException(
  @@ -549,7 +559,7 @@
   					 qName),
   		    locator);
   	    }
  -	    node = new Node.TagDirective(attrsCopy, start, current);
  +	    node = new Node.TagDirective(attrs, xmlnsAttrs, start, current);
   	    String imports = attrs.getValue("import");
   	    // There can only be one 'import' attribute per tag directive
   	    if (imports != null) {
  @@ -562,7 +572,8 @@
   					 qName),
   		    locator);
   	    }
  -	    node = new Node.AttributeDirective(attrsCopy, start, current);
  +	    node = new Node.AttributeDirective(attrs, xmlnsAttrs, start,
  +					       current);
   	} else if (qName.equals(JSP_VARIABLE_DIRECTIVE)) {
   	    if (!isTagFile) {
   		throw new SAXParseException(
  @@ -570,7 +581,8 @@
   					 qName),
   		    locator);
   	    }
  -	    node = new Node.VariableDirective(attrsCopy, start, current);
  +	    node = new Node.VariableDirective(attrs, xmlnsAttrs, start,
  +					      current);
   	} else if (qName.equals(JSP_INVOKE)) {
   	    if (!isTagFile) {
   		throw new SAXParseException(
  @@ -578,7 +590,7 @@
   					 qName),
   		    locator);
   	    }
  -	    node = new Node.InvokeAction(attrsCopy, start, current);
  +	    node = new Node.InvokeAction(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_DO_BODY)) {
   	    if (!isTagFile) {
   		throw new SAXParseException(
  @@ -586,11 +598,11 @@
   					 qName),
   		    locator);
   	    }
  -	    node = new Node.DoBodyAction(attrsCopy, start, current);
  +	    node = new Node.DoBodyAction(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_ELEMENT)) {
  -	    node = new Node.JspElement(attrsCopy, start, current);
  +	    node = new Node.JspElement(attrs, xmlnsAttrs, start, current);
   	} else if (qName.equals(JSP_FALLBACK)) {
  -	    node = new Node.FallBackAction(start, current);
  +	    node = new Node.FallBackAction(xmlnsAttrs, start, current);
   	} else {
   	    throw new SAXParseException(
   		    Localizer.getMessage("jsp.error.xml.badStandardAction",
  @@ -607,6 +619,7 @@
        */
       private Node parseCustomAction(String qName,
   				   Attributes attrs,
  +				   Attributes xmlnsAttrs,
   				   Mark start,
   				   Node parent) throws SAXException {
   	int colon = qName.indexOf(':');
  @@ -645,89 +658,121 @@
               tagInfo = tagFileInfo.getTagInfo();
           }
          
  -	return new Node.CustomTag(attrs, start, qName, prefix, shortName,
  -				  tagInfo, tagFileInfo, tagHandlerClass,
  -				  parent);
  +	return new Node.CustomTag(attrs, xmlnsAttrs, start, qName, prefix,
  +				  shortName, tagInfo, tagFileInfo,
  +				  tagHandlerClass, parent);
       }
   
       /*
  -     * Parses the xmlns:prefix attributes from the jsp:root element and adds 
  -     * the corresponding TagLibraryInfo objects to the set of custom tag
  -     * libraries.  In the process, returns a new Attributes object that does
  -     * not contain any of the xmlns: attributes.
  +     * Extracts and removes any xmlns attributes from the given Attributes.
  +     *
  +     * @param attrs The Attributes from which to extract any xmlns attributes
  +     *
  +     * @return The set of xmlns attributes extracted from the given Attributes,
  +     * or null if the given Attributes do not contain any xmlns attributes
        */
  -    private Attributes addCustomTagLibraries(Attributes attrs)
  -	        throws JasperException 
  -    {
  -        AttributesImpl result = new AttributesImpl( attrs );
  -        int len = attrs.getLength();
  -        for (int i=len-1; i>=0; i--) {
  -	    String qName = attrs.getQName(i);
  -	    if (qName.startsWith( XMLNS ) 
  -                        && !qName.startsWith(XMLNS_JSP)
  -		        && !qName.startsWith(JSP_VERSION)) {
  +    private Attributes getXmlnsAttributes(AttributesImpl attrs) {
   
  -		// get the prefix
  -		String prefix = null;
  -		try {
  -		    prefix = qName.substring(XMLNS.length());
  -		} catch (StringIndexOutOfBoundsException e) {
  -		    continue;
  +	AttributesImpl result = null;
  +
  +	if (attrs == null) {
  +	    return null;
  +	}
  +
  +	int len = attrs.getLength();
  +	for (int i=len-1; i>=0; i--) {
  +	    String qName = attrs.getQName(i);
  +	    if (qName.startsWith(XMLNS)) {
  +		if (result == null) {
  +		    result = new AttributesImpl();
   		}
  +		result.addAttribute(attrs.getURI(i), attrs.getLocalName(i),
  +				    attrs.getQName(i), attrs.getType(i),
  +				    attrs.getValue(i));
  +		attrs.removeAttribute(i);
  +	    }	    
  +	}
  +	
  +	return result;
  +    }
   
  -                if( taglibs.containsKey( prefix ) ) {
  -                    // Prefix already in taglib map.
  -                    throw new JasperException(
  -                            Localizer.getMessage("jsp.error.xmlns.redefinition.notimplemented",
  -						 prefix));
  -                }
  +    /*
  +     * Enumerates the xmlns:prefix attributes of the given Attributes object
  +     * and adds the corresponding TagLibraryInfo objects to the set of custom
  +     * tag libraries.
  +     */
  +    private void addCustomTagLibraries(Attributes attrs)
  +	    throws JasperException 
  +    {
  +        if (attrs == null) {
  +	    return;
  +	}
   
  -		// get the uri
  -		String uri = attrs.getValue(i);
  +	int len = attrs.getLength();
  +        for (int i=len-1; i>=0; i--) {
  +	    String qName = attrs.getQName(i);
  +	    if (qName.startsWith(XMLNS_JSP)) {
  +		continue;
  +	    }
   
  -		TagLibraryInfo tagLibInfo = null;
  -		if (uri.startsWith(URN_JSPTAGDIR)) {
  -		    /*
  -		     * uri references tag file directory
  -		     * (is of the form "urn:jsptagdir:path")
  -		     */
  -		    String tagdir = uri.substring(URN_JSPTAGDIR.length());
  -		    tagLibInfo = new ImplicitTagLibraryInfo(ctxt,
  -							    parserController,
  -							    prefix, 
  -							    tagdir,
  -							    err);
  -		} else {
  -		    /*
  -		     * uri references TLD file
  -		     */
  -		    if (uri.startsWith(URN_JSPTLD)) {
  -			// uri is of the form "urn:jsptld:path"
  -			uri = uri.substring(URN_JSPTLD.length());
  -		    }
  +	    // get the prefix
  +	    String prefix = null;
  +	    try {
  +		prefix = qName.substring(XMLNS.length());
  +	    } catch (StringIndexOutOfBoundsException e) {
  +		continue;
  +	    }
  +
  +	    if( taglibs.containsKey( prefix ) ) {
  +		// Prefix already in taglib map.
  +		throw new JasperException(
  +		        Localizer.getMessage(
  +                                "jsp.error.xmlns.redefinition.notimplemented",
  +				prefix));
  +	    }
  +
  +	    // get the uri
  +	    String uri = attrs.getValue(i);
  +
  +	    TagLibraryInfo tagLibInfo = null;
  +	    if (uri.startsWith(URN_JSPTAGDIR)) {
  +		/*
  +		 * uri references tag file directory
  +		 * (is of the form "urn:jsptagdir:path")
  +		 */
  +		String tagdir = uri.substring(URN_JSPTAGDIR.length());
  +		tagLibInfo = new ImplicitTagLibraryInfo(ctxt,
  +							parserController,
  +							prefix, 
  +							tagdir,
  +							err);
  +	    } else {
  +		/*
  +		 * uri references TLD file
  +		 */
  +		if (uri.startsWith(URN_JSPTLD)) {
  +		    // uri is of the form "urn:jsptld:path"
  +		    uri = uri.substring(URN_JSPTLD.length());
  +		}
   
  -		    TldLocationsCache cache
  -			= ctxt.getOptions().getTldLocationsCache();
  -		    tagLibInfo = cache.getTagLibraryInfo(uri);
  -		    if (tagLibInfo == null) {
  -			// get the location
  -			String[] location = ctxt.getTldLocation(uri);
  -                
  -			tagLibInfo = new TagLibraryInfoImpl(ctxt,
  -							    parserController,
  -							    prefix,
  -							    uri,
  -							    location,
  -							    err);
  -		    }
  +		TldLocationsCache cache
  +		    = ctxt.getOptions().getTldLocationsCache();
  +		tagLibInfo = cache.getTagLibraryInfo(uri);
  +		if (tagLibInfo == null) {
  +		    // get the location
  +		    String[] location = ctxt.getTldLocation(uri);
  +		    
  +		    tagLibInfo = new TagLibraryInfoImpl(ctxt,
  +							parserController,
  +							prefix,
  +							uri,
  +							location,
  +							err);
   		}
  -                
  -		taglibs.put(prefix, tagLibInfo);
  -		result.removeAttribute( i );
   	    }
  -        }
  -
  -        return result;
  +                
  +	    taglibs.put(prefix, tagLibInfo);
  +	}
       }
   
       /*
  
  
  
  1.57      +156 -27   jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- Node.java	15 Feb 2003 01:41:42 -0000	1.56
  +++ Node.java	19 Feb 2003 23:39:15 -0000	1.57
  @@ -83,6 +83,7 @@
       private static final VariableInfo[] ZERO_VARIABLE_INFO = { };
       
       protected Attributes attrs;
  +    protected Attributes xmlnsAttrs;
       protected Nodes body;
       protected String text;
       protected Mark startMark;
  @@ -117,6 +118,22 @@
   	addToParent(parent);
       }
   
  +    /**
  +     * Constructor.
  +     * @param attrs The attributes for this node
  +     * @param xmlnsAttrs The xmlns attributes for this node
  +     * @param start The location of the jsp page
  +     * @param parent The enclosing node
  +     */
  +    public Node(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +		Node parent) {
  +	this.attrs = attrs;
  +	this.xmlnsAttrs = xmlnsAttrs;
  +	this.startMark = start;
  +	this.isDummy = (start == null);
  +	addToParent(parent);
  +    }
  +
       /*
        * Constructor.
        * @param text The text associated with this node
  @@ -134,6 +151,10 @@
   	return attrs;
       }
   
  +    public Attributes getXmlnsAttributes() {
  +	return xmlnsAttrs;
  +    }
  +
       public void setAttributes(Attributes attrs) {
   	this.attrs = attrs;
       }
  @@ -354,8 +375,10 @@
        */
       public static class JspRoot extends Root {
   
  -	public JspRoot(Attributes attrs, Mark start, Node parent) {
  +	public JspRoot(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +		       Node parent) {
   	    super(attrs, start, parent);
  +	    this.xmlnsAttrs = xmlnsAttrs;
   	}
   
   	public void accept(Visitor v) throws JasperException {
  @@ -375,7 +398,12 @@
   	private Vector imports;
   
   	public PageDirective(Attributes attrs, Mark start, Node parent) {
  -	    super(attrs, start, parent);
  +	    this(attrs, null, start, parent);
  +	}
  +
  +	public PageDirective(Attributes attrs, Attributes xmlnsAttrs,
  +			     Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
   	    imports = new Vector();
   	}
   
  @@ -418,6 +446,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public IncludeDirective(Attributes attrs, Attributes xmlnsAttrs,
  +				Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -444,7 +477,12 @@
           private Vector imports;
   
   	public TagDirective(Attributes attrs, Mark start, Node parent) {
  -	    super(attrs, start, parent);
  +	    this(attrs, null, start, parent);
  +	}
  +
  +	public TagDirective(Attributes attrs, Attributes xmlnsAttrs,
  +			    Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
               imports = new Vector();
   	}
   
  @@ -487,6 +525,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public AttributeDirective(Attributes attrs, Attributes xmlnsAttrs,
  +				  Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -501,6 +544,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public VariableDirective(Attributes attrs, Attributes xmlnsAttrs,
  +				 Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -515,6 +563,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public InvokeAction(Attributes attrs, Attributes xmlnsAttrs,
  +			    Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -529,6 +582,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public DoBodyAction(Attributes attrs, Attributes xmlnsAttrs,
  +			    Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -558,8 +616,9 @@
   	    super(text, start, parent);
   	}
   
  -	public ScriptingElement(Mark start, Node parent) {
  -	    super(start, parent);
  +	public ScriptingElement(Attributes xmlnsAttrs, Mark start,
  +				Node parent) {
  +	    super(null, xmlnsAttrs, start, parent);
   	}
   
   	/**
  @@ -591,8 +650,8 @@
   	    super(text, start, parent);
   	}
   
  -	public Declaration(Mark start, Node parent) {
  -	    super(start, parent);
  +	public Declaration(Attributes xmlnsAttrs, Mark start, Node parent) {
  +	    super(xmlnsAttrs, start, parent);
   	}
   
   	public void accept(Visitor v) throws JasperException {
  @@ -610,8 +669,8 @@
   	    super(text, start, parent);
   	}
   
  -	public Expression(Mark start, Node parent) {
  -	    super(start, parent);
  +	public Expression(Attributes xmlnsAttrs, Mark start, Node parent) {
  +	    super(xmlnsAttrs, start, parent);
   	}
   
   	public void accept(Visitor v) throws JasperException {
  @@ -628,8 +687,8 @@
   	    super(text, start, parent);
   	}
   
  -	public Scriptlet(Mark start, Node parent) {
  -	    super(start, parent);
  +	public Scriptlet(Attributes xmlnsAttrs, Mark start, Node parent) {
  +	    super(xmlnsAttrs, start, parent);
   	}
   
   	public void accept(Visitor v) throws JasperException {
  @@ -663,6 +722,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public ParamAction(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +			   Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -682,7 +746,11 @@
       public static class ParamsAction extends Node {
   
   	public ParamsAction(Mark start, Node parent) {
  -	    super(start, parent);
  +	    this(null, start, parent);
  +	}
  +
  +	public ParamsAction(Attributes xmlnsAttrs, Mark start, Node parent) {
  +	    super(null, xmlnsAttrs, start, parent);
   	}
   
   	public void accept(Visitor v) throws JasperException {
  @@ -699,6 +767,10 @@
   	    super(start, parent);
   	}
   
  +	public FallBackAction(Attributes xmlnsAttrs, Mark start, Node parent) {
  +	    super(null, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -715,6 +787,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public IncludeAction(Attributes attrs, Attributes xmlnsAttrs,
  +			     Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -739,6 +816,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public ForwardAction(Attributes attrs, Attributes xmlnsAttrs,
  +			     Mark start, Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -761,6 +843,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public GetProperty(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +			   Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -777,6 +864,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public SetProperty(Attributes attrs, Attributes xmlsAttrs, Mark start,
  +			   Node parent) {
  +	    super(attrs, xmlsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -801,6 +893,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public UseBean(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +		       Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -826,6 +923,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public PlugIn(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +		      Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -851,11 +953,13 @@
        * Represents an uninterpreted tag, from a Jsp document
        */
       public static class UninterpretedTag extends Node {
  +
   	private String tagName;
   
  -	public UninterpretedTag(Attributes attrs, Mark start, String name,
  +	public UninterpretedTag(String name, Attributes attrs,
  +				Attributes xmlnsAttrs, Mark start,
   				Node parent) {
  -	    super(attrs, start, parent);
  +	    super(attrs, xmlnsAttrs, start, parent);
   	    tagName = name;
   	}
   
  @@ -879,6 +983,11 @@
   	    super(attrs, start, parent);
   	}
   
  +	public JspElement(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +			  Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
  +	}
  +
   	public void accept(Visitor v) throws JasperException {
   	    v.visit(this);
   	}
  @@ -897,8 +1006,9 @@
        */
       public static class JspOutput extends Node {
   
  -	public JspOutput(Attributes attrs, Mark start, Node parent) {
  -	    super(attrs, start, parent);
  +	public JspOutput(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +			 Node parent) {
  +	    super(attrs, xmlnsAttrs, start, parent);
   	}
   
   	public void accept(Visitor v) throws JasperException {
  @@ -999,11 +1109,20 @@
   	private Nodes atSTag;
   	private Nodes atETag;
   
  -	public CustomTag(Attributes attrs, Mark start, String name,
  -			 String prefix, String shortName,
  +	public CustomTag(Attributes attrs, Mark start,
  +			 String name, String prefix, String shortName,
   			 TagInfo tagInfo, TagFileInfo tagFileInfo,
   			 Class tagHandlerClass, Node parent) {
  -	    super(attrs, start, parent);
  +	    this(attrs, null, start, name, prefix, shortName, tagInfo,
  +		 tagFileInfo, tagHandlerClass, parent);
  +	}
  +
  +	public CustomTag(Attributes attrs, Attributes xmlnsAttrs, Mark start,
  +			 String name, String prefix, String shortName,
  +			 TagInfo tagInfo, TagFileInfo tagFileInfo,
  +			 Class tagHandlerClass, Node parent) {
  +
  +	    super(attrs, xmlnsAttrs, start, parent);
   	    this.name = name;
   	    this.prefix = prefix;
   	    this.shortName = shortName;
  @@ -1347,8 +1466,8 @@
        */
       public static class JspText extends Node {
   
  -	public JspText(Mark start, Node parent) {
  -	    super(start, parent);
  +	public JspText(Attributes xmlnsAttrs, Mark start, Node parent) {
  +	    super(null, xmlnsAttrs, start, parent);
   	}
   
   	public void accept(Visitor v) throws JasperException {
  @@ -1372,8 +1491,14 @@
   	private String localName;
   	private String prefix;
   
  -        public NamedAttribute( Attributes attrs, Mark start, Node parent) {
  -            super( attrs, start, parent );
  +        public NamedAttribute(Attributes attrs, Mark start, Node parent) {
  +	    this(attrs, null, start, parent);
  +	}
  +
  +        public NamedAttribute(Attributes attrs, Attributes xmlnsAttrs,
  +			      Mark start, Node parent) {
  +
  +            super(attrs, xmlnsAttrs, start, parent);
               temporaryVariableName = JspUtil.nextTemporaryVariableName();
               if( "false".equals( this.getAttributeValue( "trim" ) ) ) {
                   // (if null or true, leave default of true)
  @@ -1467,7 +1592,11 @@
           private ChildInfo childInfo;
   
           public JspBody(Mark start, Node parent) {
  -            super(start, parent);
  +            this(null, start, parent);
  +        }
  +
  +        public JspBody(Attributes xmlnsAttrs, Mark start, Node parent) {
  +            super(null, xmlnsAttrs, start, parent);
               this.childInfo = new ChildInfo();
           }
   
  
  
  
  1.21      +53 -42    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java
  
  Index: PageDataImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- PageDataImpl.java	13 Jan 2003 22:08:58 -0000	1.20
  +++ PageDataImpl.java	19 Feb 2003 23:39:15 -0000	1.21
  @@ -259,7 +259,7 @@
   	    if (n == this.root) {
   		// top-level page
   		appendXmlProlog();
  -		appendTag(JSP_ROOT, n.getAttributes(), n.getBody(), null);
  +		appendTag(JSP_ROOT, n);
   	    } else {
   		visitBody(n);
   	    }
  @@ -275,7 +275,7 @@
   	    if (n == this.root) {
   		// top-level jsp:root element
   		appendXmlProlog();
  -		appendTag(JSP_ROOT, n.getAttributes(), n.getBody(), null);
  +		appendTag(JSP_ROOT, n);
   	    } else {
   		visitBody(n);
   	    }
  @@ -295,15 +295,15 @@
   	}
   
   	public void visit(Node.Declaration n) throws JasperException {
  -	    appendTag(JSP_DECLARATION, n.getAttributes(), null, n.getText());
  +	    appendTag(JSP_DECLARATION, n);
   	}
   
   	public void visit(Node.Expression n) throws JasperException {
  -	    appendTag(JSP_EXPRESSION, n.getAttributes(), null, n.getText());
  +	    appendTag(JSP_EXPRESSION, n);
   	}
   
   	public void visit(Node.Scriptlet n) throws JasperException {
  -	    appendTag(JSP_SCRIPTLET, n.getAttributes(), null, n.getText());
  +	    appendTag(JSP_SCRIPTLET, n);
   	}
   
   	public void visit(Node.ELExpression n) throws JasperException {
  @@ -322,67 +322,67 @@
   	}
   
   	public void visit(Node.IncludeAction n) throws JasperException {
  -	    appendTag(JSP_INCLUDE, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_INCLUDE, n);
   	}
       
   	public void visit(Node.ForwardAction n) throws JasperException {
  -	    appendTag(JSP_FORWARD, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_FORWARD, n);
   	}
   
   	public void visit(Node.GetProperty n) throws JasperException {
  -	    appendTag(JSP_GET_PROPERTY, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_GET_PROPERTY, n);
   	}
   
   	public void visit(Node.SetProperty n) throws JasperException {
  -	    appendTag(JSP_SET_PROPERTY, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_SET_PROPERTY, n);
   	}
   
   	public void visit(Node.ParamAction n) throws JasperException {
  -	    appendTag(JSP_PARAM, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_PARAM, n);
   	}
   
   	public void visit(Node.ParamsAction n) throws JasperException {
  -	    appendTag(JSP_PARAMS, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_PARAMS, n);
   	}
   
   	public void visit(Node.FallBackAction n) throws JasperException {
  -	    appendTag(JSP_FALLBACK, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_FALLBACK, n);
   	}
   
   	public void visit(Node.UseBean n) throws JasperException {
  -	    appendTag(JSP_USE_BEAN, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_USE_BEAN, n);
   	}
   	
   	public void visit(Node.PlugIn n) throws JasperException {
  -	    appendTag(JSP_PLUGIN, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_PLUGIN, n);
   	}
   
           public void visit(Node.NamedAttribute n) throws JasperException {
  -            appendTag(JSP_ATTRIBUTE, n.getAttributes(), n.getBody(), null);
  +            appendTag(JSP_ATTRIBUTE, n);
           }
           
           public void visit(Node.JspBody n) throws JasperException {
  -            appendTag(JSP_BODY, n.getAttributes(), n.getBody(), null);
  +            appendTag(JSP_BODY, n);
           }
   
   	public void visit(Node.CustomTag n) throws JasperException {
  -	    appendTag(n.getName(), n.getAttributes(), n.getBody(), null);
  +	    appendTag(n.getName(), n);
   	}
   
   	public void visit(Node.UninterpretedTag n) throws JasperException {
  -	    appendTag(n.getName(), n.getAttributes(), n.getBody(), null);
  +	    appendTag(n.getName(), n);
   	}
   
   	public void visit(Node.JspText n) throws JasperException {
  -	    appendTag(JSP_TEXT, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_TEXT, n);
   	}
   
   	public void visit(Node.DoBodyAction n) throws JasperException {
  -	    appendTag(JSP_DO_BODY, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_DO_BODY, n);
   	}
   
           public void visit(Node.InvokeAction n) throws JasperException {
  -	    appendTag(JSP_INVOKE, n.getAttributes(), n.getBody(), null);
  +	    appendTag(JSP_INVOKE, n);
   	}
   
   	public void visit(Node.TagDirective n) throws JasperException {
  @@ -390,11 +390,11 @@
   	}
   
   	public void visit(Node.AttributeDirective n) throws JasperException {
  -	    appendTag(JSP_ATTRIBUTE_DIRECTIVE, n.getAttributes(), null, null);
  +	    appendTag(JSP_ATTRIBUTE_DIRECTIVE, n);
   	}
   
   	public void visit(Node.VariableDirective n) throws JasperException {
  -	    appendTag(JSP_VARIABLE_DIRECTIVE, n.getAttributes(), null, null);
  +	    appendTag(JSP_VARIABLE_DIRECTIVE, n);
   	}
           
   	public void visit(Node.TemplateText n) throws JasperException {
  @@ -408,18 +408,16 @@
   	/*
   	 * Appends the given tag, including its body, to the XML view.
   	 */
  -	private void appendTag(String tag,
  -			       Attributes attrs,
  -			       Node.Nodes body,
  -			       String text) throws JasperException {
  +	private void appendTag(String tag, Node n) throws JasperException {
  +
  +	    Node.Nodes body = n.getBody();
  +	    String text = n.getText();
   
   	    buf.append("<").append(tag);
   	    buf.append("\n");
   	    buf.append("  ").append("jsp:id").append("=\"");
   	    buf.append(jspId++).append("\"\n");
  -	    if (attrs != null) {
  -		printAttributes(attrs);
  -	    }
  +	    printAttributes(n);
   	    if (tag.equals(JSP_ROOT) || body != null || text != null) {
   		buf.append(">\n");
   		if (tag.equals(JSP_ROOT)) {
  @@ -560,7 +558,7 @@
   		return;
   	    }
   
  -	    appendTag(JSP_TAG_DIRECTIVE, tagDir.getAttributes(), null, null);
  +	    appendTag(JSP_TAG_DIRECTIVE, tagDir);
   	}
   
   	/*
  @@ -635,15 +633,28 @@
   	}
   
   	/*
  -	 * Appends the given attributes to the XML view.
  +	 * Appends the attributes of the given Node to the XML view.
   	 */
  -	private void printAttributes(Attributes attrs) {
  -	    int len = attrs.getLength();
  -	    for (int i=0; i<len; i++) {
  -		String name = attrs.getQName(i);
  -		String value = attrs.getValue(i);
  -		buf.append("  ").append(name).append("=\"");
  -		buf.append(JspUtil.getExprInXml(value)).append("\"\n");
  +	private void printAttributes(Node n) {
  +	    Attributes attrs = n.getXmlnsAttributes();
  +	    if (attrs != null) {
  +		int len = attrs.getLength();
  +		for (int i=0; i<len; i++) {
  +		    String name = attrs.getQName(i);
  +		    String value = attrs.getValue(i);
  +		    buf.append("  ").append(name).append("=\"").append(value).append("\"\n");
  +		}
  +	    }
  +
  +	    attrs = n.getAttributes();
  +	    if (attrs != null) {
  +		int len = attrs.getLength();
  +		for (int i=0; i<len; i++) {
  +		    String name = attrs.getQName(i);
  +		    String value = attrs.getValue(i);
  +		    buf.append("  ").append(name).append("=\"");
  +		    buf.append(JspUtil.getExprInXml(value)).append("\"\n");
  +		}
   	    }
   	}
   
  
  
  

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


Mime
View raw message