kinman      2003/03/20 19:18:38

  Modified:    jasper2/src/share/org/apache/jasper/compiler Validator.java
  Log:
  - Locate the correct namesapce for the EL functions.
  
  Revision  Changes    Path
  1.93      +31 -22    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- Validator.java    21 Mar 2003 00:43:57 -0000      1.92
  +++ Validator.java    21 Mar 2003 03:18:38 -0000      1.93
  @@ -1168,17 +1168,23 @@
   
        private String findUri(String prefix, Node n) {
   
  -         Node p = n;
  -         while (p != null) {
  -             if (p instanceof Node.CustomTag) {
  -                 Node.CustomTag ct = (Node.CustomTag) p;
  -                 if (prefix.equals(ct.getPrefix())) {
  -                     return (ct.getURI());
  +         for (Node p = n; p != null; p = p.getParent()) {
  +             Attributes attrs = p.getXmlnsAttributes();
  +             if (attrs == null) {
  +                 continue;
  +             }
  +             for (int i = 0; i < attrs.getLength(); i++) {
  +                 String name = attrs.getQName(i);
  +                 int k = name.indexOf(':');
  +                 if (prefix == null && k < 0) {
  +                     // prefix not specified and a default ns found
  +                     return attrs.getValue(i);
  +                 }   
  +                 if (prefix != null && k >= 0 &&
  +                             prefix.equals(name.substring(k+1))) {
  +                     return attrs.getValue(i);
                    }
  -             } else if (p instanceof Node.JspRoot) {
  -                 // XXX find Uri from the root node
                }
  -             p = p.getParent();
            }
            return null;
        }
  @@ -1198,24 +1204,27 @@
                }
   
                public void visit(ELNode.Function func) throws JasperException {
  -                 String defaultNS = null;    // for now
                    String prefix = func.getPrefix();
                    String function = func.getName();
                    String uri = null;
  -                 if (prefix == null) {
  -                     // In XML syntax, use the default namespace
  -                     if (defaultNS == null) {
  -                         err.jspError(n, "jsp.error.noFunctionPrefix",
  -                                      function);
  -                     }
  -                     uri = defaultNS;
  -                 } else if (n.isXmlSyntax()) {
  +
  +                 if (n.isXmlSyntax()) {
                        uri = findUri(prefix, n);
  -                 } else {
  +                 } else if (prefix != null) {
                        Hashtable prefixMapper = pageInfo.getPrefixMapper();
                        uri = (String) prefixMapper.get(prefix);
                    }
   
  +                 if (uri == null) {
  +                     if (prefix == null) {
  +                         err.jspError(n, "jsp.error.noFunctionPrefix",
  +                             function);
  +                     }
  +                     else {
  +                         err.jspError(n,
  +                             "jsp.error.attribute.invalidPrefix", prefix);
  +                     }
  +                 }
                    TagLibraryInfo taglib = 
                                        (TagLibraryInfo) taglibs.get(uri);
                    FunctionInfo funcInfo = null;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to