jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv JstlBaseTLV.java JstlCoreTLV.java JstlFmtTLV.java JstlSqlTLV.java JstlXmlTLV.java
Date Wed, 17 Apr 2002 17:59:23 GMT
shawn       02/04/17 10:59:23

  Modified:    standard/examples/conf web.xml
               standard/src/org/apache/taglibs/standard/tlv
                        JstlBaseTLV.java JstlCoreTLV.java JstlFmtTLV.java
                        JstlSqlTLV.java JstlXmlTLV.java
  Log:
  Allow cross-breeding between EL and RT libraries.
  
  Revision  Changes    Path
  1.8       +4 -4      jakarta-taglibs/standard/examples/conf/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/conf/web.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- web.xml	17 Apr 2002 02:53:35 -0000	1.7
  +++ web.xml	17 Apr 2002 17:59:23 -0000	1.8
  @@ -29,7 +29,7 @@
       </taglib>
   
       <taglib>
  -        <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
  +        <taglib-uri>http://java.sun.com/jstl/core_rt</taglib-uri>
           <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
       </taglib>
   
  @@ -39,7 +39,7 @@
       </taglib>
   
       <taglib>
  -        <taglib-uri>http://java.sun.com/jstl/xml-rt</taglib-uri>
  +        <taglib-uri>http://java.sun.com/jstl/xml_rt</taglib-uri>
           <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
       </taglib>
   
  @@ -49,7 +49,7 @@
       </taglib>
   
       <taglib>
  -        <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
  +        <taglib-uri>http://java.sun.com/jstl/fmt_rt</taglib-uri>
           <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
       </taglib>
   
  @@ -59,7 +59,7 @@
       </taglib>
   
       <taglib>
  -        <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
  +        <taglib-uri>http://java.sun.com/jstl/sql_rt</taglib-uri>
           <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
       </taglib>
   
  
  
  
  1.8       +46 -3     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlBaseTLV.java
  
  Index: JstlBaseTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlBaseTLV.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JstlBaseTLV.java	5 Apr 2002 21:27:43 -0000	1.7
  +++ JstlBaseTLV.java	17 Apr 2002 17:59:23 -0000	1.8
  @@ -101,6 +101,16 @@
       protected static final String SESSION_SCOPE = "session";  
       protected static final String APPLICATION_SCOPE = "application";
   
  +    // Relevant URIs
  +    protected final String JSP = "http://java.sun.com/JSP/Page";   
  +    private final String CORE_EL = "http://java.sun.com/jstl/core";
  +    private final String FMT_EL = "http://java.sun.com/jstl/fmt";
  +    private final String SQL_EL = "http://java.sun.com/jstl/sql";
  +    private final String XML_EL = "http://java.sun.com/jstl/xml";
  +    private final String CORE_RT = "http://java.sun.com/jstl/core_rt";
  +    private final String FMT_RT = "http://java.sun.com/jstl/fmt_rt";
  +    private final String SQL_RT = "http://java.sun.com/jstl/sql_rt";
  +    private final String XML_RT = "http://java.sun.com/jstl/xml_rt";
   
       //*********************************************************************
       // Validation and configuration state (protected)
  @@ -161,6 +171,7 @@
   	    // parse the page
   	    SAXParserFactory f = SAXParserFactory.newInstance();
   	    f.setValidating(false);
  +	    f.setNamespaceAware(true);
   	    SAXParser p = f.newSAXParser();
   	    p.parse(page.getInputStream(), h);
   
  @@ -204,9 +215,41 @@
   		+ response;
       }
   
  -    // utility method to help us match elements in our tagset
  -    protected boolean isTag(String qn, String unqualifiedName) {
  -        return (qn.equals(prefix + ":" + unqualifiedName));
  +    // utility methods to help us match elements in our tagset
  +    protected boolean isTag(String tagUri,
  +			    String tagLn,
  +			    String matchUri,
  +			    String matchLn) {
  +	if (tagUri == null
  +	        || tagLn == null
  +		|| matchUri == null
  +		|| matchLn == null)
  +	    return false;
  +        return (tagUri.equals(matchUri) && tagLn.equals(matchLn));
  +    }
  +
  +    protected boolean isJspTag(String tagUri, String tagLn, String target) {
  +        return isTag(tagUri, tagLn, JSP, target);
  +    }
  +
  +    protected boolean isCoreTag(String tagUri, String tagLn, String target) {
  +        return (isTag(tagUri, tagLn, CORE_EL, target)
  +	     || isTag(tagUri, tagLn, CORE_RT, target));
  +    }
  +
  +    protected boolean isFmtTag(String tagUri, String tagLn, String target) {
  +        return (isTag(tagUri, tagLn, FMT_EL, target) 
  +	     || isTag(tagUri, tagLn, FMT_RT, target));
  +    }
  +
  +    protected boolean isSqlTag(String tagUri, String tagLn, String target) {
  +        return (isTag(tagUri, tagLn, SQL_EL, target) 
  +	     || isTag(tagUri, tagLn, SQL_RT, target));
  +    }
  +
  +    protected boolean isXmlTag(String tagUri, String tagLn, String target) {
  +        return (isTag(tagUri, tagLn, XML_EL, target)
  +	     || isTag(tagUri, tagLn, XML_RT, target));
       }
   
       // utility method to determine if an attribute exists
  
  
  
  1.16      +20 -17    jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlCoreTLV.java
  
  Index: JstlCoreTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlCoreTLV.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JstlCoreTLV.java	8 Apr 2002 19:15:17 -0000	1.15
  +++ JstlCoreTLV.java	17 Apr 2002 17:59:23 -0000	1.16
  @@ -118,7 +118,7 @@
       private final String PARAM = "param";
       private final String URL_ENCODE = "urlEncode";
       // private final String EXPLANG = "expressionLanguage";
  -    private final String JSP_TEXT = "jsp:text";
  +    private final String TEXT = "text";
   
       // attribute names
       private final String EVAL = "evaluator";
  @@ -130,6 +130,7 @@
       private final String IMPORT_WITH_READER = "import varReader=''";
       private final String IMPORT_WITHOUT_READER = "import var=''";
   
  +
       //*********************************************************************
       // Contract fulfillment
   
  @@ -163,7 +164,7 @@
   
   	    // for simplicity, we can ignore <jsp:text> for our purposes
   	    // (don't bother distinguishing between it and its characters)
  -	    if (qn.equals(JSP_TEXT))
  +	    if (isJspTag(ns, ln, TEXT))
   		return;
   
   	    // check body-related constraint
  @@ -198,7 +199,7 @@
   	    // check invariants for <choose>
   	    if (chooseChild()) {
   		// ensure <choose> has the right children
  -		if(!isTag(qn, WHEN) && !isTag(qn, OTHERWISE)) {
  +		if(!isCoreTag(ns, ln, WHEN) && !isCoreTag(ns, ln, OTHERWISE)) {
   		    fail(Resources.getMessage("TLV_ILLEGAL_CHILD_TAG",
   			prefix, CHOOSE, qn));
   		}
  @@ -208,7 +209,7 @@
   		   fail(Resources.getMessage("TLV_ILLEGAL_ORDER",
   			qn, prefix, OTHERWISE, CHOOSE));
   		}
  -		if (isTag(qn, OTHERWISE)) {
  +		if (isCoreTag(ns, ln, OTHERWISE)) {
   		    chooseHasOtherwise.pop();
   		    chooseHasOtherwise.push(new Boolean(true));
   		}
  @@ -216,7 +217,7 @@
   	    }
   
   	    // check constraints for <param> vis-a-vis URL-related tags
  -	    if (isTag(qn, PARAM)) {
  +	    if (isCoreTag(ns, ln, PARAM)) {
   		// no <param> outside URL tags.
   		if (urlTags.empty() || urlTags.peek().equals(PARAM))
   		    fail(Resources.getMessage("TLV_ILLEGAL_ORPHAN", PARAM));
  @@ -237,31 +238,31 @@
   	    // now, modify state
   
   	    // we're a choose, so record new choose-specific state
  -	    if (isTag(qn, CHOOSE)) {
  +	    if (isCoreTag(ns, ln, CHOOSE)) {
   		chooseDepths.push(new Integer(depth));
   		chooseHasOtherwise.push(new Boolean(false));
   	    }
   
   	    // if we're introducing a URL-related tag, record it
  -	    if (isTag(qn, IMPORT)) {
  +	    if (isCoreTag(ns, ln, IMPORT)) {
   		if (hasAttribute(a, VAR_READER))
   		    urlTags.push(IMPORT_WITH_READER);
   		else
   		    urlTags.push(IMPORT_WITHOUT_READER);
  -	    } else if (isTag(qn, PARAM))
  +	    } else if (isCoreTag(ns, ln, PARAM))
   		urlTags.push(PARAM);
  -	    else if (isTag(qn, REDIRECT))
  +	    else if (isCoreTag(ns, ln, REDIRECT))
   		urlTags.push(REDIRECT);
  -	    else if (isTag(qn, URL))
  +	    else if (isCoreTag(ns, ln, URL))
   		urlTags.push(URL);
   
   	    // set up a check against illegal attribute/body combinations
   	    bodyIllegal = false;
   	    bodyNecessary = false;
  -	    if (isTag(qn, EXPR)) {
  +	    if (isCoreTag(ns, ln, EXPR)) {
   		if (hasAttribute(a, DEFAULT))
   		    bodyIllegal = true;
  -	    } else if (isTag(qn, SET)) {
  +	    } else if (isCoreTag(ns, ln, SET)) {
   		if (hasAttribute(a, VALUE))
   		    bodyIllegal = true;
   		// else
  @@ -270,7 +271,7 @@
   
   	    // record the most recent tag (for error reporting)
   	    lastElementName = qn;
  -	    lastElementId = a.getValue("http://java.sun.com/JSP/Page", "id");
  +	    lastElementId = a.getValue(JSP, "id");
   
   	    // we're a new element, so increase depth
   	    depth++;
  @@ -309,7 +310,7 @@
   	public void endElement(String ns, String ln, String qn) {
   
   	    // consistently, we ignore JSP_TEXT
  -	    if (qn.equals(JSP_TEXT))
  +	    if (isJspTag(ns, ln, TEXT))
   		return;
   
   	    // handle body-related invariant
  @@ -319,14 +320,16 @@
   	    bodyIllegal = false;	// reset: we've left the tag
   
   	    // update <choose>-related state
  -	    if (isTag(qn, CHOOSE)) {
  +	    if (isCoreTag(ns, ln, CHOOSE)) {
   		chooseDepths.pop();
   		chooseHasOtherwise.pop();
   	    }
   
   	    // update state related to URL tags
  -	    if (isTag(qn, IMPORT) || isTag(qn, PARAM) || isTag(qn, REDIRECT)
  -		    || isTag(qn, URL))
  +	    if (isCoreTag(ns, ln, IMPORT)
  +                    || isCoreTag(ns, ln, PARAM)
  +		    || isCoreTag(ns, ln, REDIRECT)
  +		    || isCoreTag(ns, ln, URL))
   		urlTags.pop();
   
   	    // update our depth
  
  
  
  1.15      +13 -10    jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlFmtTLV.java
  
  Index: JstlFmtTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlFmtTLV.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JstlFmtTLV.java	12 Apr 2002 19:16:50 -0000	1.14
  +++ JstlFmtTLV.java	17 Apr 2002 17:59:23 -0000	1.15
  @@ -77,6 +77,7 @@
    * </ul>
    * 
    * @author Shawn Bayern
  + * @author Jan Luehe
    */
   public class JstlFmtTLV extends JstlBaseTLV {
   
  @@ -187,32 +188,34 @@
                   fail(Resources.getMessage("TLV_INVALID_ATTRIBUTE",
                       SCOPE, qn, a.getValue(SCOPE)));
               if (qn.startsWith(prefix + ":")
  -                && !isTag(qn, SETLOCALE) 
  -		&& !isTag(qn, BUNDLE)
  -		&& !isTag(qn, TIMEZONE)
  +                && !isFmtTag(ns, ln, SETLOCALE) 
  +		&& !isFmtTag(ns, ln, BUNDLE)
  +		&& !isFmtTag(ns, ln, TIMEZONE)
                   && hasDanglingScope(a))
                   fail(Resources.getMessage("TLV_DANGLING_SCOPE", qn));
   
   	    // set up a check against illegal attribute/body combinations
   	    bodyIllegal = false;
   	    bodyNecessary = false;
  -	    if (isTag(qn, MESSAGE_PARAM)
  -		    || isTag(qn, FORMAT_NUMBER)
  -		    || isTag(qn, PARSE_NUMBER)
  -		    || isTag(qn, PARSE_DATE)) {
  +	    if (isFmtTag(ns, ln, MESSAGE_PARAM)
  +		    || isFmtTag(ns, ln, FORMAT_NUMBER)
  +		    || isFmtTag(ns, ln, PARSE_NUMBER)
  +		    || isFmtTag(ns, ln,  PARSE_DATE)) {
   		if (hasAttribute(a, VALUE))
   		    bodyIllegal = true;
   		else
   		    bodyNecessary = true;
  -	    } else if (isTag(qn, MESSAGE) && !hasAttribute(a, MESSAGE_KEY)) {
  +	    } else if (isFmtTag(ns, ln, MESSAGE)
  +		    && !hasAttribute(a, MESSAGE_KEY)) {
   		bodyNecessary = true;
  -	    } else if (isTag(qn, BUNDLE) && hasAttribute(a, BUNDLE_PREFIX)) {
  +	    } else if (isFmtTag(ns, ln, BUNDLE)
  +		    && hasAttribute(a, BUNDLE_PREFIX)) {
   		bodyNecessary = true;
   	    }
   
   	    // record the most recent tag (for error reporting)
   	    lastElementName = qn;
  -            lastElementId = a.getValue("http://java.sun.com/JSP/Page", "id");
  +            lastElementId = a.getValue(JSP, "id");
   	}
   
   	public void characters(char[] ch, int start, int length) {
  
  
  
  1.6       +9 -9      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlSqlTLV.java
  
  Index: JstlSqlTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlSqlTLV.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JstlSqlTLV.java	16 Apr 2002 00:01:34 -0000	1.5
  +++ JstlSqlTLV.java	17 Apr 2002 17:59:23 -0000	1.6
  @@ -170,21 +170,21 @@
                *   </c:forEach>
                *  </sql:query>
                */
  -            if ( (isTag(qn, PARAM) || isTag(qn, DATEPARAM)) 
  +            if ( (isSqlTag(ns, ln, PARAM) || isSqlTag(ns, ln, DATEPARAM)) 
                   && (queryDepths.empty() && updateDepths.empty()) ) {
                   fail(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
               }
   
               // If we're in a <query>, record relevant state
  -            if (isTag(qn, QUERY)) {
  +            if (isSqlTag(ns, ln, QUERY)) {
                   queryDepths.push(new Integer(depth));
               }
               // If we're in a <update>, record relevant state
  -            if (isTag(qn, UPDATE)) {
  +            if (isSqlTag(ns, ln, UPDATE)) {
                   updateDepths.push(new Integer(depth));
               }
               // If we're in a <transaction>, record relevant state
  -            if (isTag(qn, TRANSACTION)) {
  +            if (isSqlTag(ns, ln, TRANSACTION)) {
                   transactionDepths.push(new Integer(depth));
               }
   
  @@ -192,7 +192,7 @@
   	    bodyIllegal = false;
   	    bodyNecessary = false;
   
  -            if (isTag(qn, QUERY) || isTag(qn, UPDATE)) {
  +            if (isSqlTag(ns, ln, QUERY) || isSqlTag(ns, ln, UPDATE)) {
                   if (!hasAttribute(a, SQL)) {
                       bodyNecessary = true;
                   }
  @@ -201,7 +201,7 @@
                   }
               }
   
  -            if (isTag(qn, DATEPARAM)) {
  +            if (isSqlTag(ns, ln, DATEPARAM)) {
                   bodyIllegal = true;
               }
   
  @@ -240,15 +240,15 @@
   	    bodyIllegal = false;	// reset: we've left the tag
   
               // update <query>-related state
  -            if (isTag(qn, QUERY)) {
  +            if (isSqlTag(ns, ln, QUERY)) {
                   queryDepths.pop();
               }
               // update <update>-related state
  -            if (isTag(qn, UPDATE)) {
  +            if (isSqlTag(ns, ln, UPDATE)) {
                   updateDepths.pop();
               }
               // update <update>-related state
  -            if (isTag(qn, TRANSACTION)) {
  +            if (isSqlTag(ns, ln, TRANSACTION)) {
                   transactionDepths.pop();
               }
   
  
  
  
  1.10      +8 -8      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlXmlTLV.java
  
  Index: JstlXmlTLV.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tlv/JstlXmlTLV.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JstlXmlTLV.java	8 Apr 2002 19:15:17 -0000	1.9
  +++ JstlXmlTLV.java	17 Apr 2002 17:59:23 -0000	1.10
  @@ -194,7 +194,7 @@
   	    // check invariants for <choose>
   	    if (chooseChild()) {
   		// ensure <choose> has the right children
  -		if(!isTag(qn, WHEN) && !isTag(qn, OTHERWISE)) {
  +		if(!isXmlTag(ns, ln, WHEN) && !isXmlTag(ns, ln, OTHERWISE)) {
   		    fail(Resources.getMessage("TLV_ILLEGAL_CHILD_TAG",
   			prefix, CHOOSE, qn));
   		}
  @@ -204,7 +204,7 @@
   		   fail(Resources.getMessage("TLV_ILLEGAL_ORDER",
   			qn, prefix, OTHERWISE, CHOOSE));
   		}
  -		if (isTag(qn, OTHERWISE)) {
  +		if (isXmlTag(ns, ln, OTHERWISE)) {
   		    chooseHasOtherwise.pop();
   		    chooseHasOtherwise.push(new Boolean(true));
   		}
  @@ -215,7 +215,7 @@
   	    if (!transformWithSource.empty() &&
   		    topDepth(transformWithSource) == (depth - 1)) {
   		// only allow <param>
  -		if (!isTag(qn, PARAM))
  +		if (!isXmlTag(ns, ln, PARAM))
   		    fail(Resources.getMessage("TLV_ILLEGAL_BODY",
   			prefix + ":" + TRANSFORM));
   
  @@ -226,7 +226,7 @@
   	    // now, modify state
   
   	    // we're a choose, so record new choose-specific state
  -	    if (isTag(qn, CHOOSE)) {
  +	    if (isXmlTag(ns, ln, CHOOSE)) {
   		chooseDepths.push(new Integer(depth));
   		chooseHasOtherwise.push(new Boolean(false));
   	    }
  @@ -234,15 +234,15 @@
   	    // set up a check against illegal attribute/body combinations
   	    bodyIllegal = false;
   	    bodyNecessary = false;
  -	    if (isTag(qn, PARSE)) {
  +	    if (isXmlTag(ns, ln, PARSE)) {
   		if (hasAttribute(a, SOURCE))
   		    bodyIllegal = true;
  -	    } else if (isTag(qn, PARAM)) {
  +	    } else if (isXmlTag(ns, ln, PARAM)) {
   		if (hasAttribute(a, VALUE))
   		    bodyIllegal = true;
   		else
   		    bodyNecessary = true;
  -	    } else if (isTag(qn, TRANSFORM)) {
  +	    } else if (isXmlTag(ns, ln, TRANSFORM)) {
   		if (hasAttribute(a, SOURCE))
   		    transformWithSource.push(new Integer(depth));
   	    }
  @@ -298,7 +298,7 @@
   	    bodyIllegal = false;	// reset: we've left the tag
   
   	    // update <choose>-related state
  -	    if (isTag(qn, CHOOSE)) {
  +	    if (isXmlTag(ns, ln, CHOOSE)) {
   		chooseDepths.pop();
   		chooseHasOtherwise.pop();
   	    }
  
  
  

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


Mime
View raw message