zongaro     2002/09/18 06:31:55

  Modified:    java/src Tag: XSLTC_DTM xml-commons-src.tar.gz
               java/src/org/apache/xalan/lib Tag: XSLTC_DTM Extensions.java
               java/src/org/apache/xalan/processor Tag: XSLTC_DTM
                        XSLTSchema.java
               java/src/org/apache/xalan/xsltc Tag: XSLTC_DTM DOM.java
               java/src/org/apache/xalan/xsltc/cmdline Tag: XSLTC_DTM
                        Transform.java
               java/src/org/apache/xalan/xsltc/compiler Tag: XSLTC_DTM
                        CastExpr.java Constants.java FunctionCall.java
                        Parser.java SyntaxTreeNode.java TransletOutput.java
                        xpath.cup
               java/src/org/apache/xalan/xsltc/compiler/util Tag: XSLTC_DTM
                        BooleanType.java IntType.java NodeSetType.java
                        NodeType.java RealType.java ResultTreeType.java
                        StringType.java
               java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
                        AbsoluteIterator.java DOMAdapter.java DOMImpl.java
                        MultiDOM.java SAXImpl.java
               java/src/org/apache/xalan/xsltc/runtime Tag: XSLTC_DTM
                        AbstractTranslet.java BasisLibrary.java
               java/src/org/apache/xpath/objects Tag: XSLTC_DTM
                        XRTreeFrag.java
  Log:
  Folding changes from MAIN branch back into this branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.6.1   +634 -603  xml-xalan/java/src/xml-commons-src.tar.gz
  
        <<Binary file>>
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.17.2.4  +24 -9     xml-xalan/java/src/org/apache/xalan/lib/Extensions.java
  
  Index: Extensions.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Extensions.java,v
  retrieving revision 1.17.2.3
  retrieving revision 1.17.2.4
  diff -u -r1.17.2.3 -r1.17.2.4
  --- Extensions.java   12 Sep 2002 16:07:31 -0000      1.17.2.3
  +++ Extensions.java   18 Sep 2002 13:31:51 -0000      1.17.2.4
  @@ -70,6 +70,7 @@
   import org.xml.sax.SAXNotSupportedException;
   
   import java.util.Hashtable;
  +import java.util.StringTokenizer;
   
   import org.apache.xalan.extensions.ExpressionContext;
   import org.apache.xalan.res.XSLMessages;
  @@ -91,6 +92,9 @@
   public class Extensions
   {
   
  +  // Reuse the Document object to reduce memory usage.
  +  private static Document lDoc = null;
  +  
     /**
      * Constructor Extensions
      *
  @@ -282,14 +286,29 @@
      * @param toTokenize The string to be split into text tokens.
      * @param delims The delimiters to use.
      * @return a NodeSet as described above.
  -   *
  -   * Note: The usage of this extension function in the xalan namespace 
  -   * is deprecated. Please use the same function in the EXSLT strings 
extension
  -   * (http://exslt.org/strings).
      */
     public static NodeList tokenize(String toTokenize, String delims)
     {
  -    return ExsltStrings.tokenize(toTokenize, delims);
  +
  +    try
  +    {
  +      if (lDoc == null)
  +        lDoc = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  +    }
  +    catch(ParserConfigurationException pce)
  +    {
  +      throw new org.apache.xml.utils.WrappedRuntimeException(pce);
  +    }
  +
  +    StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
  +    NodeSet resultSet = new NodeSet();
  +
  +    while (lTokenizer.hasMoreTokens())
  +    {
  +      resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
  +    }
  +
  +    return resultSet;
     }
   
     /**
  @@ -306,10 +325,6 @@
      *                  extension mechanism.  This must be an XPathContext.
      * @param toTokenize The string to be split into text tokens.
      * @return a NodeSet as described above.
  -   *
  -   * Note: The usage of this extension function in the xalan namespace 
  -   * is deprecated. Please use the same function in the EXSLT strings 
extension
  -   * (http://exslt.org/strings).
      */
     public static NodeList tokenize(String toTokenize)
     {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.23.10.2 +5 -4      
xml-xalan/java/src/org/apache/xalan/processor/XSLTSchema.java
  
  Index: XSLTSchema.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/XSLTSchema.java,v
  retrieving revision 1.23.10.1
  retrieving revision 1.23.10.2
  diff -u -r1.23.10.1 -r1.23.10.2
  --- XSLTSchema.java   29 Jul 2002 00:01:18 -0000      1.23.10.1
  +++ XSLTSchema.java   18 Sep 2002 13:31:52 -0000      1.23.10.2
  @@ -348,11 +348,11 @@
         new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL, "*",
                              XSLTAttributeDef.T_CDATA, false, 
false,XSLTAttributeDef.WARNING);
                              
  -    XSLTElementDef[] templateElements = new XSLTElementDef[22];
  -    XSLTElementDef[] templateElementsAndParams = new XSLTElementDef[23];
  -    XSLTElementDef[] templateElementsAndSort = new XSLTElementDef[23];
  +    XSLTElementDef[] templateElements = new XSLTElementDef[23];
  +    XSLTElementDef[] templateElementsAndParams = new XSLTElementDef[24];
  +    XSLTElementDef[] templateElementsAndSort = new XSLTElementDef[24];
       //exslt
  -    XSLTElementDef[] exsltFunctionElements = new XSLTElementDef[23];
  +    XSLTElementDef[] exsltFunctionElements = new XSLTElementDef[24];
       
       XSLTElementDef[] charTemplateElements = new XSLTElementDef[15];
       XSLTElementDef resultElement = new XSLTElementDef(this, null, "*",
  @@ -617,6 +617,7 @@
       templateElements[i++] = xslAttribute;
       templateElements[i++] = resultElement;
       templateElements[i++] = unknownElement;
  +    templateElements[i++] = exsltFunction;
       templateElements[i++] = exsltResult;
   
       int k;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.9.10.4  +1 -1      xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java
  
  Index: DOM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/DOM.java,v
  retrieving revision 1.9.10.3
  retrieving revision 1.9.10.4
  diff -u -r1.9.10.3 -r1.9.10.4
  --- DOM.java  24 Aug 2002 11:33:23 -0000      1.9.10.3
  +++ DOM.java  18 Sep 2002 13:31:52 -0000      1.9.10.4
  @@ -130,7 +130,7 @@
        throws TransletException;
       public int getNodeIdent(final int nodehandle);
       public int getNodeHandle(final int nodeId);
  -    public DOM getResultTreeFrag();
  +    public DOM getResultTreeFrag(int initialSize);
       public TransletOutputHandler getOutputDomBuilder();
       public int getNSType(int node);
       public int getDocument();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.15.10.5 +2 -21     
xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java
  
  Index: Transform.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java,v
  retrieving revision 1.15.10.4
  retrieving revision 1.15.10.5
  diff -u -r1.15.10.4 -r1.15.10.5
  --- Transform.java    12 Sep 2002 16:07:33 -0000      1.15.10.4
  +++ Transform.java    18 Sep 2002 13:31:52 -0000      1.15.10.5
  @@ -296,9 +296,7 @@
                boolean uri = false, debug = false;
                boolean isJarFileSpecified = false;
                String  jarFile = null;
  -             boolean doDiag = false;
  -             long start=0;
  -             long stop=0;
  +
                // Parse options starting with '-'
                for (i = 0; i < args.length && args[i].charAt(0) == '-'; i++) {
                    if (args[i].equals("-u")) {
  @@ -325,9 +323,6 @@
                            // ignore
                        }
                    }
  -                 else if ("-DIAG".equalsIgnoreCase(args[i])){
  -                     doDiag = true;
  -                 }
                    else {
                        printUsage();
                    }
  @@ -357,21 +352,7 @@
   
                if (i == args.length) {
                    handler.setParameters(params);
  -                 if (doDiag) {
  -                     start = System.currentTimeMillis();
  -                 }
                    handler.doTransform();
  -                 if (doDiag) {
  -                     stop = System.currentTimeMillis();
  -                     long millisecondsDuration = stop - start;
  -                     String msg = "--------- Transform of "
  -                                   + handler.getFileName() + " via "
  -                                   + handler.getClassName() + " took "
  -                                   + millisecondsDuration + " ms"; 
  -                     java.io.PrintWriter diagnosticsWriter =
  -                                              new PrintWriter(System.err, 
true);
  -                     diagnosticsWriter.println(msg);
  -                 }
                    if (_allowExit) System.exit(0);
                }
            } else {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.6.3  +5 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java
  
  Index: CastExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java,v
  retrieving revision 1.10.6.2
  retrieving revision 1.10.6.3
  diff -u -r1.10.6.2 -r1.10.6.3
  --- CastExpr.java     1 Aug 2002 19:55:30 -0000       1.10.6.2
  +++ CastExpr.java     18 Sep 2002 13:31:52 -0000      1.10.6.3
  @@ -85,23 +85,27 @@
        InternalTypeMap.put(Type.Boolean, Type.Real);
        InternalTypeMap.put(Type.Boolean, Type.String);
        InternalTypeMap.put(Type.Boolean, Type.Reference);
  +        InternalTypeMap.put(Type.Boolean, Type.Object);
   
        InternalTypeMap.put(Type.Real, Type.Real);
        InternalTypeMap.put(Type.Real, Type.Int);
        InternalTypeMap.put(Type.Real, Type.Boolean);
        InternalTypeMap.put(Type.Real, Type.String);
        InternalTypeMap.put(Type.Real, Type.Reference);
  +        InternalTypeMap.put(Type.Real, Type.Object);
   
        InternalTypeMap.put(Type.Int, Type.Int);
        InternalTypeMap.put(Type.Int, Type.Real);
        InternalTypeMap.put(Type.Int, Type.Boolean);
        InternalTypeMap.put(Type.Int, Type.String);
        InternalTypeMap.put(Type.Int, Type.Reference);
  +        InternalTypeMap.put(Type.Int, Type.Object);
   
        InternalTypeMap.put(Type.String, Type.String);
        InternalTypeMap.put(Type.String, Type.Boolean);
        InternalTypeMap.put(Type.String, Type.Real);
        InternalTypeMap.put(Type.String, Type.Reference);
  +        InternalTypeMap.put(Type.String, Type.Object);
   
        InternalTypeMap.put(Type.NodeSet, Type.NodeSet);
        InternalTypeMap.put(Type.NodeSet, Type.Boolean);
  
  
  
  1.19.2.5  +5 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
  retrieving revision 1.19.2.4
  retrieving revision 1.19.2.5
  diff -u -r1.19.2.4 -r1.19.2.5
  --- Constants.java    12 Sep 2002 16:07:33 -0000      1.19.2.4
  +++ Constants.java    18 Sep 2002 13:31:52 -0000      1.19.2.5
  @@ -489,6 +489,10 @@
        = "http://www.w3.org/1999/xhtml";;
       public static final String TRANSLET_URI
        = "http://xml.apache.org/xalan/xsltc";;
  +    public static final String REDIRECT_URI
  +        = "http://xml.apache.org/xalan/redirect";;
       public static final String FALLBACK_CLASS
        = "org.apache.xalan.xsltc.compiler.Fallback";
  +
  +    public static final int RTF_INITIAL_SIZE = 64;
   }
  
  
  
  1.14.2.3  +365 -179  
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.14.2.2
  retrieving revision 1.14.2.3
  diff -u -r1.14.2.2 -r1.14.2.3
  --- FunctionCall.java 1 Aug 2002 19:55:30 -0000       1.14.2.2
  +++ FunctionCall.java 18 Sep 2002 13:31:52 -0000      1.14.2.3
  @@ -107,8 +107,35 @@
        "http://xml.apache.org/xalan";;
   
       protected final static String JAVA_EXT_XALAN =
  +     "http://xml.apache.org/xalan/java";;
  +
  +    protected final static String JAVA_EXT_XALAN_OLD =
        "http://xml.apache.org/xslt/java";;
  +     
  +    protected final static String EXSLT_COMMON =
  +     "http://exslt.org/common";;
  +
  +    protected final static String EXSLT_MATH =
  +     "http://exslt.org/math";;
  +     
  +    protected final static String EXSLT_SETS =
  +     "http://exslt.org/sets";;
  +
  +    protected final static String EXSLT_DATETIME =
  +     "http://exslt.org/dates-and-times";;
   
  +    protected final static String EXSLT_STRINGS =
  +     "http://exslt.org/strings";;
  +     
  +    // Namespace format constants
  +    protected final static int NAMESPACE_FORMAT_JAVA = 0;
  +    protected final static int NAMESPACE_FORMAT_CLASS = 1;
  +    protected final static int NAMESPACE_FORMAT_PACKAGE = 2;
  +    protected final static int NAMESPACE_FORMAT_CLASS_OR_PACKAGE = 3;
  +     
  +    // Namespace format
  +    private int _namespace_format = NAMESPACE_FORMAT_JAVA;
  +        
       /**
        * Stores reference to object for non-static Java calls
        */
  @@ -116,6 +143,7 @@
   
       // External Java function's class/method/signature
       private String      _className;
  +    private Class       _clazz;
       private Method      _chosenMethod;
       private Constructor _chosenConstructor;
       private MethodType  _chosenMethodType;
  @@ -126,12 +154,20 @@
       // If FunctionCall is a external java constructor 
       private boolean     _isExtConstructor = false; 
   
  +    // If the java method is static
  +    private boolean    _isStatic = false;
  +
       // Legal conversions between internal and Java types.
       private static final MultiHashtable _internal2Java = new 
MultiHashtable();
   
       // Legal conversions between Java and internal types.
       private static final Hashtable _java2Internal = new Hashtable();
  +    
  +    // The mappings between EXSLT extension namespaces and implementation 
classes
  +    private static final Hashtable _extensionNamespaceTable = new 
Hashtable();
   
  +    // Extension functions that are implemented in BasisLibrary
  +    private static final Hashtable _extensionFunctionTable = new Hashtable();
       /**
        * inner class to used in internal2Java mappings, contains
        * the Java type and the distance between the internal type and
  @@ -165,42 +201,54 @@
            final Class nodeListClass = Class.forName("org.w3c.dom.NodeList");
   
            // Possible conversions between internal and Java types
  +         _internal2Java.put(Type.Boolean, new JavaType(objectClass,2));
  +         _internal2Java.put(Type.Boolean, new 
JavaType(java.lang.Boolean.class,1));
            _internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE,0));
   
  -         _internal2Java.put(Type.Int, new JavaType(Character.TYPE, 6)); 
  -         _internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 5));
  -         _internal2Java.put(Type.Int, new JavaType(Short.TYPE, 4));
  +         _internal2Java.put(Type.Int, new JavaType(objectClass, 8));
  +         _internal2Java.put(Type.Int, new JavaType(Character.TYPE, 7));
  +         _internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 6));
  +         _internal2Java.put(Type.Int, new JavaType(Short.TYPE, 5));
            _internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 0));
  -         _internal2Java.put(Type.Int, new JavaType(Long.TYPE, 1));
  -         _internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2));
  -         _internal2Java.put(Type.Int, new JavaType(Double.TYPE, 3));
  -
  -         _internal2Java.put(Type.Real, new JavaType(Character.TYPE, 6)); 
  -         _internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 5));
  -         _internal2Java.put(Type.Real, new JavaType(Short.TYPE, 4));
  -         _internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 3));
  -         _internal2Java.put(Type.Real, new JavaType(Long.TYPE, 2));
  -         _internal2Java.put(Type.Real, new JavaType(Float.TYPE, 1));
  +         _internal2Java.put(Type.Int, new JavaType(java.lang.Integer.class, 
1));
  +         _internal2Java.put(Type.Int, new JavaType(Long.TYPE, 2));
  +         _internal2Java.put(Type.Int, new JavaType(Float.TYPE, 3));
  +         _internal2Java.put(Type.Int, new JavaType(Double.TYPE, 4));
  +
  +         _internal2Java.put(Type.Real, new JavaType(objectClass, 8));
  +         _internal2Java.put(Type.Real, new JavaType(Character.TYPE, 7)); 
  +         _internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 6));
  +         _internal2Java.put(Type.Real, new JavaType(Short.TYPE, 5));
  +         _internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 4));
  +         _internal2Java.put(Type.Real, new JavaType(Long.TYPE, 3));
  +         _internal2Java.put(Type.Real, new JavaType(Float.TYPE, 2));
  +         _internal2Java.put(Type.Real, new JavaType(java.lang.Double.class, 
1));
            _internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0));
   
  +         _internal2Java.put(Type.String, new JavaType(objectClass, 1));
            _internal2Java.put(Type.String, new JavaType(stringClass, 0)); 
   
            _internal2Java.put(Type.Node, new JavaType(nodeClass, 0));  
            _internal2Java.put(Type.Node, new JavaType(nodeListClass, 1));
  +         _internal2Java.put(Type.Node, new JavaType(objectClass, 2));
  +         _internal2Java.put(Type.Node, new JavaType(stringClass, 3));
   
  -         _internal2Java.put(Type.NodeSet, new JavaType(Integer.TYPE, 10)); 
  +         _internal2Java.put(Type.NodeSet, new JavaType(Integer.TYPE, 10));
  +         _internal2Java.put(Type.NodeSet, new JavaType(stringClass, 3)); 
  +         _internal2Java.put(Type.NodeSet, new JavaType(objectClass, 2));
            _internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1)); 
            _internal2Java.put(Type.NodeSet, new JavaType(nodeListClass,0)); 
   
            _internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1)); 
            _internal2Java.put(Type.ResultTree, new JavaType(nodeListClass,0));
            _internal2Java.put(Type.ResultTree, new JavaType(objectClass,2));
  +         _internal2Java.put(Type.ResultTree, new JavaType(stringClass,3));
   
            _internal2Java.put(Type.Reference, new JavaType(objectClass,0));
   
            // Possible conversions between Java and internal types
            _java2Internal.put(Boolean.TYPE, Type.Boolean); 
  -
  +         _java2Internal.put(Void.TYPE, Type.Void);
            _java2Internal.put(Character.TYPE, Type.Real); 
            _java2Internal.put(Byte.TYPE, Type.Real);
            _java2Internal.put(Short.TYPE, Type.Real);
  @@ -216,6 +264,18 @@
            // Conversions from org.w3c.dom.Node/NodeList are not supported
            // GTM
            _java2Internal.put(nodeListClass, Type.NodeSet);
  +         
  +         // Initialize the extension namespace table
  +         _extensionNamespaceTable.put(EXT_XALAN, 
"org.apache.xalan.lib.Extensions");
  +         _extensionNamespaceTable.put(EXSLT_MATH, 
"org.apache.xalan.lib.ExsltMath");
  +         _extensionNamespaceTable.put(EXSLT_SETS, 
"org.apache.xalan.lib.ExsltSets");
  +         _extensionNamespaceTable.put(EXSLT_DATETIME, 
"org.apache.xalan.lib.ExsltDatetime");
  +         _extensionNamespaceTable.put(EXSLT_STRINGS, 
"org.apache.xalan.lib.ExsltStrings");
  +         
  +         // Initialize the extension function table
  +         _extensionFunctionTable.put(EXSLT_COMMON + ":nodeSet", "nodeset");
  +         _extensionFunctionTable.put(EXSLT_COMMON + ":objectType", 
"objectType");        
  +         _extensionFunctionTable.put(EXT_XALAN + ":nodeset", "nodeset");
        }
        catch (ClassNotFoundException e) {
            System.err.println(e);
  @@ -251,14 +311,34 @@
       public String getClassNameFromUri(String uri) 
        throws TypeCheckError
       {
  -     final int length = 
  -         uri.startsWith(JAVA_EXT_XSLTC) ? JAVA_EXT_XSLTC.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;
  +    
  +        String className = (String)_extensionNamespaceTable.get(uri);
  +    
  +        if (className != null)
  +          return className;
  +        else
  +        {
  +          if (uri.startsWith(JAVA_EXT_XSLTC))
  +          {
  +                 int length = JAVA_EXT_XSLTC.length() + 1;
  +            return (uri.length() > length) ? uri.substring(length) : 
EMPTYSTRING;
  +          }
  +          else if (uri.startsWith(JAVA_EXT_XALAN))
  +          {
  +                 int length = JAVA_EXT_XALAN.length() + 1;
  +            return (uri.length() > length) ? uri.substring(length) : 
EMPTYSTRING;
  +          }
  +          else if (uri.startsWith(JAVA_EXT_XALAN_OLD))
  +          {
  +                 int length = JAVA_EXT_XALAN_OLD.length() + 1;
  +            return (uri.length() > length) ? uri.substring(length) : 
EMPTYSTRING;
  +          }
  +          else
  +          {
  +                 int index = uri.lastIndexOf('/');
  +                 return (index > 0) ? uri.substring(index+1) : uri;
  +          }      
  +        }
       }
   
       /**
  @@ -268,45 +348,87 @@
       public Type typeCheck(SymbolTable stable) 
        throws TypeCheckError 
       {
  -     if (_type != null) return _type;
  +       if (_type != null) return _type;
   
  -     final String namespace = _fname.getNamespace();
  -     final String local = _fname.getLocalPart();
  +       final String namespace = _fname.getNamespace();
  +       String local = _fname.getLocalPart();
   
  -     if (isExtension()) {
  +       if (isExtension()) {
            _fname = new QName(null, null, local);
            return typeCheckStandard(stable);
  -     }
  -     else if (isStandard()) {
  +       }
  +       else if (isStandard()) {
            return typeCheckStandard(stable);
  -     }
  -     // Handle extension functions (they all have a namespace)
  -     else {
  -         try {
  -             // GTM: namespace = http://xml.apache.org/xslt/java
  -             _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);
  +       }
  +       // Handle extension functions (they all have a namespace)
  +       else 
  +       {
  +         try 
  +            {
  +             _className = getClassNameFromUri(namespace);
  +               
  +                final int pos = local.lastIndexOf('.');
  +             if (pos > 0) 
  +                {
  +               _isStatic = true;
  +               if (_className != null && _className.length() > 0)
  +               {
  +                  _namespace_format = NAMESPACE_FORMAT_PACKAGE;
  +                  _className = _className + "." + local.substring(0, pos);
  +               }
  +               else
  +               {
  +                  _namespace_format = NAMESPACE_FORMAT_JAVA;
  +                  _className = local.substring(0, pos);
  +               }
  +                       
  +               _fname = new QName(namespace, null, local.substring(pos + 1));
  +             }
  +             else 
  +             {
  +               if (_className != null && _className.length() > 0)
  +               {
  +                 try 
  +                    {                                
  +                   TransletLoader loader = new TransletLoader();
  +                   _clazz = loader.loadClass(_className);                    
        
  +                   _namespace_format = NAMESPACE_FORMAT_CLASS;
  +                 }
  +                 catch (ClassNotFoundException e)
  +                 {
  +                   _namespace_format = NAMESPACE_FORMAT_PACKAGE;     
  +                 }
  +               }
  +               else
  +                 _namespace_format = NAMESPACE_FORMAT_JAVA;
  +                     
  +               if (local.indexOf('-') > 0)
  +               {
  +                 local = replaceDash(local);
  +               }
  +                 
  +               String extFunction = 
(String)_extensionFunctionTable.get(namespace + ":" + local);
  +               if (extFunction != null) {
  +                  _fname = new QName(null, null, extFunction);
  +                  return typeCheckStandard(stable);
  +               }
  +               else
  +                  _fname = new QName(namespace, null, local);
                }
  +               
                return typeCheckExternal(stable);
            } 
  -         catch (TypeCheckError e) {
  -             ErrorMsg errorMsg = e.getErrorMsg();
  -             if (errorMsg == null) {
  +         catch (TypeCheckError e) 
  +         {
  +               ErrorMsg errorMsg = e.getErrorMsg();
  +               if (errorMsg == null) {
                    final String name = _fname.getLocalPart();
                    errorMsg = new ErrorMsg(ErrorMsg.METHOD_NOT_FOUND_ERR, 
name);
  -             }
  -             getParser().reportError(ERROR, errorMsg);
  -             return _type = Type.Void;
  +               }
  +               getParser().reportError(ERROR, errorMsg);
  +               return _type = Type.Void;
            }
  -     }
  +       }
       }
   
       /**
  @@ -387,7 +509,11 @@
                _chosenConstructor = constructor;
                _isExtConstructor = true;
                bestConstrDistance = currConstrDistance;
  -             _type = new ObjectType(_className);
  +             
  +             if (_clazz != null)
  +               _type = new ObjectType(_clazz);
  +             else
  +               _type = new ObjectType(_className);
            }
        }
   
  @@ -395,16 +521,7 @@
            return _type;
        }
   
  -     final StringBuffer buf = new StringBuffer(_className);
  -     buf.append('.').append(_fname.getLocalPart()).append('(');
  -     for (int i = 0; i < nArgs; i++) {
  -         final Type intType = (Type)argsType.elementAt(i);
  -         buf.append(intType.toString());
  -         if (i < nArgs - 1) buf.append(", ");
  -     }
  -     buf.append(')');
  -     throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, 
  -         buf.toString());
  +     throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, 
getMethodSignature(argsType));
       }
   
   
  @@ -418,23 +535,46 @@
       public Type typeCheckExternal(SymbolTable stable) throws TypeCheckError {
        int nArgs = _arguments.size();
        final String name = _fname.getLocalPart();
  -
  +    
  +     // check if function is a contructor 'new'
  +     if (_fname.getLocalPart().equals("new")) {
  +         return typeCheckConstructor(stable);
  +     }
        // check if we are calling an instance method
  -     if (_className.length() == 0) {
  -         if (nArgs > 0) {
  -             _thisArgument = (Expression) _arguments.elementAt(0);
  -             _arguments.remove(0); nArgs--;  
  -             Type type = _thisArgument.typeCheck(stable);    
  -             if (type instanceof ObjectType) {
  -                 _className = ((ObjectType) type).getJavaClassName();
  -             }
  -             else {
  -                 // TODO: define a new error message
  -                    throw new 
TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, 
  -                     name);
  -             }
  -            }
  -            else {
  +     else
  +     {
  +       boolean hasThisArgument = false;
  +       
  +       if (nArgs == 0)
  +         _isStatic = true;
  +       
  +       if (!_isStatic)
  +       {
  +             if (_namespace_format == NAMESPACE_FORMAT_JAVA ||
  +                 _namespace_format == NAMESPACE_FORMAT_PACKAGE)
  +               hasThisArgument = true;
  +               
  +             Expression firstArg = (Expression)_arguments.elementAt(0);
  +             Type firstArgType = (Type)firstArg.typeCheck(stable);
  +             
  +             if (_namespace_format == NAMESPACE_FORMAT_CLASS &&
  +                 firstArgType instanceof ObjectType && 
  +                 
((ObjectType)firstArgType).getJavaClassName().equals(_className))
  +               hasThisArgument = true;
  +             
  +             if (hasThisArgument)
  +             {
  +               _thisArgument = (Expression) _arguments.elementAt(0);
  +               _arguments.remove(0); nArgs--;
  +               if (firstArgType instanceof ObjectType) {
  +                 _className = ((ObjectType) firstArgType).getJavaClassName();
  +               }
  +               else
  +                throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, 
name);             
  +             }
  +       }
  +       else if (_className.length() == 0)
  +       {
                /*
                 * Warn user if external function could not be resolved.
                 * Warning will _NOT_ be issued is the call is properly
  @@ -448,18 +588,14 @@
                }
                unresolvedExternal = true;
                return _type = Type.Int;        // use "Int" as "unknown"
  -            }             
  +       }
        }
  -     // check if function is a contructor 'new'
  -     else if (_fname.getLocalPart().equals("new")) {
  -         return typeCheckConstructor(stable);
  -     }
  -
  +     
        final Vector methods = findMethods();
        
        if (methods == null) {
            // Method not found in this class
  -         throw new TypeCheckError(ErrorMsg.METHOD_NOT_FOUND_ERR, name);
  +         throw new TypeCheckError(ErrorMsg.METHOD_NOT_FOUND_ERR, _className 
+ "." + name);
        }
   
        Class extType = null;
  @@ -487,42 +623,59 @@
                }
                else {
                    // no mapping available
  -                 currMethodDistance = Integer.MAX_VALUE;
  -                 break;
  +                 if (intType instanceof ObjectType)
  +                 {
  +                   ObjectType object = (ObjectType)intType;
  +                   if (extType.getName().equals(object.getJavaClassName()))
  +                     currMethodDistance += 0;
  +                   else if (extType.isAssignableFrom(object.getJavaClass()))
  +                     currMethodDistance += 1;
  +                   else
  +                   {
  +                     currMethodDistance = Integer.MAX_VALUE;
  +                     break;
  +                   }
  +                 }
  +                 else
  +                 {
  +                   currMethodDistance = Integer.MAX_VALUE;
  +                   break;
  +                 }
                }
            }
   
            if (j == nArgs) {
  -             // Check if the return type can be converted
  -             extType = method.getReturnType();
  -             _type = extType.getName().equals("void") ? Type.Void
  -                 : (Type) _java2Internal.get(extType);
  +               // Check if the return type can be converted
  +               extType = method.getReturnType();
  +             
  +               _type = (Type) _java2Internal.get(extType);
  +               if (_type == null) {
  +                 _type = new ObjectType(extType);
  +               }             
   
  -             // Use this method if all parameters & return type match
  -             if (_type != null && currMethodDistance < bestMethodDistance) {
  +               // Use this method if all parameters & return type match
  +               if (_type != null && currMethodDistance < bestMethodDistance) 
{
                    _chosenMethod = method;
                    bestMethodDistance = currMethodDistance;
  -             }
  +               }
            }
        }
  +     
  +     // It is an error if the chosen method is an instance menthod but we 
don't
  +     // have a this argument.
  +     if (_chosenMethod != null && _thisArgument == null &&
  +         !Modifier.isStatic(_chosenMethod.getModifiers())) {
  +       throw new TypeCheckError(ErrorMsg.NO_JAVA_FUNCT_THIS_REF, 
getMethodSignature(argsType));
  +     }
   
        if (_type != null) {
  -         if (_type == Type.NodeSet){
  -                getXSLTC().setMultiDocument(true);
  -            }
  -         return _type;
  +       if (_type == Type.NodeSet) {
  +           getXSLTC().setMultiDocument(true);
  +          }
  +       return _type;
        }
   
  -     final StringBuffer buf = new StringBuffer(_className);
  -     buf.append('.').append(_fname.getLocalPart()).append('(');
  -     for (int i = 0; i < nArgs; i++) {
  -         final Type intType = (Type)argsType.elementAt(i);
  -         buf.append(intType.toString());
  -         if (i < nArgs - 1) buf.append(", ");
  -     }
  -     buf.append(')');
  -     throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, 
  -         buf.toString());
  +     throw new TypeCheckError(ErrorMsg.ARGUMENT_CONVERSION_ERR, 
getMethodSignature(argsType));
       }
   
       /**
  @@ -666,7 +819,7 @@
            // Push "this" if it is an instance method
            if (_thisArgument != null) {
                _thisArgument.translate(classGen, methodGen);
  -         }
  +         }       
   
            for (int i = 0; i < n; i++) {
                final Expression exp = argument(i);
  @@ -687,10 +840,9 @@
            index = cpg.addMethodref(clazz,
                                     _fname.getLocalPart(),
                                     buffer.toString());
  -         il.append(_thisArgument != null ?
  -             (InvokeInstruction) new INVOKEVIRTUAL(index) : 
  -                (InvokeInstruction) new INVOKESTATIC(index));
  -
  +         il.append(_thisArgument != null ? (InvokeInstruction) new 
INVOKEVIRTUAL(index) :
  +                       (InvokeInstruction) new INVOKESTATIC(index));
  + 
            // Convert the return type back to our internal type
            _type.translateFrom(classGen, methodGen,
                                _chosenMethod.getReturnType());
  @@ -708,8 +860,7 @@
   
       public boolean isExtension() {
        final String namespace = _fname.getNamespace();
  -     return (namespace != null) && (namespace.equals(EXT_XSLTC) 
  -         || namespace.equals(EXT_XALAN));
  +     return (namespace != null) && (namespace.equals(EXT_XSLTC));
       }
   
       /**
  @@ -718,47 +869,47 @@
        * if no such methods exist.
        */
       private Vector findMethods() {
  -     Vector result = null;
  -     final String namespace = _fname.getNamespace();
  +       
  +       Vector result = null;
  +       final String namespace = _fname.getNamespace();
   
  -     if (namespace.startsWith(JAVA_EXT_XSLTC) ||
  -         namespace.startsWith(JAVA_EXT_XALAN)) {
  +       if (_className != null && _className.length() > 0) {
            final int nArgs = _arguments.size();
            try {
  +           if (_clazz == null) {
                TransletLoader loader = new TransletLoader();
  -             final Class clazz = loader.loadClass(_className);
  -
  -             if (clazz == null) {
  -                 final ErrorMsg msg =
  -                     new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className);
  -                 getParser().reportError(Constants.ERROR, msg);
  -             }
  -             else {
  -                 final String methodName = _fname.getLocalPart();
  -                 final Method[] methods = clazz.getDeclaredMethods();
  -
  -                 for (int i = 0; i < methods.length; i++) {
  -                     final int mods = methods[i].getModifiers();
  -                     // Is it public and same number of args ?
  -                     if (Modifier.isPublic(mods)
  -                         && methods[i].getName().equals(methodName)
  -                         && methods[i].getParameterTypes().length == nArgs)
  -                         {
  -                             if (result == null) {
  -                                 result = new Vector();
  -                             }
  -                             result.addElement(methods[i]);
  -                         }
  -                 }
  +             _clazz = loader.loadClass(_className);
  +             
  +             if (_clazz == null) {
  +               final ErrorMsg msg =
  +                     new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className);
  +               getParser().reportError(Constants.ERROR, msg);
  +             }
  +           }
  +
  +           final String methodName = _fname.getLocalPart();
  +           final Method[] methods = _clazz.getMethods();
  +
  +           for (int i = 0; i < methods.length; i++) {
  +             final int mods = methods[i].getModifiers();
  +             // Is it public and same number of args ?
  +             if (Modifier.isPublic(mods)
  +                 && methods[i].getName().equals(methodName)
  +                 && methods[i].getParameterTypes().length == nArgs)
  +             {
  +               if (result == null) {
  +                 result = new Vector();
  +               }
  +               result.addElement(methods[i]);
                }
  +           }
            }
            catch (ClassNotFoundException e) {
  -             final ErrorMsg msg =
  -                 new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className);
  -             getParser().reportError(Constants.ERROR, msg);
  +               final ErrorMsg msg = new 
ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className);
  +               getParser().reportError(Constants.ERROR, msg);
            }
  -     }
  -     return result;
  +       }
  +       return result;
       }
   
       /**
  @@ -770,41 +921,38 @@
           Vector result = null;
           final String namespace = _fname.getNamespace();
   
  -        if (namespace.startsWith(JAVA_EXT_XSLTC) ||
  -            namespace.startsWith(JAVA_EXT_XALAN)) {
  -            final int nArgs = _arguments.size();
  -            try {
  -                TransletLoader loader = new TransletLoader();
  -                final Class clazz = loader.loadClass(_className);
  -
  -                if (clazz == null) {
  -                    final ErrorMsg msg =
  -                        new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, 
_className);
  -                    getParser().reportError(Constants.ERROR, msg);
  +        final int nArgs = _arguments.size();
  +        try {
  +          if (_clazz == null) {
  +            TransletLoader loader = new TransletLoader();
  +            _clazz = loader.loadClass(_className);
  +          
  +            if (_clazz == null) {
  +              final ErrorMsg msg = new 
ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className);
  +              getParser().reportError(Constants.ERROR, msg);
  +            }          
  +          }
  +
  +          final Constructor[] constructors = _clazz.getConstructors();
  +
  +          for (int i = 0; i < constructors.length; i++) {
  +              final int mods = constructors[i].getModifiers();
  +              // Is it public, static and same number of args ?
  +              if (Modifier.isPublic(mods) &&
  +                  constructors[i].getParameterTypes().length == nArgs)
  +              {
  +                if (result == null) {
  +                  result = new Vector();
                   }
  -                else {
  -                    final Constructor[] constructors = 
clazz.getConstructors();
  -
  -                    for (int i = 0; i < constructors.length; i++) {
  -                        final int mods = constructors[i].getModifiers();
  -                        // Is it public, static and same number of args ?
  -                        if (Modifier.isPublic(mods) &&
  -                           constructors[i].getParameterTypes().length == 
nArgs)
  -                        {
  -                            if (result == null) {
  -                                result = new Vector();
  -                            }
  -                            result.addElement(constructors[i]);
  -                        }
  -                    }
  -                }
  -            }
  -            catch (ClassNotFoundException e) {
  -                final ErrorMsg msg =
  -                    new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className);
  -                getParser().reportError(Constants.ERROR, msg);
  -            }
  +                result.addElement(constructors[i]);
  +              }
  +          }
  +        }
  +        catch (ClassNotFoundException e) {
  +          final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, 
_className);
  +          getParser().reportError(Constants.ERROR, msg);
           }
  +            
           return result;
       }
   
  @@ -888,4 +1036,42 @@
        }
        return sb.append(")V").toString();
       }
  +    
  +    /**
  +     * Return the signature of the current method
  +     */
  +    private String getMethodSignature(Vector argsType) {
  +     final StringBuffer buf = new StringBuffer(_className);
  +        buf.append('.').append(_fname.getLocalPart()).append('(');
  +       
  +     int nArgs = argsType.size();        
  +     for (int i = 0; i < nArgs; i++) {
  +       final Type intType = (Type)argsType.elementAt(i);
  +       buf.append(intType.toString());
  +       if (i < nArgs - 1) buf.append(", ");
  +     }
  +       
  +     buf.append(')');
  +     return buf.toString();
  +    }
  +
  +    /**
  +     * To support EXSLT extensions, convert names with dash to allowable 
Java names: 
  +     * e.g., convert abc-xyz to abcXyz.
  +     * Note: dashes only appear in middle of an EXSLT function or element 
name.
  +     */
  +    private static String replaceDash(String name)
  +    {
  +      char dash = '-';
  +      StringBuffer buff = new StringBuffer("");
  +      for (int i = 0; i < name.length(); i++)
  +      {
  +        if (i > 0 && name.charAt(i-1) == dash)
  +          buff.append(Character.toUpperCase(name.charAt(i)));
  +        else if (name.charAt(i) != dash)
  +          buff.append(name.charAt(i));
  +      }
  +      return buff.toString();
  +    }
  +      
   }
  
  
  
  1.39.2.3  +9 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
  retrieving revision 1.39.2.2
  retrieving revision 1.39.2.3
  diff -u -r1.39.2.2 -r1.39.2.3
  --- Parser.java       29 Jul 2002 00:01:22 -0000      1.39.2.2
  +++ Parser.java       18 Sep 2002 13:31:52 -0000      1.39.2.3
  @@ -719,6 +719,7 @@
   
       private void initExtClasses() {
        initExtClass("output", "TransletOutput");
  +        initExtClass(REDIRECT_URI, "write", "TransletOutput");
       }
   
       private void initExtClass(String elementName, String className) {
  @@ -726,6 +727,11 @@
                                COMPILER_PACKAGE + '.' + className);
       }
   
  +    private void initExtClass(String namespace, String elementName, String 
className) {
  +        _instructionClasses.put(getQName(namespace, TRANSLET, elementName),
  +                                COMPILER_PACKAGE + '.' + className);
  +    }
  +
       /**
        * Add primops and base functions to the symbol table.
        */
  @@ -840,7 +846,8 @@
        _symbolTable.addPrimop("system-property", S_S);
   
        // Extensions
  -     _symbolTable.addPrimop("nodeset", D_X);
  +        _symbolTable.addPrimop("nodeset", D_O);
  +        _symbolTable.addPrimop("objectType", S_O);
   
        // Operators +, -, *, /, % defined on real types.
        _symbolTable.addPrimop("+", R_RR);      
  
  
  
  1.19.2.4  +5 -7      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
  
  Index: SyntaxTreeNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
  retrieving revision 1.19.2.3
  retrieving revision 1.19.2.4
  diff -u -r1.19.2.3 -r1.19.2.4
  --- SyntaxTreeNode.java       12 Sep 2002 16:07:33 -0000      1.19.2.3
  +++ SyntaxTreeNode.java       18 Sep 2002 13:31:52 -0000      1.19.2.4
  @@ -547,21 +547,19 @@
   
        final String DOM_CLASS = classGen.getDOMClass();
   
  -     // Create new instance of DOM class (with 64 nodes)
  +     // Create new instance of DOM class (with RTF_INITIAL_SIZE nodes)
        //int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
        //il.append(new NEW(cpg.addClass(DOM_IMPL)));
        
        il.append(methodGen.loadDOM());
        int index = cpg.addInterfaceMethodref(DOM_INTF,
                                 "getResultTreeFrag",
  -                              "()" + DOM_INTF_SIG);
  -     il.append(new INVOKEINTERFACE(index,1));
  +                              "(I)" + DOM_INTF_SIG);
  +     il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
  +     il.append(new INVOKEINTERFACE(index,2));
   
        
        il.append(DUP);
  -     //il.append(DUP);
  -     //il.append(new PUSH(cpg, 64));
  -     //il.append(new INVOKESPECIAL(index));
   
        // Overwrite old handler with DOM handler
        index = cpg.addInterfaceMethodref(DOM_INTF,
  
  
  
  1.7.6.1   +16 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java
  
  Index: TransletOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java,v
  retrieving revision 1.7
  retrieving revision 1.7.6.1
  diff -u -r1.7 -r1.7.6.1
  --- TransletOutput.java       1 Feb 2002 20:07:09 -0000       1.7
  +++ TransletOutput.java       18 Sep 2002 13:31:52 -0000      1.7.6.1
  @@ -69,6 +69,7 @@
   final class TransletOutput extends Instruction {
   
       private Expression _filename;
  +    private boolean _append;
   
       private final static String MISSING_FILE_ATTR =
        "The <xsltc:output> element requires a 'file' attribute.";
  @@ -88,6 +89,10 @@
       public void parseContents(Parser parser) {
        // Get the output filename from the 'file' attribute
        String filename = getAttribute("file");
  +        
  +        // If the 'append' attribute is set to "yes" or "true",
  +        // the output is appended to the file.
  +        String append   = getAttribute("append");
   
        // Verify that the filename is in fact set
        if ((filename == null) || (filename.equals(EMPTYSTRING))) {
  @@ -96,6 +101,14 @@
   
        // Save filename as an attribute value template
        _filename = AttributeValue.create(this, filename, parser);
  +        
  +        if (append != null && (append.toLowerCase().equals("yes") ||
  +            append.toLowerCase().equals("true"))) {
  +          _append = true;     
  +        }
  +        else
  +          _append = false;
  +          
        parseChildren(parser);
       }
       
  @@ -124,7 +137,7 @@
        
        final int open =  cpg.addMethodref(TRANSLET_CLASS,
                                           "openOutputHandler",
  -                                        "("+STRING_SIG+")"+
  +                                           "(" + STRING_SIG + "Z)" +
                                           TRANSLET_OUTPUT_SIG);
   
        final int close =  cpg.addMethodref(TRANSLET_CLASS,
  @@ -134,6 +147,7 @@
        // Create the new output handler (leave it on stack)
        il.append(classGen.loadTranslet());
        _filename.translate(classGen, methodGen);
  +        il.append(new PUSH(cpg, _append));
        il.append(new INVOKEVIRTUAL(open));
   
        // Overwrite current handler
  
  
  
  1.33.10.3 +48 -14    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
  
  Index: xpath.cup
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
  retrieving revision 1.33.10.2
  retrieving revision 1.33.10.3
  diff -u -r1.33.10.2 -r1.33.10.3
  --- xpath.cup 12 Sep 2002 16:07:33 -0000      1.33.10.2
  +++ xpath.cup 18 Sep 2002 13:31:52 -0000      1.33.10.3
  @@ -70,6 +70,8 @@
   import java.io.StringReader;
   import java_cup.runtime.*;
   
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.dom.Axis;
   import org.apache.xalan.xsltc.runtime.Operators;
   import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
  @@ -229,6 +231,16 @@
            return rlp;
        }
       }
  +
  +    /**
  +     * Returns true if the axis applies to elements only. The axes
  +     * child, attribute, namespace, descendant result in non-empty
  +     * nodesets only if the context node is of type element.
  +     */
  +    public boolean isElementAxis(int axis) {
  +     return (axis == Axis.CHILD || axis == Axis.ATTRIBUTE ||
  +             axis == Axis.NAMESPACE || axis == Axis.DESCENDANT);
  +    }
   :}
   
   terminal SLASH, DOT, LBRACK, RBRACK, VBAR, LPAREN, RPAREN, STAR, COMMA;
  @@ -513,12 +525,22 @@
   
           | FilterExpr:fexp DSLASH RelativeLocationPath:rlp
           {:
  -           // Expand '//' into '/descendant-or-self::node()/'
  -           Step step = new Step(Axis.DESCENDANTORSELF, NodeTest.ANODE, null);
  +           // 
  +        // Expand '//' into '/descendant-or-self::node()/' or
  +        // into /descendant-or-self::*/
  +        //
  +        int nodeType = DOM.NO_TYPE;
  +        if (rlp instanceof Step && 
  +            parser.isElementAxis(((Step) rlp).getAxis())) 
  +        {
  +            nodeType = DTM.ELEMENT_NODE;
  +        }
  +           final Step step = new Step(Axis.DESCENDANTORSELF, nodeType, null);
              FilterParentPath fpp = new FilterParentPath(fexp, step);
              fpp = new FilterParentPath(fpp, rlp);
  -           if (!(fexp instanceof KeyCall))
  +           if (fexp instanceof KeyCall == false) {
                  fpp.setDescendantAxis();
  +        }
              RESULT = fpp;
           :};
   
  @@ -580,13 +602,15 @@
                  else {
                      // Expand './/step' -> 'descendant-or-self::*/step'
                      if (rlp instanceof Step && 
((Step)rlp).isAbbreviatedDot()) {
  -                       Step left = new Step(Axis.DESCENDANTORSELF, -1, null);
  +                       Step left = new Step(Axis.DESCENDANTORSELF, 
  +                         DTM.ELEMENT_NODE, null);
                          RESULT = new ParentLocationPath(left, right);
                      }
                      else {
                          // Expand 'rlp//step' -> 
'rlp/descendant-or-self::*/step'
                          RelativeLocationPath left = (RelativeLocationPath)rlp;
  -                       Step mid = new Step(Axis.DESCENDANTORSELF, -1, null);
  +                       Step mid = new Step(Axis.DESCENDANTORSELF, 
  +                         DTM.ELEMENT_NODE, null);
                          ParentLocationPath ppl = new ParentLocationPath(mid, 
right);
                          RESULT = new ParentLocationPath(left, ppl);
                      }
  @@ -595,14 +619,16 @@
              else if ((axis == Axis.ATTRIBUTE) || (type == 
NodeTest.ATTRIBUTE)) {
                  // Expand 'rlp//step' -> 'rlp/descendant-or-self::*/step'
                  RelativeLocationPath left = (RelativeLocationPath)rlp;
  -               Step middle = new Step(Axis.DESCENDANTORSELF, -1, null);
  +               Step middle = new Step(Axis.DESCENDANTORSELF, 
  +                 DTM.ELEMENT_NODE, null);
                  ParentLocationPath ppl = new ParentLocationPath(middle, 
right);
                  RESULT = new ParentLocationPath(left, ppl);
           }
           else {
               // Expand 'rlp//step' -> 'rlp/descendant-or-self::node()/step'
                  RelativeLocationPath left = (RelativeLocationPath)rlp;
  -            Step middle = new Step(Axis.DESCENDANTORSELF, -1, null); 
  +            Step middle = new Step(Axis.DESCENDANTORSELF, 
  +                 DOM.NO_TYPE, null); 
                  ParentLocationPath ppl = new ParentLocationPath(middle, 
right);
               RESULT = new ParentLocationPath(left, ppl);
           }
  @@ -611,11 +637,19 @@
   
   AbbreviatedAbsoluteLocationPath ::= DSLASH RelativeLocationPath:rlp
           {:
  -         final Step step = new Step(Axis.DESCENDANTORSELF, -1, null);
  -
  -         RESULT = new FilteredAbsoluteLocationPath(
  -                     new AbsoluteLocationPath(parser.insertStep(step, 
  -                             (RelativeLocationPath) rlp)));
  +           // 
  +        // Expand '//' into '/descendant-or-self::node()/' or
  +        // into /descendant-or-self::*/
  +        //
  +        int nodeType = DOM.NO_TYPE;
  +        if (rlp instanceof Step && 
  +            parser.isElementAxis(((Step) rlp).getAxis())) 
  +        {
  +            nodeType = DTM.ELEMENT_NODE;
  +        }
  +        final Step step = new Step(Axis.DESCENDANTORSELF, nodeType, null);
  +        RESULT = new AbsoluteLocationPath(parser.insertStep(step, 
  +                             (RelativeLocationPath) rlp));
        :};
   
   Step ::= NodeTest:ntest
  @@ -907,7 +941,7 @@
               RESULT = new NamespaceUriCall(fname, argl);
          }
          // Special case for extension function nodeset()
  -          else if (fname.getLocalPart().equals("nodeset")) {
  +          else if (fname.getLocalPart().equals("nodeset") || 
fname.getLocalPart().equals("node-set")) {
            parser.setCallsNodeset(true);  // implies MultiDOM
               RESULT = new FunctionCall(fname, argl);
          }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.6.1   +4 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/BooleanType.java
  
  Index: BooleanType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/BooleanType.java,v
  retrieving revision 1.3
  retrieving revision 1.3.6.1
  diff -u -r1.3 -r1.3.6.1
  --- BooleanType.java  1 Feb 2002 20:27:46 -0000       1.3
  +++ BooleanType.java  18 Sep 2002 13:31:53 -0000      1.3.6.1
  @@ -172,6 +172,9 @@
        if (clazz == java.lang.Boolean.TYPE) {
            methodGen.getInstructionList().append(NOP);
        }
  +        else if (clazz.isAssignableFrom(java.lang.Boolean.class)) {
  +            translateTo(classGen, methodGen, Type.Reference);
  +        }
        else {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                        toString(), clazz.getName());
  
  
  
  1.3.6.1   +4 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/IntType.java
  
  Index: IntType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/IntType.java,v
  retrieving revision 1.3
  retrieving revision 1.3.6.1
  diff -u -r1.3 -r1.3.6.1
  --- IntType.java      1 Feb 2002 20:27:46 -0000       1.3
  +++ IntType.java      18 Sep 2002 13:31:53 -0000      1.3.6.1
  @@ -231,6 +231,9 @@
        else if (clazz == Double.TYPE) {
            il.append(I2D);
        }
  +        else if (clazz.isAssignableFrom(java.lang.Integer.class)) {
  +            translateTo(classGen, methodGen, Type.Reference);   
  +        }
        else {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                        toString(), clazz.getName());
  
  
  
  1.9.6.3   +16 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSetType.java
  
  Index: NodeSetType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSetType.java,v
  retrieving revision 1.9.6.2
  retrieving revision 1.9.6.3
  diff -u -r1.9.6.2 -r1.9.6.3
  --- NodeSetType.java  29 Jul 2002 00:01:26 -0000      1.9.6.2
  +++ NodeSetType.java  18 Sep 2002 13:31:53 -0000      1.9.6.3
  @@ -271,12 +271,26 @@
                                                  MAKE_NODE_SIG2);
            il.append(new INVOKEINTERFACE(index, 2));
        }
  -     else if (className.equals("org.w3c.dom.NodeList")) {
  +        else if (className.equals("org.w3c.dom.NodeList") || 
  +                 className.equals("java.lang.Object")) {
            int index = cpg.addInterfaceMethodref(DOM_INTF,
                                                  MAKE_NODE_LIST,
                                                  MAKE_NODE_LIST_SIG2);
            il.append(new INVOKEINTERFACE(index, 2));
        }
  +        else if (className.equals("java.lang.String")) {
  +            int next = cpg.addInterfaceMethodref(NODE_ITERATOR,
  +                                                 "next", "()I");
  +            int index = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                 GET_NODE_VALUE,
  +                                                 "(I)"+STRING_SIG);
  +
  +            // Get next node from the iterator
  +            il.append(new INVOKEINTERFACE(next, 1));
  +            // Get the node's string value (from the DOM)
  +            il.append(new INVOKEINTERFACE(index, 2));
  +                       
  +        }
        else if (className.equals("int")) {
            int next = cpg.addInterfaceMethodref(NODE_ITERATOR,
                                                  "next", "()I");
  
  
  
  1.7.6.2   +9 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeType.java
  
  Index: NodeType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeType.java,v
  retrieving revision 1.7.6.1
  retrieving revision 1.7.6.2
  diff -u -r1.7.6.1 -r1.7.6.2
  --- NodeType.java     29 Jul 2002 00:01:26 -0000      1.7.6.1
  +++ NodeType.java     18 Sep 2002 13:31:53 -0000      1.7.6.2
  @@ -282,11 +282,17 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  +        String className = clazz.getName();
  +        if (className.equals("java.lang.String")) {
  +           translateTo(classGen, methodGen, Type.String);
  +           return;
  +        }
  +
        il.append(methodGen.loadDOM());
        il.append(SWAP);                // dom ref must be below node index
   
  -     String className = clazz.getName();
  -     if (className.equals("org.w3c.dom.Node")) {
  +        if (className.equals("org.w3c.dom.Node") ||
  +            className.equals("java.lang.Object")) {
            int index = cpg.addInterfaceMethodref(DOM_INTF,
                                                  MAKE_NODE,
                                                  MAKE_NODE_SIG);
  
  
  
  1.3.6.1   +4 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/RealType.java
  
  Index: RealType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/RealType.java,v
  retrieving revision 1.3
  retrieving revision 1.3.6.1
  diff -u -r1.3 -r1.3.6.1
  --- RealType.java     1 Feb 2002 20:08:11 -0000       1.3
  +++ RealType.java     18 Sep 2002 13:31:53 -0000      1.3.6.1
  @@ -260,6 +260,9 @@
        else if (clazz == Double.TYPE) {
            il.append(NOP);
        }
  +        else if (clazz.isAssignableFrom(java.lang.Double.class)) {
  +            translateTo(classGen, methodGen, Type.Reference);
  +        }
        else {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                        toString(), clazz.getName());
  
  
  
  1.10.6.4  +8 -9      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java
  
  Index: ResultTreeType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java,v
  retrieving revision 1.10.6.3
  retrieving revision 1.10.6.4
  diff -u -r1.10.6.3 -r1.10.6.4
  --- ResultTreeType.java       12 Sep 2002 16:07:34 -0000      1.10.6.3
  +++ ResultTreeType.java       18 Sep 2002 13:31:53 -0000      1.10.6.4
  @@ -269,18 +269,14 @@
            }
            il.append(methodGen.loadDOM());
   
  -         // Create new instance of DOM class (with 64 nodes)
  +         // Create new instance of DOM class (with RTF_INITIAL_SIZE nodes)
            il.append(methodGen.loadDOM());
            int index = cpg.addInterfaceMethodref(DOM_INTF,
                                 "getResultTreeFrag",
  -                              "()" + DOM_INTF_SIG);
  -         il.append(new INVOKEINTERFACE(index,1));
  -        // int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
  -        // il.append(new NEW(cpg.addClass(DOM_IMPL)));
  -        // il.append(DUP);
  +                              "(I)" + DOM_INTF_SIG);
  +         il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
  +         il.append(new INVOKEINTERFACE(index,2));
            il.append(DUP);
  -        // il.append(new PUSH(cpg, 64));
  -        // il.append(new INVOKESPECIAL(index));
            
            // Store new DOM into a local variable
            newDom = methodGen.addLocalVariable("rt_to_reference_dom", 
  @@ -445,6 +441,9 @@
        else if (className.equals("java.lang.Object")) {
            il.append(NOP);
        }
  +        else if (className.equals("java.lang.String")) {
  +            translateTo(classGen, methodGen, Type.String);
  +        }
        else {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                        toString(), className);
  
  
  
  1.5.6.2   +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/StringType.java
  
  Index: StringType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/StringType.java,v
  retrieving revision 1.5.6.1
  retrieving revision 1.5.6.2
  diff -u -r1.5.6.1 -r1.5.6.2
  --- StringType.java   29 Jul 2002 00:01:26 -0000      1.5.6.1
  +++ StringType.java   18 Sep 2002 13:31:53 -0000      1.5.6.2
  @@ -184,7 +184,7 @@
       public void translateTo(ClassGenerator classGen, MethodGenerator 
methodGen, 
                            Class clazz) 
       {
  -     if (clazz.getName().equals("java.lang.String")) {
  +        if (clazz.isAssignableFrom(java.lang.String.class)) {
            // same internal representation
            methodGen.getInstructionList().append(NOP);
        }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.10.3  +3 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java
  
  Index: AbsoluteIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java,v
  retrieving revision 1.6.10.2
  retrieving revision 1.6.10.3
  diff -u -r1.6.10.2 -r1.6.10.3
  --- AbsoluteIterator.java     29 Jul 2002 00:01:27 -0000      1.6.10.2
  +++ AbsoluteIterator.java     18 Sep 2002 13:31:53 -0000      1.6.10.3
  @@ -92,7 +92,8 @@
   
        if (_isRestartable) {
            resetPosition();
  -         return _source.setStartNode(_startNode = DTMDefaultBase.ROOTNODE);
  +         _source.setStartNode(_startNode);
  +         return this;
        }
        return reset();
       }
  
  
  
  1.11.10.4 +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
  
  Index: DOMAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
  retrieving revision 1.11.10.3
  retrieving revision 1.11.10.4
  diff -u -r1.11.10.3 -r1.11.10.4
  --- DOMAdapter.java   24 Aug 2002 11:33:23 -0000      1.11.10.3
  +++ DOMAdapter.java   18 Sep 2002 13:31:53 -0000      1.11.10.4
  @@ -417,9 +417,9 @@
       /**
        * Return a instance of a DOM class to be used as an RTF
        */ 
  -    public DOM getResultTreeFrag()
  +    public DOM getResultTreeFrag(int initSize)
       {
  -     return _domImpl.getResultTreeFrag();
  +     return _domImpl.getResultTreeFrag(initSize);
       }
       
       /**
  
  
  
  1.68.2.8  +18 -19    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.68.2.7
  retrieving revision 1.68.2.8
  diff -u -r1.68.2.7 -r1.68.2.8
  --- DOMImpl.java      17 Sep 2002 21:08:48 -0000      1.68.2.7
  +++ DOMImpl.java      18 Sep 2002 13:31:54 -0000      1.68.2.8
  @@ -1207,6 +1207,14 @@
   
       }
   
  +    /*
  +     * These init sizes have been tuned for the average case. Do not
  +     * change these values unless you know exactly what you're doing.
  +     */
  +    static private final int SMALL_TEXT_SIZE   = 1024; 
  +    static private final int DEFAULT_INIT_SIZE = 1024;
  +    static private final int DEFAULT_TEXT_FACTOR = 10;
  +
       /**
        * Construct a DOMImpl object from a DOM node.
        *
  @@ -1224,9 +1232,8 @@
                      XMLStringFactory xstringfactory,
                      boolean doIndexing)
       {
  -        super(mgr, domSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
  -              doIndexing);
  -        initSize(8*1024);
  +        this(mgr, domSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
  +             doIndexing, DEFAULT_INIT_SIZE);
       }
       
       /**
  @@ -1249,26 +1256,18 @@
       {
           super(mgr, domSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
                 doIndexing);
  -        initSize(size);
  +     initialize(size, size < 128 ? SMALL_TEXT_SIZE
  +                                 : size * DEFAULT_TEXT_FACTOR);
       }
       
       /**
  -     * Constructor - defaults to 32K nodes
  -     */
  -  /*  public DOMImpl() 
  -    {
  -      //this(32*1024);
  -      this(8*1024);
  -    }*/
  -    
  -    /**
        *  defines initial size
        */
  -    public void initSize(int size) 
  +    public void initialize(int size, int textsize)
       {
         _offsetOrChild        = new int[size];
         _lengthOrAttr         = new int[size];
  -      _text                 = new char[size * 10];
  +      _text                 = new char[textsize];
         _whitespace           = new BitArray(size);
         _checkedForWhitespace = new BitArray(size);
       }
  @@ -1989,10 +1988,10 @@
       /**
        * Return a instance of a DOM class to be used as an RTF
        */ 
  -    public DOM getResultTreeFrag()
  +    public DOM getResultTreeFrag(int initSize)
       {
  -     return ((SAXImpl)m_mgr.getDTM(null, true, m_wsfilter, false, false));
  -
  +        return (SAXImpl) ((XSLTCDTMManager)m_mgr).getDTM(null, true, 
m_wsfilter,
  +                                                        false, false, 
initSize);
       }
   
       /**
  
  
  
  1.16.10.5 +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java
  
  Index: MultiDOM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java,v
  retrieving revision 1.16.10.4
  retrieving revision 1.16.10.5
  diff -u -r1.16.10.4 -r1.16.10.5
  --- MultiDOM.java     17 Sep 2002 21:09:00 -0000      1.16.10.4
  +++ MultiDOM.java     18 Sep 2002 13:31:54 -0000      1.16.10.5
  @@ -599,9 +599,9 @@
           return _adapters[nodeId>>>24].getNodeHandle(nodeId & CLR);
       }
       
  -    public DOM getResultTreeFrag()
  +    public DOM getResultTreeFrag(int initSize)
       {
  -        return _adapters[0].getResultTreeFrag();
  +        return _adapters[0].getResultTreeFrag(initSize);
       }
       
       public DOM getMain()
  
  
  
  1.1.2.8   +22 -30    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
  
  Index: SAXImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- SAXImpl.java      17 Sep 2002 21:08:48 -0000      1.1.2.7
  +++ SAXImpl.java      18 Sep 2002 13:31:54 -0000      1.1.2.8
  @@ -1126,20 +1126,24 @@
         _types         = setupMapping(_namesArray);
       }
   
  +    /*
  +     * These init sizes have been tuned for the average case. Do not
  +     * change these values unless you know exactly what you're doing.
  +     */
  +    static private final int SMALL_TEXT_SIZE   = 1024;
  +    static private final int DEFAULT_INIT_SIZE = 1024;
  +    static private final int DEFAULT_TEXT_FACTOR = 10;
  +
       /**
        * Constructor - defaults to 32K nodes
        */
  -
       public SAXImpl(DTMManager mgr, Source saxSource,
                    int dtmIdentity, DTMWSFilter whiteSpaceFilter,
                    XMLStringFactory xstringfactory,
                    boolean doIndexing)
       {
  -      super(mgr, saxSource,
  -                 dtmIdentity, whiteSpaceFilter,
  -                 xstringfactory,
  -                 doIndexing);
  -      initSize(8*1024);
  +      this(mgr, saxSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
  +           doIndexing, DEFAULT_INIT_SIZE);
       }
   
       public SAXImpl(DTMManager mgr, Source saxSource,
  @@ -1147,33 +1151,20 @@
                    XMLStringFactory xstringfactory,
                    boolean doIndexing, int size)
       {
  -      super(mgr, saxSource,
  -                 dtmIdentity, whiteSpaceFilter,
  -                 xstringfactory,
  -                 doIndexing);
  -      initSize(size);
  +      super(mgr, saxSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
  +            doIndexing);
  +      initialize(size, size < 128 ? SMALL_TEXT_SIZE
  +                                  : size * DEFAULT_TEXT_FACTOR);
       }
   
  -  /*  public DOMImpl()
  -    {
  -      //this(32*1024);
  -      this(8*1024);
  -    }*/
  -
       /**
        *  defines initial size
        */
  -    public void initSize(int size)
  +    public void initialize(int size, int textsize)
       {
  -      //_type          = new short[size];
  -      //_parent        = new int[size];
  -      //_nextSibling   = new int[size];
  -      _offsetOrChild = new int[size];
  -      _lengthOrAttr  = new int[size];
  -      //_text          = new char[size * 10];
  -      _whitespace    = new BitArray(size);
  -     // _prefix        = new short[size];
  -      // _namesArray[] and _uriArray[] are allocated in endDocument
  +      _offsetOrChild        = new int[size];
  +      _lengthOrAttr         = new int[size];
  +      _whitespace           = new BitArray(size);
       }
   
       /**
  @@ -1905,9 +1896,10 @@
       /**
        * Return a instance of a DOM class to be used as an RTF
        */ 
  -    public DOM getResultTreeFrag()
  +    public DOM getResultTreeFrag(int initSize)
       {
  -     return ((SAXImpl)m_mgr.getDTM(null, true, m_wsfilter, false, false));
  +     return (SAXImpl) ((XSLTCDTMManager)m_mgr).getDTM(null, true, m_wsfilter,
  +                                                        false, false, 
initSize);
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.33.2.5  +9 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.33.2.4
  retrieving revision 1.33.2.5
  diff -u -r1.33.2.4 -r1.33.2.5
  --- AbstractTranslet.java     12 Sep 2002 16:07:35 -0000      1.33.2.4
  +++ AbstractTranslet.java     18 Sep 2002 13:31:55 -0000      1.33.2.5
  @@ -457,7 +457,7 @@
        * See compiler/TransletOutput for actual implementation.
        
************************************************************************/
   
  -    public TransletOutputHandler openOutputHandler(String filename) 
  +    public TransletOutputHandler openOutputHandler(String filename, boolean 
append) 
        throws TransletException 
       {
        try {
  @@ -466,7 +466,7 @@
   
            factory.setEncoding(_encoding);
            factory.setOutputMethod(_method);
  -         factory.setWriter(new FileWriter(filename));
  +         factory.setWriter(new FileWriter(filename, append));
            factory.setOutputType(TransletOutputHandlerFactory.STREAM);
   
            final TransletOutputHandler handler 
  @@ -479,6 +479,12 @@
        catch (Exception e) {
            throw new TransletException(e);
        }
  +    }
  +
  +    public TransletOutputHandler openOutputHandler(String filename) 
  +       throws TransletException 
  +    {
  +       return openOutputHandler(filename, false);
       }
   
       public void closeOutputHandler(TransletOutputHandler handler) {
  
  
  
  1.35.2.6  +108 -65   
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
  
  Index: BasisLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
  retrieving revision 1.35.2.5
  retrieving revision 1.35.2.6
  diff -u -r1.35.2.5 -r1.35.2.6
  --- BasisLibrary.java 12 Sep 2002 16:07:35 -0000      1.35.2.5
  +++ BasisLibrary.java 18 Sep 2002 13:31:55 -0000      1.35.2.6
  @@ -91,6 +91,7 @@
   import org.apache.xalan.xsltc.dom.DOMImpl;
   import org.apache.xalan.xsltc.dom.DOMBuilder;
   import org.apache.xalan.xsltc.dom.StepIterator;
  +import org.w3c.dom.Element;
   import org.w3c.dom.NodeList;
   import org.w3c.dom.DOMException;
   import org.w3c.dom.Document;
  @@ -469,6 +470,27 @@
       }
   
       /**
  +     * Implements the object-type() extension function.
  +     * 
  +     * @see <a href="http://www.exslt.org/";>EXSLT</a>
  +     */
  +    public static String objectTypeF(Object obj)
  +    {
  +      if (obj instanceof String)
  +        return "string";
  +      else if (obj instanceof Boolean)
  +        return "boolean";
  +      else if (obj instanceof Number)
  +        return "number";
  +      else if (obj instanceof DOMAdapter)
  +        return "RTF";
  +      else if (obj instanceof NodeIterator)
  +        return "node-set";
  +      else
  +        return "unknown";
  +    }  
  +
  +    /**
        * Implements the nodeset() extension function. 
        */
       public static DTMAxisIterator nodesetF(Object obj) {
  @@ -944,6 +966,89 @@
       }
   
       /**
  +     * Utility function used to copy a node list to be under a parent node.
  +     */
  +    private static void copyNodes(org.w3c.dom.NodeList nodeList, 
org.w3c.dom.Document doc, org.w3c.dom.Node parent)
  +    {
  +        final int size = nodeList.getLength();
  +
  +          // copy Nodes from NodeList into new w3c DOM
  +        for (int i = 0; i < size; i++) 
  +        {
  +            org.w3c.dom.Node curr = nodeList.item(i);
  +            int nodeType = curr.getNodeType();
  +            if (nodeType == org.w3c.dom.Node.DOCUMENT_NODE) {
  +                // ignore the root node of node list
  +                continue;
  +            }
  +            String value = null;
  +            try {
  +                value = curr.getNodeValue();
  +            } catch (DOMException ex) {
  +                runTimeError(RUN_TIME_INTERNAL_ERR, ex.getMessage());
  +                return;
  +            }
  +            
  +            String nodeName = curr.getNodeName();
  +            org.w3c.dom.Node newNode = null; 
  +            switch (nodeType){
  +                case org.w3c.dom.Node.ATTRIBUTE_NODE:
  +                     newNode = doc.createAttributeNS(curr.getNamespaceURI(), 
nodeName);
  +                     break;
  +                case org.w3c.dom.Node.CDATA_SECTION_NODE: 
  +                     newNode = doc.createCDATASection(value);
  +                     break;
  +                case org.w3c.dom.Node.COMMENT_NODE: 
  +                     newNode = doc.createComment(value);
  +                     break;
  +                case org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE: 
  +                     newNode = doc.createDocumentFragment();
  +                     break;
  +                case org.w3c.dom.Node.DOCUMENT_TYPE_NODE: 
  +                     // nothing ?
  +                     break;
  +                case org.w3c.dom.Node.ELEMENT_NODE: 
  +                     // For Element node, also copy the children and the 
attributes.
  +                     org.w3c.dom.Element element = 
doc.createElementNS(curr.getNamespaceURI(), nodeName);
  +                     if (curr.hasAttributes())
  +                     {
  +                       org.w3c.dom.NamedNodeMap attributes = 
curr.getAttributes();
  +                       for (int k = 0; k < attributes.getLength(); k++)
  +                       {
  +                         org.w3c.dom.Node attr = attributes.item(k);
  +                         element.setAttribute(attr.getNodeName(), 
attr.getNodeValue());
  +                       }
  +                     }
  +                     copyNodes(curr.getChildNodes(), doc, element);
  +                     newNode = element;
  +                     break;
  +                case org.w3c.dom.Node.ENTITY_NODE: 
  +                     // nothing ? 
  +                     break;
  +                case org.w3c.dom.Node.ENTITY_REFERENCE_NODE: 
  +                     newNode = doc.createEntityReference(nodeName);
  +                     break;
  +                case org.w3c.dom.Node.NOTATION_NODE: 
  +                     // nothing ? 
  +                     break;
  +                case org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE: 
  +                     newNode = doc.createProcessingInstruction(nodeName,
  +                        value);
  +                     break;
  +                case org.w3c.dom.Node.TEXT_NODE: 
  +                     newNode = doc.createTextNode(value);
  +                     break;
  +            }
  +            try {
  +                parent.appendChild(newNode);
  +            } catch (DOMException e) {
  +                runTimeError(RUN_TIME_INTERNAL_ERR, e.getMessage());
  +                return;
  +            }           
  +        }
  +    }
  +
  +    /**
        * Utility function used to convert a w3c NodeList into a internal
        * DOM iterator. 
        */
  @@ -951,8 +1056,6 @@
                                           org.w3c.dom.NodeList nodeList,
                                        Translet translet, DOM dom) 
       {
  -     int size = nodeList.getLength();
  -
        // w3c NodeList -> w3c DOM
        DocumentBuilderFactory dfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docbldr = null;
  @@ -968,68 +1071,8 @@
           org.w3c.dom.Node topElementNode = 
               doc.appendChild(doc.createElementNS("", "__top__"));
   
  -     // copy Nodes from NodeList into new w3c DOM
  -     for (int i=0; i<size; i++){
  -         org.w3c.dom.Node curr = nodeList.item(i);
  -         int nodeType = curr.getNodeType();
  -         if (nodeType == org.w3c.dom.Node.DOCUMENT_NODE) {
  -             // ignore the root node of node list
  -             continue;
  -         }
  -         String value = null;
  -         try {
  -             value = curr.getNodeValue();
  -         } catch (DOMException ex) {
  -             runTimeError(RUN_TIME_INTERNAL_ERR, ex.getMessage());
  -                return null;
  -         }
  -         String namespaceURI = curr.getNamespaceURI();
  -         String nodeName = curr.getNodeName();
  -         org.w3c.dom.Node newNode = null; 
  -         switch (nodeType){
  -             case org.w3c.dom.Node.ATTRIBUTE_NODE: 
  -                  newNode = doc.createAttributeNS(namespaceURI,
  -                     nodeName);
  -                     break;
  -             case org.w3c.dom.Node.CDATA_SECTION_NODE: 
  -                  newNode = doc.createCDATASection(value);
  -                     break;
  -             case org.w3c.dom.Node.COMMENT_NODE: 
  -                  newNode = doc.createComment(value);
  -                     break;
  -             case org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE: 
  -                  newNode = doc.createDocumentFragment();
  -                     break;
  -             case org.w3c.dom.Node.DOCUMENT_TYPE_NODE: 
  -                  // nothing ?
  -                     break;
  -             case org.w3c.dom.Node.ELEMENT_NODE: 
  -                  newNode = doc.createElementNS(namespaceURI, nodeName);
  -                  break;
  -             case org.w3c.dom.Node.ENTITY_NODE: 
  -                  // nothing ? 
  -                     break;
  -             case org.w3c.dom.Node.ENTITY_REFERENCE_NODE: 
  -                  newNode = doc.createEntityReference(nodeName);
  -                  break;
  -             case org.w3c.dom.Node.NOTATION_NODE: 
  -                  // nothing ? 
  -                  break;
  -             case org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE: 
  -                  newNode = doc.createProcessingInstruction(nodeName,
  -                     value);
  -                  break;
  -             case org.w3c.dom.Node.TEXT_NODE: 
  -                  newNode = doc.createTextNode(value);
  -                  break;
  -         }
  -         try {
  -             topElementNode.appendChild(newNode);
  -         } catch (DOMException e) {
  -             runTimeError(RUN_TIME_INTERNAL_ERR, e.getMessage());
  -             return null;
  -         }
  -     }
  +        // Copy all the nodes in the nodelist to be under the top element
  +        copyNodes(nodeList, doc, topElementNode);
   
           // w3cDOM -> DTM -> DOMImpl
        DTMManager dtmManager = XSLTCDTMManager.newInstance(
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.22.2.3  +1 -3      
xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java
  
  Index: XRTreeFrag.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java,v
  retrieving revision 1.22.2.2
  retrieving revision 1.22.2.3
  diff -u -r1.22.2.2 -r1.22.2.3
  --- XRTreeFrag.java   8 Aug 2002 15:21:22 -0000       1.22.2.2
  +++ XRTreeFrag.java   18 Sep 2002 13:31:55 -0000      1.22.2.3
  @@ -350,9 +350,7 @@
      */
     public DTMIterator asNodeIterator()
     {
  -    DTMIterator iter = new RTFIterator(Axis.SELF);
  -    iter.setRoot(m_dtmRoot, m_xctxt);    
  -    return iter;
  +    return new RTFIterator(m_dtmRoot, m_xctxt.getDTMManager());
     }
   
     /**
  
  
  

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

Reply via email to