santiagopg    02/04/05 14:45:26

  Modified:    java/src/org/apache/xalan/xsltc/compiler Tag:
                        jaxp-ri-1_2_0-fcs-branch FunctionCall.java
  Log:
  Bugzilla 7721.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.12.4.1  +48 -27    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java
  
  Index: FunctionCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java,v
  retrieving revision 1.12
  retrieving revision 1.12.4.1
  diff -u -r1.12 -r1.12.4.1
  --- FunctionCall.java 1 Feb 2002 20:07:08 -0000       1.12
  +++ FunctionCall.java 5 Apr 2002 22:45:25 -0000       1.12.4.1
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: FunctionCall.java,v 1.12 2002/02/01 20:07:08 tmiller Exp $
  + * @(#)$Id: FunctionCall.java,v 1.12.4.1 2002/04/05 22:45:25 santiagopg Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -170,6 +170,7 @@
       public FunctionCall(QName fname, Vector arguments) {
        _fname = fname;
        _arguments = arguments;
  +     _type = null;
       }
   
       public FunctionCall(QName fname) {
  @@ -192,11 +193,27 @@
        }
       }
   
  +    public String getClassNameFromUri(String uri) 
  +     throws TypeCheckError
  +    {
  +     final int length = 
  +         uri.startsWith(JAVA_EXT_PREFIX) ? JAVA_EXT_PREFIX.length() + 1 :
  +         uri.startsWith(JAVA_EXT_XALAN) ? JAVA_EXT_XALAN.length() + 1 : 0;
  +
  +     if (length == 0) {
  +         throw new TypeCheckError(this);
  +     }
  +     return (uri.length() > length) ? uri.substring(length) : EMPTYSTRING;
  +    }
  +
       /**
        * Type check a function call. Since different type conversions apply,
        * type checking is different for standard and external (Java) functions.
        */
  -    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  +    public Type typeCheck(SymbolTable stable) 
  +     throws TypeCheckError 
  +    {
  +     if (_type != null) return _type;
   
        final String namespace = _fname.getNamespace();
        final String local = _fname.getLocalPart();
  @@ -207,33 +224,37 @@
        }
        // Handle extension functions (they all have a namespace)
        else {
  -         final int len = JAVA_EXT_PREFIX.length();
  -         if (namespace.equals(JAVA_EXT_PREFIX) ||
  -             namespace.equals(JAVA_EXT_XALAN)) {
  -             final int pos = local.indexOf('.');
  -             _className = local.substring(0, pos);
  -             _fname = new QName(namespace, null, local.substring(pos+1));
  -         }
  -         else if (namespace.length() >= len &&
  -             namespace.substring(0, len).equals(JAVA_EXT_PREFIX)) {
  -             _className = namespace.substring(len + 1);
  -         }
  -         else {
  -             /*
  -              * Warn user if external function could not be resolved.
  -              * Warning will _NOT_ be issued is the call is properly
  -              * wrapped in an <xsl:if> or <xsl:when> element. For details
  -              * see If.parserContents() and When.parserContents()
  -              */
  -             final Parser parser = getParser();
  -             if (parser != null) {
  -                 reportWarning(this, parser, ErrorMsg.FUNCTION_RESOLVE_ERR,
  -                               _fname.toString());
  +         try {
  +             _className = getClassNameFromUri(namespace);
  +
  +             final int pos = local.lastIndexOf('.');
  +             if (pos > 0) {
  +                 _className = _className + local.substring(0, pos);
  +                 _fname = new QName(namespace, null, local.substring(pos + 
1));
  +             }
  +             else {
  +                 _fname = new QName(namespace, null, local);
  +             }
  +             if (_className.length() > 0) {
  +                 return typeCheckExternal(stable);
                }
  -             unresolvedExternal = true;
  -             return _type = Type.Void;
  +         } catch (TypeCheckError e) {
  +             // Falls through
  +         }
  +
  +         /*
  +          * Warn user if external function could not be resolved.
  +          * Warning will _NOT_ be issued is the call is properly
  +          * wrapped in an <xsl:if> or <xsl:when> element. For details
  +          * see If.parserContents() and When.parserContents()
  +          */
  +         final Parser parser = getParser();
  +         if (parser != null) {
  +             reportWarning(this, parser, ErrorMsg.FUNCTION_RESOLVE_ERR,
  +                           _fname.toString());
            }
  -         return typeCheckExternal(stable);
  +         unresolvedExternal = true;
  +         return _type = Type.Void;
        }
       }
   
  
  
  

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

Reply via email to