tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kin...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspDocumentParser.java PageInfo.java
Date Fri, 08 Aug 2003 22:22:10 GMT
kinman      2003/08/08 15:22:10

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        JspDocumentParser.java PageInfo.java
  Log:
  - Refactor some code in JspDocumentParser, since startPrefixMapping
    got called before startElement.
  - Turn on push/pop prefixes for taglibs in XML syntax, so that proper
    prefix can be located.
  - Fix a minor bug in PageInfo.
  
  Revision  Changes    Path
  1.62      +31 -30    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.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- JspDocumentParser.java	21 Jul 2003 21:52:51 -0000	1.61
  +++ JspDocumentParser.java	8 Aug 2003 22:22:09 -0000	1.62
  @@ -109,6 +109,7 @@
       private boolean isTagFile;
       private boolean directivesOnly;
       private boolean isTop;
  +    private Stack prefixMapStack;
   
       /*
        * Constructor
  @@ -127,6 +128,7 @@
   	this.isTagFile = isTagFile;
   	this.directivesOnly = directivesOnly;
   	this.isTop = true;
  +        this.prefixMapStack = new Stack();;
       }
   
       /*
  @@ -265,20 +267,9 @@
   			isTaglib = true;
   		    } else {
   			String attrUri = attrs.getValue(i);
  -			if (!pageInfo.hasTaglib(attrUri)) {
  -			    TagLibraryInfo tagLibInfo = null;
  -			    try {
  -				tagLibInfo = getTaglibInfo(attrQName, attrUri);
  -			    } catch (JasperException je) {
  -				throw new SAXParseException(
  -                                    Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
  -				    locator, je);
  -			    }
  -			    if (tagLibInfo != null) {
  -				isTaglib = true;
  -			    }
  -			    pageInfo.addTaglib(attrUri, tagLibInfo);
  -			}
  +			// TaglibInfo for this uri already established in
  +			// startPrefixMapping
  +			isTaglib = pageInfo.hasTaglib(attrUri);
   		    }
   		    if (isTaglib) {
   			if (taglibAttrs == null) {
  @@ -555,16 +546,34 @@
       /*
        * Receives notification of the start of a Namespace mapping. 
        */
  -     public void startPrefixMapping(String prefix, String uri)
  +    public void startPrefixMapping(String prefix, String uri)
   	     throws SAXException {
  -         // XXX
  +        TagLibraryInfo taglibInfo;
  +        try {
  +            taglibInfo = getTaglibInfo(prefix, uri);
  +        } catch (JasperException je) {
  +            throw new SAXParseException(
  +                Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
  +                locator, je);
  +        }
  +
  +        if (taglibInfo != null) {
  +            pageInfo.addTaglib(uri, taglibInfo);
  +            pageInfo.pushPrefixMapping(prefix, uri);
  +            prefixMapStack.push(new Boolean(true));
  +	}
  +        else {
  +            prefixMapStack.push(new Boolean(false));
  +        }
        }
   
        /*
         * Receives notification of the end of a Namespace mapping. 
         */
       public void endPrefixMapping(String prefix) throws SAXException {
  -	// XXX
  +        if (((Boolean)prefixMapStack.pop()).booleanValue()) {
  +            pageInfo.popPrefixMapping(prefix);
  +        }
       }
   
   
  @@ -792,23 +801,15 @@
        * Creates the tag library associated with the given uri namespace, and
        * returns it.
        *
  -     * @param qName The qualified name of the xmlns attribute
  -     * (of the form 'xmlns:<prefix>')
  +     * @param prefix The prefix of the xmlns attribute
        * @param uri The uri namespace (value of the xmlns attribute)
        *
        * @return The tag library associated with the given uri namespace
        */
  -    private TagLibraryInfo getTaglibInfo(String qName, String uri)
  +    private TagLibraryInfo getTaglibInfo(String prefix, String uri)
                   throws JasperException {
   
   	TagLibraryInfo result = null;
  -
  -	// Get the prefix
  -	String prefix = "";
  -	int colon = qName.indexOf(':');
  -	if (colon != -1) {
  -	    prefix = qName.substring(colon + 1);
  -	}
   
   	if (uri.startsWith(URN_JSPTAGDIR)) {
   	    // uri (of the form "urn:jsptagdir:path") references tag file dir
  
  
  
  1.38      +4 -3      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageInfo.java
  
  Index: PageInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/PageInfo.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- PageInfo.java	8 Aug 2003 19:06:41 -0000	1.37
  +++ PageInfo.java	8 Aug 2003 22:22:09 -0000	1.38
  @@ -320,6 +320,7 @@
   	LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix);
   	if (stack == null) {
   	    stack = new LinkedList();
  +	    xmlPrefixMapper.put(prefix, stack);
   	}
   	stack.addFirst(uri);
       }
  
  
  

Mime
View raw message