You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by pa...@apache.org on 2002/08/14 21:45:37 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/utils/synthetic JavaUtils.java

pauldick    2002/08/14 12:45:36

  Modified:    java/src/org/apache/xml/dtm Tag: xalan3 DTM.java
                        DTMFilter.java DTMIterator.java DTMManager.java
               java/src/org/apache/xml/dtm/ref Tag: xalan3
                        DTMDefaultBase.java DTMDefaultBaseIterators.java
                        DTMDefaultBaseTraversers.java DTMDocumentImpl.java
                        DTMManagerDefault.java DTMNodeList.java
                        ExpandedNameTable.java
                        IncrementalSAXSource_Xerces.java
               java/src/org/apache/xml/dtm/ref/dom2dtm Tag: xalan3
                        DOM2DTM.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: xalan3
                        SAX2DTM.java
               java/src/org/apache/xml/utils Tag: xalan3
                        DefaultErrorHandler.java FastStringBuffer.java
                        ListingErrorHandler.java QName.java
                        StringToIntTable.java SystemIDResolver.java
                        TreeWalker.java URI.java
               java/src/org/apache/xml/utils/synthetic Tag: xalan3
                        JavaUtils.java
  Added:       java/src/org/apache/xml/dtm Tag: xalan3 DTMSequence.java
                        DTMSequenceEmpty.java XType.java
                        XTypeConverter.java
               java/src/org/apache/xml/dtm/ref/xni2dtm Tag: xalan3
                        AbstractSchema.java
                        DOMValidationConfigurationSwipedFromXerces.java
                        DTM2XNI.java DTM_XSequence.java
                        ElemImportSchema.java FuncData.java
                        FuncInstanceOf.java FuncTreatAs.java
                        FuncValidate.java NamespaceSupportAtDTMNode.java
                        XNI2DTM.java XNISource.java XPath2Type.java
               java/src/org/apache/xml/utils Tag: xalan3
                        CharacterBlockEnumeration.java DateTimeObj.java
                        Duration.java SparseVector.java
  Log:
  Xalan3 specific additions and updates
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.4.1   +75 -2     xml-xalan/java/src/org/apache/xml/dtm/DTM.java
  
  Index: DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTM.java,v
  retrieving revision 1.7
  retrieving revision 1.7.4.1
  diff -u -r1.7 -r1.7.4.1
  --- DTM.java	10 Apr 2002 20:33:15 -0000	1.7
  +++ DTM.java	14 Aug 2002 19:45:33 -0000	1.7.4.1
  @@ -57,6 +57,7 @@
   package org.apache.xml.dtm;
   
   import org.apache.xml.utils.XMLString;
  +import org.apache.xpath.objects.*;
   
   import javax.xml.transform.SourceLocator;
   
  @@ -192,9 +193,11 @@
     public static final short NAMESPACE_NODE = 13;
     
     /**
  -   * The number of valid nodetypes.
  +   * The number of valid nodetypes. REMEMBER TO UPDATE THIS if you add more
  +   * node types.
      */
     public static final short  NTYPES = 14;
  +  
   
     // ========= DTM Implementation Control Functions. ==============
     // %TBD% RETIRED -- do via setFeature if needed. Remove from impls.
  @@ -217,6 +220,7 @@
      * @param value an <code>Object</code> value
      */
     public void setProperty(String property, Object value);
  +  
   
     // ========= Document Navigation Functions =========
   
  @@ -999,6 +1003,75 @@
      * to shutdown any subsystem activity that may of been assoiated with
      * the active DTM Implementation.
      */
  +  public void documentRelease();
  +   
  +   
  +   /**
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +    * Query schema type name of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the expanded-QName (namespace URI
  +    *	rather than prefix) of the type actually
  +    *    resolved in the instance document. Note that this may be derived from,
  +    *	rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeName(int nodeHandle);
  +  	
  +  /** 
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +	* Query schema type namespace of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the namespace URI
  +    *	of the type actually resolved in the instance document. This may
  +    * 	be null if the default/unspecified namespace was used.
  +    *    Note that this may be derived from,
  +    *	rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeNamespace(int nodeHandle);
  +
  +  /** EXPERIMENTAL XPath2 Support: Query schema type localname of a given node.
  +   * 
  +   * %REVIEW% Is this actually needed?
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return null if no type known, else returns the localname of the type
  +   *    resolved in the instance document. Note that this may be derived from,
  +   *	rather than identical to, the type declared in the schema.
  +   */
  +  public String getSchemaTypeLocalName(int nodeHandle);
  +
  +  /** EXPERIMENTAL XPath2 Support: Query whether node's type is derived from a specific type
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @param namespace String containing URI of namespace for the type we're intersted in
  +   * @param localname String containing local name for the type we're intersted in
  +   * @return true if node has a Schema Type which equals or is derived from 
  +   *	the specified type. False if the node has no type or that type is not
  +   * 	derived from the specified type.
  +   */
  +  public boolean isNodeSchemaType(int nodeHandle, String namespace, String localname);
  +  
  +  /** EXPERIMENTAL XPath2 Support: Retrieve the typed value(s), based on the schema
  +   *  type.
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return XSequence object containing one or more values and their type
  +   * information. If no typed value is available, returns an empty sequence.
  +   * */
  +  public DTMSequence getTypedValue(int nodeHandle);
  +
  +  /** Query which DTMManager this DTM is currently being handled by.
  +   * 
  +   * @return a DTMManager, or null if this is a "stand-alone" DTM.
  +   */
  +  public DTMManager getManager();
   
  -   public void documentRelease();
   }
  
  
  
  1.2.16.1  +18 -0     xml-xalan/java/src/org/apache/xml/dtm/DTMFilter.java
  
  Index: DTMFilter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMFilter.java,v
  retrieving revision 1.2
  retrieving revision 1.2.16.1
  diff -u -r1.2 -r1.2.16.1
  --- DTMFilter.java	12 Jun 2001 19:15:40 -0000	1.2
  +++ DTMFilter.java	14 Aug 2002 19:45:33 -0000	1.2.16.1
  @@ -175,6 +175,24 @@
      * possibly, to create a DTM-specific field for these additional bits.
      */
     public static final int SHOW_BYFUNCTION = 0x00010000;
  +  
  +  /**
  +   * Special bit for supporting "item" in ItemType..
  +   * <p>
  +   * %REVIEW% Might be safer to start from higher bits and work down,
  +   * to leave room for the DOM to expand its set of constants... Or,
  +   * possibly, to create a DTM-specific field for these additional bits.
  +   */
  +  public static final int SHOW_ITEM = 0x00020000;
  +
  +  /**
  +   * Special bit for supporting "untyped" in ItemType..
  +   * <p>
  +   * %REVIEW% Might be safer to start from higher bits and work down,
  +   * to leave room for the DOM to expand its set of constants... Or,
  +   * possibly, to create a DTM-specific field for these additional bits.
  +   */
  +  public static final int SHOW_UNTYPED = 0x00040000;
   
     /**
      * Test whether a specified node is visible in the logical view of a
  
  
  
  1.4.14.1  +6 -4      xml-xalan/java/src/org/apache/xml/dtm/DTMIterator.java
  
  Index: DTMIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMIterator.java,v
  retrieving revision 1.4
  retrieving revision 1.4.14.1
  diff -u -r1.4 -r1.4.14.1
  --- DTMIterator.java	7 Aug 2001 19:16:42 -0000	1.4
  +++ DTMIterator.java	14 Aug 2002 19:45:33 -0000	1.4.14.1
  @@ -256,16 +256,18 @@
     //========= Random Access ==========
   
     /**
  -   * If setShouldCacheNodes(true) is called, then nodes will
  +   * If setShouldCache(true) is called, then nodes will
      * be cached, enabling random access, and giving the ability to do 
      * sorts and the like.  They are not cached by default.
      *
  -   * %REVIEW% Shouldn't the other random-access methods throw an exception
  -   * if they're called on a DTMIterator with this flag set false?
  +   * %REVIEW% Should random-access methods 
  +   * (specifically setCurrentPosition() and item())
  +   * throw an exception if they're called on a DTMIterator 
  +   * with this flag set false?
      *
      * @param b true if the nodes should be cached.
      */
  -  public void setShouldCacheNodes(boolean b);
  +  public void setShouldCache(boolean b);
     
     /**
      * Tells if this iterator can have nodes added to it or set via 
  
  
  
  1.10.2.1  +1 -1      xml-xalan/java/src/org/apache/xml/dtm/DTMManager.java
  
  Index: DTMManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMManager.java,v
  retrieving revision 1.10
  retrieving revision 1.10.2.1
  diff -u -r1.10 -r1.10.2.1
  --- DTMManager.java	13 May 2002 22:17:42 -0000	1.10
  +++ DTMManager.java	14 Aug 2002 19:45:33 -0000	1.10.2.1
  @@ -486,7 +486,7 @@
             System.err.println("DTM: found  " + serviceId);
           }
   
  -        BufferedReader rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
  +        BufferedReader rd = new BufferedReader(new InputStreamReader(is,"UTF-8"));
   
           foundFactory = rd.readLine();
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +131 -0    xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMSequence.java
  
  
  
  
  1.1.2.1   +131 -0    xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMSequenceEmpty.java
  
  
  
  
  1.1.2.1   +342 -0    xml-xalan/java/src/org/apache/xml/dtm/Attic/XType.java
  
  
  
  
  1.1.2.1   +252 -0    xml-xalan/java/src/org/apache/xml/dtm/Attic/XTypeConverter.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.29.2.1  +102 -26   xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
  
  Index: DTMDefaultBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
  retrieving revision 1.29
  retrieving revision 1.29.2.1
  diff -u -r1.29 -r1.29.2.1
  --- DTMDefaultBase.java	16 May 2002 23:38:41 -0000	1.29
  +++ DTMDefaultBase.java	14 Aug 2002 19:45:34 -0000	1.29.2.1
  @@ -56,33 +56,28 @@
    */
   package org.apache.xml.dtm.ref;
   
  -import org.apache.xml.dtm.*;
  -import org.apache.xml.utils.SuballocatedIntVector;
  -import org.apache.xml.utils.SuballocatedByteVector;
  -import org.apache.xml.utils.IntStack;
  -import org.apache.xml.utils.BoolStack;
  -import org.apache.xml.utils.StringBufferPool;
  -import org.apache.xml.utils.FastStringBuffer;
  -import org.apache.xml.utils.TreeWalker;
  -import org.apache.xml.utils.QName;
  -import org.apache.xml.utils.XMLCharacterRecognizer;
  -
  +import java.io.File;
  +import java.io.FileOutputStream;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintStream;
   import java.util.Vector;
   
  -import org.xml.sax.ContentHandler;
  -
  -import org.apache.xml.utils.NodeVector;
  -
   import javax.xml.transform.Source;
   
  -import org.apache.xml.utils.XMLString;
  -import org.apache.xml.utils.XMLStringFactory;
  -
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xalan.res.XSLTErrorResources;
  -
  -import java.io.*; // for dumpDTM
  -
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMAxisTraverser;
  +import org.apache.xml.dtm.DTMException;
  +import org.apache.xml.dtm.DTMManager;
  +import org.apache.xml.dtm.DTMSequence;
  +import org.apache.xml.dtm.DTMWSFilter;
  +import org.apache.xml.utils.BoolStack;
  +import org.apache.xml.utils.SuballocatedIntVector;
  +import org.apache.xml.utils.XMLString;
  +import org.apache.xml.utils.XMLStringFactory;
  +import org.apache.xpath.objects.XSequence;
   /**
    * The <code>DTMDefaultBase</code> class serves as a helper base for DTMs.
    * It sets up structures for navigation and type, while leaving data
  @@ -460,7 +455,7 @@
       if (NULL != info)
         return m_expandedNameTable.getType(info);
       else
  -      return NULL;
  +      return (short)NULL;
     }
   
     /**
  @@ -820,7 +815,7 @@
           case DTM.NOTATION_NODE :
             typestring = "NOTATION";
             break;
  -        case DTM.NULL :
  +        case (short)DTM.NULL:
             typestring = "null";
             break;
           case DTM.PROCESSING_INSTRUCTION_NODE :
  @@ -1401,7 +1396,7 @@
      */
     public int getDocument()
     {
  -    return m_dtmIdent.elementAt(0); // makeNodeHandle(0)
  +    return m_dtmIdent.elementAt(0);
     }
   
     /**
  @@ -1439,6 +1434,20 @@
     }
   
     /**
  +   * Given a node identifier, find the owning document node.  Unlike the DOM,
  +   * this considers the owningDocument of a Document to be itself. Note that
  +   * in shared DTMs this may not be zero.
  +   *
  +   * @param nodeId the id of the node.
  +   * @return int Node identifier of owning document, or the nodeId if it is
  +   *             a Document.
  +   */
  +  protected int _documentRoot(int nodeIdentifier)
  +  {
  +    return 0;
  +  }
  +
  +  /**
      * Get the string-value of a node as a String object
      * (see http://www.w3.org/TR/xpath#data-model
      * for the definition of a node's string-value).
  @@ -2128,8 +2137,6 @@
   
   	 /** Query which DTMManager this DTM is currently being handled by.
   	  * 
  -	  * %REVEW% Should this become part of the base DTM API?
  -	  * 
   	  * @return a DTMManager, or null if this is a "stand-alone" DTM.
   	  */
   	 public DTMManager getManager()
  @@ -2148,4 +2155,73 @@
   		 if(m_mgr==null) return null;
   		 return m_dtmIdent;
   	 }
  +	 
  +
  +  /**
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +    * Query schema type name of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the expanded-QName (namespace URI
  +    *	rather than prefix) of the type actually
  +    *    resolved in the instance document. Note that this may be derived from,
  +    *	rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeName(int nodeHandle)
  +   { return null; }
  +  	
  +  /** 
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +	* Query schema type namespace of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the namespace URI
  +    *	of the type actually resolved in the instance document. This may
  +    * 	be null if the default/unspecified namespace was used.
  +    *    Note that this may be derived from,
  +    *	rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeNamespace(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query schema type localname of a given node.
  +   * 
  +   * %REVIEW% Is this actually needed?
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return null if no type known, else returns the localname of the type
  +   *    resolved in the instance document. Note that this may be derived from,
  +   *	rather than identical to, the type declared in the schema.
  +   */
  +  public String getSchemaTypeLocalName(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query whether node's type is derived from a specific type
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @param namespace String containing URI of namespace for the type we're intersted in
  +   * @param localname String containing local name for the type we're intersted in
  +   * @return true if node has a Schema Type which equals or is derived from 
  +   *	the specified type. False if the node has no type or that type is not
  +   * 	derived from the specified type.
  +   */
  +  public boolean isNodeSchemaType(int nodeHandle, String namespace, String localname)
  +   { return false; }
  +  
  +  /** EXPERIMENTAL XPath2 Support: Retrieve the typed value(s), based on the schema
  +   *  type.
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return XSequence object containing one or more values and their type
  +   * information. If no typed value is available, returns an empty sequence.
  +   * */
  +  public DTMSequence getTypedValue(int nodeHandle)
  +   {return DTMSequence.EMPTY;}
  +	 
   }
  
  
  
  1.15.2.1  +9 -11     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java
  
  Index: DTMDefaultBaseIterators.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseIterators.java,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- DTMDefaultBaseIterators.java	10 Jul 2002 18:57:00 -0000	1.15
  +++ DTMDefaultBaseIterators.java	14 Aug 2002 19:45:34 -0000	1.15.2.1
  @@ -1491,6 +1491,8 @@
           else
             _startNode = getParent(node);
   
  +        _currentNode = getDocumentRoot(node);
  +        
           node = _startNode;
           while (node != END)
           {
  @@ -1499,10 +1501,6 @@
           }
           m_ancestorsPos = m_ancestors.size()-1;
   
  -        _currentNode = (m_ancestorsPos>=0)
  -                               ? m_ancestors.elementAt(m_ancestorsPos)
  -                               : DTM.NULL;
  -
           return resetPosition();
         }
   
  @@ -1518,11 +1516,10 @@
       public DTMAxisIterator reset()
       {
   
  +      _currentNode = getDocumentRoot(_startNode);
  +            
         m_ancestorsPos = m_ancestors.size()-1;
   
  -      _currentNode = (m_ancestorsPos>=0) ? m_ancestors.elementAt(m_ancestorsPos)
  -                                         : DTM.NULL;
  -
         return resetPosition();
       }
   
  @@ -1536,10 +1533,11 @@
   
         int next = _currentNode;
         
  -      int pos = --m_ancestorsPos;
  -
  -      _currentNode = (pos >= 0) ? m_ancestors.elementAt(m_ancestorsPos)
  -                                : DTM.NULL;
  +      int pos = m_ancestorsPos--;
  +      if(pos < 0)
  +         _currentNode = DTM.NULL;
  +      else
  +     	 _currentNode = m_ancestors.elementAt(pos);
         
         return returnNode(next);
       }
  
  
  
  1.11.2.1  +20 -18    xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseTraversers.java
  
  Index: DTMDefaultBaseTraversers.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBaseTraversers.java,v
  retrieving revision 1.11
  retrieving revision 1.11.2.1
  diff -u -r1.11 -r1.11.2.1
  --- DTMDefaultBaseTraversers.java	7 Jun 2002 17:13:54 -0000	1.11
  +++ DTMDefaultBaseTraversers.java	14 Aug 2002 19:45:34 -0000	1.11.2.1
  @@ -195,9 +195,8 @@
       }
   
       if (null == traverser)
  -      throw new DTMException(XSLMessages.createMessage(XSLTErrorResources.ER_AXIS_TRAVERSER_NOT_SUPPORTED, new Object[]{Axis.names[axis]}));
  -      // "Axis traverser not supported: "
  -      //                       + Axis.names[axis]);
  +      throw new DTMException("Axis traverser not supported: "
  +                             + Axis.names[axis]);
   
       m_traversers[axis] = traverser;
   
  @@ -1257,7 +1256,8 @@
   			// compute in ID space
         int subtreeRootIdent = makeNodeIdentity(context);
   
  -      for (current = makeNodeIdentity(current) - 1; current >= 0; current--)
  +      int doc=_documentRoot(subtreeRootIdent);
  +      for (current = makeNodeIdentity(current) - 1; current >= doc; current--)
         {
           short type = _type(current);
   
  @@ -1286,7 +1286,8 @@
   			// Compute in ID space
         int subtreeRootIdent = makeNodeIdentity(context);
   
  -      for (current = makeNodeIdentity(current) - 1; current >= 0; current--)
  +      int doc=_documentRoot(subtreeRootIdent);
  +      for (current = makeNodeIdentity(current) - 1; current >= doc; current--)
         {
           int exptype = m_exptype.elementAt(current);
   
  @@ -1321,7 +1322,8 @@
   			// Compute in ID space
         int subtreeRootIdent = makeNodeIdentity(context );
   
  -      for (current = makeNodeIdentity(current) - 1; current >= 0; current--)
  +      int doc=_documentRoot(subtreeRootIdent);
  +      for (current = makeNodeIdentity(current) - 1; current >= doc; current--)
         {
           short type = _type(current);
   
  @@ -1349,7 +1351,8 @@
   			// Compute in ID space
         int subtreeRootIdent = makeNodeIdentity(context);
   
  -      for (current = makeNodeIdentity(current) - 1; current >= 0; current--)
  +      int doc=_documentRoot(subtreeRootIdent);
  +      for (current = makeNodeIdentity(current) - 1; current >= doc; current--)
         {
           int exptype = m_exptype.elementAt(current);
   
  @@ -1486,7 +1489,7 @@
        */
       public int first(int context)
       {
  -      return getDocument();
  +      return getDocumentRoot(context);
       }
   
       /**
  @@ -1499,7 +1502,7 @@
        */
       public int first(int context, int expandedTypeID)
       {
  -      return (getExpandedTypeID(getDocument()) == expandedTypeID)
  +      return (getExpandedTypeID(getDocumentRoot(context)) == expandedTypeID)
                ? context : next(context, context, expandedTypeID);
       }
   
  @@ -1619,8 +1622,7 @@
        */
       protected int getSubtreeRoot(int handle)
       {
  -			// %REVIEW% Shouldn't this always be 0?
  -      return makeNodeIdentity(getDocument());
  +      return _documentRoot(makeNodeIdentity(handle));
       }
   
       /**
  @@ -1632,7 +1634,7 @@
        */
       public int first(int context)
       {
  -      return getDocument();
  +      return getDocumentRoot(context);
       }
       
       /**
  @@ -1653,7 +1655,7 @@
       {
         if (isIndexed(expandedTypeID))
         {
  -        int identity = 0;
  +        int identity = _documentRoot(makeNodeIdentity(context));
           int firstPotential = getFirstPotential(identity);
   
           return makeNodeHandle(getNextIndexed(identity, firstPotential, expandedTypeID));
  @@ -1681,7 +1683,7 @@
        */
       protected int getFirstPotential(int identity)
       {
  -      return _firstch(0);
  +      return _firstch(_documentRoot(identity));
       }
   
       /**
  @@ -1691,7 +1693,7 @@
        */
       protected int getSubtreeRoot(int handle)
       {
  -      return 0;
  +      return _documentRoot(makeNodeIdentity(handle));
       }
   
       /**
  @@ -1703,7 +1705,7 @@
        */
       public int first(int context)
       {
  -      return makeNodeHandle(_firstch(0));
  +      return makeNodeHandle(_firstch(_documentRoot(makeNodeIdentity(context))));
       }
       
       /**
  @@ -1724,13 +1726,13 @@
       {
         if (isIndexed(expandedTypeID))
         {
  -        int identity = 0; 
  +        int identity = _documentRoot(makeNodeIdentity(context)); 
           int firstPotential = getFirstPotential(identity);
   
           return makeNodeHandle(getNextIndexed(identity, firstPotential, expandedTypeID));
         }
   
  -      int root = getDocument(); 
  +      int root = getDocumentRoot(context); 
         return next(root, root, expandedTypeID);
       }
       
  
  
  
  1.7.10.1  +94 -16    xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDocumentImpl.java
  
  Index: DTMDocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDocumentImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.7.10.1
  diff -u -r1.7 -r1.7.10.1
  --- DTMDocumentImpl.java	8 Feb 2002 23:33:50 -0000	1.7
  +++ DTMDocumentImpl.java	14 Aug 2002 19:45:34 -0000	1.7.10.1
  @@ -56,24 +56,22 @@
    */
   package org.apache.xml.dtm.ref;
   
  -import org.apache.xml.dtm.*;
  -import java.util.Hashtable;
  -//import java.util.Stack;
  -import java.util.Vector;
  -
   import javax.xml.transform.SourceLocator;
   
  -import org.apache.xml.dtm.ref.ChunkedIntArray;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.DTMAxisTraverser;
  +import org.apache.xml.dtm.DTMManager;
  +import org.apache.xml.dtm.DTMSequence;
  +import org.apache.xml.dtm.DTMWSFilter;
   import org.apache.xml.utils.FastStringBuffer;
  -
  +import org.apache.xml.utils.XMLString;
  +import org.apache.xml.utils.XMLStringFactory;
  +import org.xml.sax.Attributes;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.Locator;
  -import org.xml.sax.Attributes;
   import org.xml.sax.ext.LexicalHandler;
   
  -import org.apache.xml.utils.XMLString;
  -import org.apache.xml.utils.XMLStringFactory;
  -
   /**
    * This is the implementation of the DTM document interface.  It receives
    * requests from an XML content handler similar to that of an XML DOM or SAX parser
  @@ -148,6 +146,8 @@
      * @see setIncrementalSAXSource
      */
     private IncrementalSAXSource m_incrSAXSource=null;
  +  
  +  DTMManager m_manager;
   
   
           // ========= DTM data structure declarations. ==============
  @@ -196,11 +196,15 @@
            * DTMManager's responsibility to assign a unique number to each
            * document.
            */
  -        public DTMDocumentImpl(DTMManager mgr, int documentNumber,
  -                               DTMWSFilter whiteSpaceFilter,
  -                               XMLStringFactory xstringfactory){
  -                initDocument(documentNumber);	 // clear nodes and document handle
  -                m_xsf = xstringfactory;
  +        public DTMDocumentImpl(
  +          DTMManager mgr,
  +          int documentNumber,
  +          DTMWSFilter whiteSpaceFilter,
  +          XMLStringFactory xstringfactory)
  +        {
  +          m_manager = mgr;
  +          initDocument(documentNumber); // clear nodes and document handle
  +          m_xsf = xstringfactory;
           }
   
     /** Bind a IncrementalSAXSource to this DTM. If we discover we need nodes
  @@ -2445,5 +2449,79 @@
      {
      }
   
  +   /**
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +    * Query schema type name of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the expanded-QName (namespace URI
  +    *	rather than prefix) of the type actually
  +    *    resolved in the instance document. Note that this may be derived from,
  +    *	rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeName(int nodeHandle)
  +   { return null; }
  +  	
  +  /** 
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +	* Query schema type namespace of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the namespace URI
  +    *	of the type actually resolved in the instance document. This may
  +    * 	be null if the default/unspecified namespace was used.
  +    *    Note that this may be derived from,
  +    *	rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeNamespace(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query schema type localname of a given node.
  +   * 
  +   * %REVIEW% Is this actually needed?
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return null if no type known, else returns the localname of the type
  +   *    resolved in the instance document. Note that this may be derived from,
  +   *	rather than identical to, the type declared in the schema.
  +   */
  +  public String getSchemaTypeLocalName(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query whether node's type is derived from a specific type
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @param namespace String containing URI of namespace for the type we're intersted in
  +   * @param localname String containing local name for the type we're intersted in
  +   * @return true if node has a Schema Type which equals or is derived from 
  +   *	the specified type. False if the node has no type or that type is not
  +   * 	derived from the specified type.
  +   */
  +  public boolean isNodeSchemaType(int nodeHandle, String namespace, String localname)
  +   { return false; }
  +  
  +  /** EXPERIMENTAL XPath2 Support: Retrieve the typed value(s), based on the schema
  +   *  type.
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return XSequence object containing one or more values and their type
  +   * information. If no typed value is available, returns an empty sequence.
  +   * */
  +  public DTMSequence getTypedValue(int nodeHandle)
  +   {return DTMSequence.EMPTY;}
  +
  +  /**
  +   * @see org.apache.xml.dtm.DTM#getManager()
  +   */
  +  public DTMManager getManager()
  +  {
  +    return m_manager;
  +  }
   
   }
  
  
  
  1.41.6.1  +291 -191  xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
  retrieving revision 1.41
  retrieving revision 1.41.6.1
  diff -u -r1.41 -r1.41.6.1
  --- DTMManagerDefault.java	10 Apr 2002 13:30:42 -0000	1.41
  +++ DTMManagerDefault.java	14 Aug 2002 19:45:34 -0000	1.41.6.1
  @@ -73,12 +73,13 @@
   import org.apache.xml.utils.SystemIDResolver;
   import org.apache.xml.dtm.ref.dom2dtm.DOM2DTM;
   import org.apache.xml.dtm.ref.sax2dtm.SAX2DTM;
  -import org.apache.xml.dtm.ref.sax2dtm.SAX2RTFDTM;
  +//import org.apache.xml.dtm.ref.sax2dtm.SAX2RTFDTM;
   
  -/**************************************************************
  +/**************************************************************/
   // EXPERIMENTAL 3/22/02
   import org.apache.xml.dtm.ref.xni2dtm.XNI2DTM;
  -**************************************************************/
  +import org.apache.xml.dtm.ref.xni2dtm.XNISource;
  +/**************************************************************/
   
   // W3C DOM
   import org.w3c.dom.Document;
  @@ -121,12 +122,10 @@
    * */
   public class DTMManagerDefault extends DTMManager
   {
  -  //static final boolean JKESS_XNI_EXPERIMENT=true;
  -
     /** Set this to true if you want a dump of the DTM after creation. */
     private static final boolean DUMPTREE = false;
   
  -  /** Set this to true if you want a basic diagnostics. */
  +  /** Set this to true if you want basic diagnostics. */
     private static final boolean DEBUG = false;
   
     /**
  @@ -275,7 +274,6 @@
                                    DTMWSFilter whiteSpaceFilter,
                                    boolean incremental, boolean doIndexing)
     {
  -
       if(DEBUG && null != source)
         System.out.println("Starting "+
                            (unique ? "UNIQUE" : "shared")+
  @@ -286,243 +284,345 @@
       int dtmPos = getFirstFreeDTMID();
       int documentID = dtmPos << IDENT_DTM_NODE_BITS;
   
  -    if ((null != source) && source instanceof DOMSource)
  +    if (source instanceof DOMSource)
       {
  +      // Simplest case: Wrap a DTM around an existing DOM.
  +      //
  +      // %REVIEW% May get more complicated if we start trying to match
  +      // DOM2DTM implementations against specific DOM implementations,
  +      // eg taking advantage of a particular DOM's hashability or
  +      // userData hooks.
         DOM2DTM dtm = new DOM2DTM(this, (DOMSource) source, documentID,
                                   whiteSpaceFilter, xstringFactory, doIndexing);
  -
         addDTM(dtm, dtmPos, 0);
  -
  -      //      if (DUMPTREE)
  -      //      {
  -      //        dtm.dumpDTM();
  -      //      }
  -
         return dtm;
       }
  -    else
  +    
  +    if(source==null)
       {
  -      boolean isSAXSource = (null != source)
  -        ? (source instanceof SAXSource) : true;
  -      boolean isStreamSource = (null != source)
  -        ? (source instanceof StreamSource) : false;
  +      // Set up a DTM which will accept a SAX input stream to be bound later.
  +      // Note that XNI is _not_ currently an option in this case.
  +      SAX2DTM dtm;
  +
  +      if(unique && !incremental && !doIndexing)
  +      {
  +        // Special case to support RTF construction into shared DTM.
  +        // It should actually still work for other uses,
  +        // but may be slightly deoptimized relative to the base
  +        // to allow it to deal with carrying multiple documents.
  +        //
  +        // %REVIEW% This is a sloppy way to request this mode;
  +        // we need to consider architectural improvements.
  +        dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
  +                             xstringFactory, doIndexing, true);
  +        if(DEBUG)
  +        	System.out.println("CREATING RTF DTM: "+dtm);
  +      }
  +      else // Create the basic SAX2DTM.
  +      {
  +        dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
  +                          xstringFactory, doIndexing);
  +      }
  +
  +      addDTM(dtm, dtmPos, 0);
   
  -      if (isSAXSource || isStreamSource)
  +      // If the source is null, but they requested an incremental build,
  +      // then we still want to set up the IncrementalSAXSource stuff
  +      // so it can be bound later.
  +      if (this.m_incremental && incremental)
         {
  -        XMLReader reader;
  -        InputSource xmlSource;
  +        IncrementalSAXSource coParser=new IncrementalSAXSource_Filter();
  +        dtm.setIncrementalSAXSource(coParser);
  +      }
  +      
  +      return dtm;
  +    }
   
  -        if (null == source)
  +    if (source instanceof XNISource)
  +    {
  +    	XNISource xsrc=(XNISource)source;
  +    	
  +        XNI2DTM dtm = new XNI2DTM(this, source, documentID, whiteSpaceFilter,
  +                              xstringFactory, doIndexing);
  +        addDTM(dtm, dtmPos, 0);
  +        
  +        xsrc.setDocumentHandler(dtm);
  +        xsrc.setErrorHandler(dtm);
  +        
  +        // XNI's document scanner does support incremental.
  +        // Would require yet another flavor of incremental-source to
  +        // glue it to our APIs. For now, just run it to completion.
  +        // MOVE THIS DOWN !!!!!
  +        // %REVIEW%
  +        try
           {
  -          xmlSource = null;
  -          reader = null;
  +	        xsrc.reset();
  +	        xsrc.scanDocument(true);
           }
  -        else
  +        catch (RuntimeException re)
           {
  -          reader = getXMLReader(source);
  -          xmlSource = SAXSource.sourceToInputSource(source);
  -
  -          String urlOfSource = xmlSource.getSystemId();
  -
  -          if (null != urlOfSource)
  -          {
  -            try
  -            {
  -              urlOfSource = SystemIDResolver.getAbsoluteURI(urlOfSource);
  -            }
  -            catch (Exception e)
  -            {
  -
  -              // %REVIEW% Is there a better way to send a warning?
  -              System.err.println("Can not absolutize URL: " + urlOfSource);
  -            }
  -
  -            xmlSource.setSystemId(urlOfSource);
  -          }
  +          throw re;
  +        }
  +        catch (Exception e)
  +        {
  +          throw new org.apache.xml.utils.WrappedRuntimeException(e);
           }
  +          
  +        return dtm;
  +    } // XNISource
   
  -        SAX2DTM dtm;
  -        if(source==null && unique && !incremental && !doIndexing)
  +    if (source instanceof StreamSource)
  +    {
  +      // Try processing it as XNI first, to get PSVI information!
  +      
  +      // %REVIEW% Arguably, we shouldn't go XNI (or at least not
  +      // Schema-validated?) unless it's requested and/or XSLT2/XPath2
  +      // are in use, since the schema processor is so expensive.
  +      // Unfortunately, we don't have the XPathContext here to ask
  +      // which version of the language is in use...
  +
  +      InputSource xmlSource = SAXSource.sourceToInputSource(source);
  +      String urlOfSource = xmlSource.getSystemId();
  +      if (null != urlOfSource)
  +      {
  +        try
           {
  -          // Special case to support RTF construction into shared DTM.
  -          // It should actually still work for other uses,
  -          // but may be slightly deoptimized relative to the base
  -          // to allow it to deal with carrying multiple documents.
  -          //
  -          // %REVIEW% This is a sloppy way to request this mode;
  -          // we need to consider architectural improvements.
  -          dtm = new SAX2RTFDTM(this, source, documentID, whiteSpaceFilter,
  -                               xstringFactory, doIndexing);
  -        }
  -        /**************************************************************
  -        // EXPERIMENTAL 3/22/02
  -        else if(JKESS_XNI_EXPERIMENT && m_incremental)
  -        {        	
  -          dtm = new XNI2DTM(this, source, documentID, whiteSpaceFilter,
  -                            xstringFactory, doIndexing);
  -        }
  -        **************************************************************/
  -        else // Create the basic SAX2DTM.
  -        {
  -          dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
  -                            xstringFactory, doIndexing);
  -        }
  -
  -        // Go ahead and add the DTM to the lookup table.  This needs to be
  -        // done before any parsing occurs. Note offset 0, since we've just
  -        // created a new DTM.
  +          urlOfSource=SystemIDResolver.getAbsoluteURI(urlOfSource);
  +        }
  +        catch (Exception e)
  +        {
  +          // %REVIEW% Is there a better way to send a warning?
  +          System.err.println("Can not absolutize URL: " + urlOfSource);
  +        }
  +        xmlSource.setSystemId(urlOfSource);
  +      } // urlOfSource fixup
  +      
  +      // %REVIEW% Need a better test for whether Xerces2 is available
  +      // This one involves creating a SAX reader, then discarding
  +      // it in order to build a lower-level XNI reader. Wasteful.
  +      XMLReader reader = getXMLReader(source);
  +      if(reader.getClass().getName().equals("org.apache.xerces.parsers.SAXParser")) 
  +      {         
  +        DTM dtm = new XNI2DTM(this, source, documentID, whiteSpaceFilter,
  +                              xstringFactory, doIndexing);
           addDTM(dtm, dtmPos, 0);
   
  -
  -        boolean haveXercesParser =
  -          (null != reader)
  -          && (reader.getClass().getName().equals("org.apache.xerces.parsers.SAXParser") );
  -        
  -        if (haveXercesParser)
  -          incremental = true;  // No matter what.  %REVIEW%
  -        
  -        // If the reader is null, but they still requested an incremental build,
  -        // then we still want to set up the IncrementalSAXSource stuff.
  -        if (this.m_incremental && incremental /* || ((null == reader) && incremental) */)
           {
  -          IncrementalSAXSource coParser=null;
  -
  -          if (haveXercesParser)
  -          {
  -            // IncrementalSAXSource_Xerces to avoid threading.
  -            try {
  -              coParser=org.apache.xml.dtm.ref.IncrementalSAXSource_Xerces.createIncrementalSAXSource();
  -            }  catch( Exception ex ) {
  -              ex.printStackTrace();
  -              coParser=null;
  -            }
  -          }
  -
  -          if( coParser==null ) {
  -            // Create a IncrementalSAXSource that will run on the secondary thread.
  -            if (null == reader)
  -              coParser = new IncrementalSAXSource_Filter();
  -            else
  -            {
  -              IncrementalSAXSource_Filter filter=new IncrementalSAXSource_Filter();
  -              filter.setXMLReader(reader);
  -              coParser=filter;
  -            }
  -
  -          }
  -
  -			
  -        /**************************************************************
  -        // EXPERIMENTAL 3/22/02
  -          if(JKESS_XNI_EXPERIMENT && m_incremental & 
  -          	dtm instanceof XNI2DTM && 
  -          	coParser instanceof IncrementalSAXSource_Xerces)
  -          {          	
  -       		org.apache.xerces.xni.parser.XMLPullParserConfiguration xpc=
  -       			((IncrementalSAXSource_Xerces)coParser).getXNIParserConfiguration();
  -       		if(xpc!=null)	
  -       			// Bypass SAX; listen to the XNI stream
  -          		((XNI2DTM)dtm).setIncrementalXNISource(xpc);
  -          	else
  -          		// Listen to the SAX stream (will fail, diagnostically...)
  -				dtm.setIncrementalSAXSource(coParser);
  -          } else
  -          ***************************************************************/
  +          // %REVIEW% Currently this creates a new instance of Xerces, since
  +          // there's no way to access the XNI APIs of an existing SAXParser.
  +          // This is wasteful since a reader as already created.
  +          // Can we rationalize this flow? Can we get Xerces improved?
  +          IncrementalSAXSource_Xerces coParser;
  +          coParser=(IncrementalSAXSource_Xerces)IncrementalSAXSource_Xerces.createIncrementalSAXSource();
  +
  +          // Bypass SAX; listen to the XNI stream
  +          // %REVIEW% This shouldn't have a compile-time dependency on Xerces2!
  +          // Can we fix it? (Change to Object?)
  +          org.apache.xerces.xni.parser.XMLPullParserConfiguration xpc=
  +            ((IncrementalSAXSource_Xerces)coParser).getXNIParserConfiguration();
  +          ((XNI2DTM)dtm).setIncrementalXNISource(xpc);
             
  -          // Have the DTM set itself up as the IncrementalSAXSource's listener.
  -          dtm.setIncrementalSAXSource(coParser);
  -
  -          if (null == xmlSource)
  -          {
  -
  -            // Then the user will construct it themselves.
  -            return dtm;
  -          }
  -
  -          if(null == reader.getErrorHandler())
  -            reader.setErrorHandler(dtm);
  -          reader.setDTDHandler(dtm);
  -
             try
             {
  -
  -            // Launch parsing coroutine.  Launches a second thread,
  -            // if we're using IncrementalSAXSource.filter().
  +            // Launch parsing coroutine. 
               coParser.startParse(xmlSource);
  +            
  +            // %REVIEW% Kluge: Run nominal incremental setup in non-incremental
  +            // mode. Simplifies this code, but it's a badly mixed metaphor.
  +	        if(!this.m_incremental)
  +	        	coParser.deliverAllNodes();
             }
             catch (RuntimeException re)
             {
  -
  -            dtm.clearCoRoutine();
  -
               throw re;
             }
             catch (Exception e)
             {
  -
  -            dtm.clearCoRoutine();
  -
               throw new org.apache.xml.utils.WrappedRuntimeException(e);
             }
  +          
  +          return dtm;
  +        } // if incremental
  +        
  +      } // If Xerces2
  +      
  +      // Fallback: Turn it into a SAX request. (We _could_ just let
  +      // it fall through unchanged and put an OR in SAX case, as I do
  +      // when disabling this block for debugging purposes... but
  +      // I think making it explicit may be clearer.
  +      source=new SAXSource(reader,xmlSource);
  +      // FALL THROUGH to SAX processing
  +    } // if streamsource
  +        
  +        
  +    if ((source instanceof SAXSource) 
  +    	// || (!JJK_ENABLE_XNI && source instanceof StreamSource) // debug fallback
  +    	)
  +    {
  +      XMLReader reader;
  +      InputSource xmlSource;
  +      SAX2DTM dtm;
  +      
  +      reader = getXMLReader(source);
  +      xmlSource = SAXSource.sourceToInputSource(source);
  +      
  +      String urlOfSource = xmlSource.getSystemId();
  +      if (null != urlOfSource)
  +      {
  +        try
  +        {
  +          urlOfSource=SystemIDResolver.getAbsoluteURI(urlOfSource);
           }
  -        else
  +        catch (Exception e)
           {
  -          if (null == reader)
  -          {
  +          // %REVIEW% Is there a better way to send a warning?
  +          System.err.println("Can not absolutize URL: " + urlOfSource);
  +        }
  +        xmlSource.setSystemId(urlOfSource);
  +      }
   
  -            // Then the user will construct it themselves.
  -            return dtm;
  -          }
  +      dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
  +                          xstringFactory, doIndexing);
   
  -          // not incremental
  -          reader.setContentHandler(dtm);
  -          reader.setDTDHandler(dtm);
  -          if(null == reader.getErrorHandler())
  -            reader.setErrorHandler(dtm);
  +      // Add the DTM to the lookup table with offset 0 (start of new DTM).
  +      // This needs to be done before any parsing occurs.
  +      addDTM(dtm, dtmPos, 0);
   
  -          try
  -          {
  -            reader.setProperty(
  -                               "http://xml.org/sax/properties/lexical-handler", dtm);
  +      boolean haveXercesParser =
  +        (null != reader)
  +        && (reader.getClass().getName().equals("org.apache.xerces.parsers.SAXParser") );
  +        
  +      if (haveXercesParser)
  +        incremental = true;  // No matter what.  %REVIEW%
  +        
  +      // If the reader is null, but they still requested an incremental build,
  +      // then we still want to set up the IncrementalSAXSource stuff.
  +      if (this.m_incremental && incremental /* || ((null == reader) && incremental) */)
  +      {
  +        IncrementalSAXSource coParser=null;
  +
  +        if (haveXercesParser)
  +        {
  +          // IncrementalSAXSource_Xerces to avoid threading.
  +          // %REVIEW% Currently this creates a new instance of Xerces, since
  +          // there's no way to access the incremental parsing APIs in today's
  +          // Xerces. This is wasteful since a reader was already created.
  +          // Can we rationalize this flow?
  +          try {
  +            coParser=org.apache.xml.dtm.ref.IncrementalSAXSource_Xerces.createIncrementalSAXSource();
  +          }  catch( Exception ex ) {
  +            ex.printStackTrace();
  +            coParser=null;
             }
  -          catch (SAXNotRecognizedException e){}
  -          catch (SAXNotSupportedException e){}
  +        }
   
  -          try
  +        if( coParser==null ) {
  +          // Create a IncrementalSAXSource that will run on the secondary thread.
  +          if (null == reader)
  +            coParser = new IncrementalSAXSource_Filter();
  +          else
             {
  -            reader.parse(xmlSource);
  +            IncrementalSAXSource_Filter filter=new IncrementalSAXSource_Filter();
  +            filter.setXMLReader(reader);
  +            coParser=filter;
             }
  -          catch (RuntimeException re)
  -          {
   
  -            dtm.clearCoRoutine();
  +        }
   
  -            throw re;
  -          }
  -          catch (Exception e)
  -          {
  +        // Have the DTM set itself up as the IncrementalSAXSource's listener.
  +        dtm.setIncrementalSAXSource(coParser);
   
  -            dtm.clearCoRoutine();
  +        if (null == xmlSource)
  +        {
   
  -            throw new org.apache.xml.utils.WrappedRuntimeException(e);
  -          }
  +          // Then the user will construct it themselves.
  +          return dtm;
           }
   
  -        if (DUMPTREE)
  +        if(null == reader.getErrorHandler())
  +          reader.setErrorHandler(dtm);
  +        reader.setDTDHandler(dtm);
  +
  +        try
           {
  -          System.out.println("Dumping SAX2DOM");
  -          dtm.dumpDTM(System.err);
  +
  +          // Launch parsing coroutine.  Launches a second thread,
  +          // if we're using IncrementalSAXSource.filter().
  +          coParser.startParse(xmlSource);
           }
  +        catch (RuntimeException re)
  +        {
   
  -        return dtm;
  +          dtm.clearCoRoutine();
  +
  +          throw re;
  +        }
  +        catch (Exception e)
  +        {
  +
  +          dtm.clearCoRoutine();
  +
  +          throw new org.apache.xml.utils.WrappedRuntimeException(e);
  +        }
         }
         else
         {
  +        if (null == reader)
  +        {
  +
  +          // Then the user will construct it themselves.
  +          return dtm;
  +        }
   
  -        // It should have been handled by a derived class or the caller
  -        // made a mistake.
  -        throw new DTMException(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUPPORTED, new Object[]{source})); //"Not supported: " + source);
  +        // not incremental
  +        reader.setContentHandler(dtm);
  +        reader.setDTDHandler(dtm);
  +        if(null == reader.getErrorHandler())
  +          reader.setErrorHandler(dtm);
  +
  +        try
  +        {
  +          reader.setProperty(
  +                             "http://xml.org/sax/properties/lexical-handler", dtm);
  +        }
  +        catch (SAXNotRecognizedException e){}
  +        catch (SAXNotSupportedException e){}
  +
  +        try
  +        {
  +          reader.parse(xmlSource);
  +        }
  +        catch (RuntimeException re)
  +        {
  +
  +          dtm.clearCoRoutine();
  +
  +          throw re;
  +        }
  +        catch (Exception e)
  +        {
  +
  +          dtm.clearCoRoutine();
  +
  +          throw new org.apache.xml.utils.WrappedRuntimeException(e);
  +        }
         }
  +
  +      if (DUMPTREE)
  +      {
  +        System.out.println("Dumping SAX2DOM");
  +        dtm.dumpDTM(System.err);
  +      }
  +
  +      return dtm;
  +    }
  +
  +    else
  +    {
  +
  +      // It should have been handled by a derived class or the caller
  +      // made a mistake.
  +      throw new DTMException(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUPPORTED, new Object[]{source})); //"Not supported: " + source);
       }
     }
   
  @@ -794,10 +894,10 @@
       {
         System.out.println("Releasing "+
   			 (shouldHardDelete ? "HARD" : "soft")+
  -			 " dtm="+
  +			 " dtm="+dtm
   			 // Following shouldn't need a nodeHandle, but does...
   			 // and doesn't seem to report the intended value
  -			 dtm.getDocumentBaseURI()
  +			 +" ("+dtm.getDocumentBaseURI()+")"
   			 );
       }
   
  
  
  
  1.5.14.1  +14 -1     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java
  
  Index: DTMNodeList.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeList.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- DTMNodeList.java	13 Nov 2001 22:09:42 -0000	1.5
  +++ DTMNodeList.java	14 Aug 2002 19:45:34 -0000	1.5.14.1
  @@ -112,10 +112,23 @@
           dtm_iter=(DTMIterator)dtmIterator.cloneWithReset();
         }
         catch(CloneNotSupportedException cnse) {}
  -      dtm_iter.setShouldCacheNodes(true);
  +      dtm_iter.setShouldCache(true);
         dtm_iter.runTo(-1);
         dtm_iter.setCurrentPos(pos);
       }
  +    
  +  /** Public constructor: Create a NodeList to support a XNodeSequenceSingleton.
  +   *
  +   * @param dtm The DTM containing this node.
  +   * @param node node-handle integer.
  +   * @param dummy unused.
  +   * */
  +  public DTMNodeList(DTM dtm,int node, boolean dummy)
  +  {
  +    dtm_iter=null;
  +    m_parentDTM=dtm;
  +    m_firstChild=node;
  +  }
   
     /** Public constructor: Create a NodeList to support
      * DTMNodeProxy.getChildren().
  
  
  
  1.6.2.1   +39 -1     xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java
  
  Index: ExpandedNameTable.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- ExpandedNameTable.java	10 May 2002 18:41:54 -0000	1.6
  +++ ExpandedNameTable.java	14 Aug 2002 19:45:34 -0000	1.6.2.1
  @@ -77,6 +77,11 @@
    * */
   public class ExpandedNameTable
   {
  +  // A bit of a kluge... We want assign-only-once behavior for the
  +  // schemaType field, and null is a legitimate value... so we need
  +  // a cheap non-null singleton object to use as the not-yet-set flag.
  +  // As it happens, almost anything will work...
  +  static final Object UNKNOWN_SCHEMA_TYPE=Boolean.FALSE;    
   
     /** Probably a reference to static pool.     */
     private DTMStringPool m_locNamesPool;
  @@ -282,12 +287,45 @@
       return (short)etype.nodetype;
     }
     
  -  
  +  /** Store the default schema datatype associated with this expanded
  +      name.
  +
  +      @return true if the default has been set (or if the new value
  +      matches the old one), false if the new doesn't match (meaning
  +      you'd better record this as a per-node exception).
  +  */
  +  public boolean setSchemaType(int ExpandedNameID, Object schemaType)
  +  {
  +    ExtendedType et=(ExtendedType)m_extendedTypes.elementAt (ExpandedNameID);
  +    if(et.schemaType==UNKNOWN_SCHEMA_TYPE)
  +    {
  +      et.schemaType=schemaType;
  +      return true;
  +    }
  +    else if(et.schemaType==schemaType || 
  +    	(et.schemaType!=null && et.schemaType.equals(schemaType)) )
  +      return true;
  +    else
  +      return false;
  +  }
  +
  +  /** @return the default schema datatype associated with this expanded
  +      name, null if none has been bound OR if the type bound was itself
  +      null.
  +  */
  +  public Object getSchemaType(int ExpandedNameID)
  +  {
  +    ExtendedType et=(ExtendedType)m_extendedTypes.elementAt (ExpandedNameID);
  +    return (et.schemaType==UNKNOWN_SCHEMA_TYPE) ? null : et.schemaType;
  +  }
  +
     /**
      * Private class representing an extended type object 
      */
     private class ExtendedType
     {
  +    protected Object schemaType=UNKNOWN_SCHEMA_TYPE;
  +    
       protected int nodetype;
       protected String namespace;
       protected String localName;
  
  
  
  1.8.10.1  +84 -2     xml-xalan/java/src/org/apache/xml/dtm/ref/IncrementalSAXSource_Xerces.java
  
  Index: IncrementalSAXSource_Xerces.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/IncrementalSAXSource_Xerces.java,v
  retrieving revision 1.8
  retrieving revision 1.8.10.1
  diff -u -r1.8 -r1.8.10.1
  --- IncrementalSAXSource_Xerces.java	6 Feb 2002 17:46:45 -0000	1.8
  +++ IncrementalSAXSource_Xerces.java	14 Aug 2002 19:45:34 -0000	1.8.10.1
  @@ -61,13 +61,17 @@
   import org.xml.sax.SAXException;
   import java.io.IOException;
   import org.apache.xerces.parsers.SAXParser;
  +import org.apache.xml.utils.WrappedRuntimeException;
   import org.xml.sax.XMLReader;
   
   import org.apache.xalan.res.XSLTErrorResources;
   import org.apache.xalan.res.XSLMessages;
   import java.lang.reflect.Constructor;
  +import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
   
  +import javax.xml.transform.TransformerException;
  +
   
   /** <p>IncrementalSAXSource_Xerces takes advantage of the fact that Xerces1
    * incremental mode is already a coroutine of sorts, and just wraps our
  @@ -177,7 +181,41 @@
   			this.fParseSome=dummy.fParseSome;
   			this.fIncrementalParser=dummy.fIncrementalParser;
   		}
  -  }
  +
  +		// General SAX-level feature initialization
  +		try
  +		{
  +			fIncrementalParser.setFeature("http://xml.org/sax/features/validation",true);
  +		}
  +		catch(org.xml.sax.SAXNotRecognizedException e) {e.printStackTrace();}
  +		catch(org.xml.sax.SAXNotSupportedException e) {e.printStackTrace();}
  +		try
  +		{
  +			fIncrementalParser.setFeature("http://apache.org/xml/features/validation/dynamic",true);
  +		}
  +		catch(org.xml.sax.SAXNotRecognizedException e) {e.printStackTrace();}
  +		catch(org.xml.sax.SAXNotSupportedException e) {e.printStackTrace();}
  +
  +		// %REVIEW% Turning on schema support is necessary for some
  +		// of the information we'd like to retrieve. Unfortunately,
  +		// XERCES currently slows down by 90% (ie, takes twice as
  +		// long to run!) with this feature enabled, even if the
  +		// document never references schemas. We could make this
  +		// optional (resurrect the old -VALIDATE switch?), but it's
  +		// really not clear we want the user to have to deal with
  +		// manually setting this appropriately for every document.
  +		// The default would have to be full validation, slow mode.
  +		//
  +		// I'm trying to convince Xerces that higher speed should be
  +		// given higher priority.
  +		try
  +		{
  +			fIncrementalParser.setFeature("http://apache.org/xml/features/validation/schema",true);
  +		}
  +		catch(org.xml.sax.SAXNotRecognizedException e) {e.printStackTrace();}
  +		catch(org.xml.sax.SAXNotSupportedException e) {e.printStackTrace();}
  +		
  +   }
   
     /** Create a IncrementalSAXSource_Xerces wrapped around
      * an existing SAXParser. Currently this works only for recent
  @@ -348,7 +386,39 @@
       return arg;
     }
   	
  -	// Private methods -- conveniences to hide the reflection details
  +  static final Object[] parmstrue={Boolean.TRUE};
  +	
  +  /** deliverAllNodes() is a simple API which tells the coroutine
  +   * parser to run until all nodes have been delivered.  
  +   * This is a bit of a kluge, intended to address the case where
  +   * we're using IncrementalSAXSource_Xerces not for its incrementality
  +   * but as a wrapper around the Xerces XNI layer; its primary purpose
  +   * is to simplify the logic in DTMManagerDefault.java
  +   * */
  +  public void deliverAllNodes() throws SAXException
  +  {
  +    try
  +    {
  +      Object ret =
  +        (Boolean) (fConfigParse.invoke(fPullParserConfig, parmstrue));
  +    }
  +    catch (IllegalAccessException iae)
  +    {
  +      throw new WrappedRuntimeException(
  +        new TransformerException(iae));
  +    }
  +    catch (InvocationTargetException ite)
  +    {
  +      throw new WrappedRuntimeException(
  +        new TransformerException(ite.getTargetException()));
  +    }
  +    catch (RuntimeException ex)
  +    {
  +      throw new WrappedRuntimeException(new TransformerException(ex));
  +    }
  +  }
  +  
  +  	// Private methods -- conveniences to hide the reflection details
   	private boolean parseSomeSetup(InputSource source) 
   		throws SAXException, IOException, IllegalAccessException, 
   					 java.lang.reflect.InvocationTargetException,
  @@ -479,6 +549,18 @@
       }
       
     }
  +  
  +  /** EXPERIMENTAL AS OF 3/22/02: Support for XNI2DTM, allowing us to
  +   * bind direct to the parser's XNI stream.
  +   * 
  +   * %BUG% Gonk -- This requires hard link to Xerces2. Could use reflection
  +   * typecasting, but for now... Does anyone still care about Xerces1?
  +   * */
  +  public org.apache.xerces.xni.parser.XMLPullParserConfiguration getXNIParserConfiguration()
  +  {
  +  	return (org.apache.xerces.xni.parser.XMLPullParserConfiguration)fPullParserConfig;
  +  }
  +
   
     
   } // class IncrementalSAXSource_Xerces
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.28.4.1  +3 -0      xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
  
  Index: DOM2DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java,v
  retrieving revision 1.28
  retrieving revision 1.28.4.1
  diff -u -r1.28 -r1.28.4.1
  --- DOM2DTM.java	10 Apr 2002 20:33:16 -0000	1.28
  +++ DOM2DTM.java	14 Aug 2002 19:45:34 -0000	1.28.4.1
  @@ -94,6 +94,9 @@
    * Note too that we do not currently attempt to track document
    * mutation. If you alter the DOM after wrapping DOM2DTM around it,
    * all bets are off.
  + * %REVIEW% We _could_ ask the DOM whether it supports mutation
  + * events, and if so use that to invalidate the DTM or at least
  + * toss a warning back into Xalan...
    * */
   public class DOM2DTM extends DTMDefaultBaseIterators
   {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.29.2.1  +339 -26   xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
  retrieving revision 1.29
  retrieving revision 1.29.2.1
  diff -u -r1.29 -r1.29.2.1
  --- SAX2DTM.java	21 May 2002 16:24:40 -0000	1.29
  +++ SAX2DTM.java	14 Aug 2002 19:45:35 -0000	1.29.2.1
  @@ -82,6 +82,12 @@
   /**
    * This class implements a DTM that tends to be optimized more for speed than
    * for compactness, that is constructed via SAX2 ContentHandler events.
  + * 
  + * NOTE: This version of the code incorporates the logic needed to allow
  + * "shared DTMs", where a single DTM contains several documents which may
  + * be tail-pruned away. This mode is used for result tree 
  + * fragments/temporary trees. A separate constructor *must* be used to
  + * invoke this mode.
    */
   public class SAX2DTM extends DTMDefaultBaseIterators
           implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler,
  @@ -89,6 +95,14 @@
   {
     /** Set true to monitor SAX events and similar diagnostic info. */
     private static final boolean DEBUG = false;
  +  
  +	/** See discussion in endDocument() */
  +	static final boolean JJK_LEAVE_DOCUMENT_CURRENT=false;  
  +
  +  /** Set true when the DTM goes into Shared DTM mode -- specifically, when
  +   * the shared-mode constructor is invoked.
  +   * */
  +  private boolean m_isSharedDTM=false;
   
     /**
      * If we're building the model incrementally on demand, we need to
  @@ -116,11 +130,26 @@
      * between RTFs, and tail-pruning... consider going back to the larger/faster.
      *
      * Made protected rather than private so SAX2RTFDTM can access it.
  -   */
  -  //private FastStringBuffer m_chars = new FastStringBuffer(13, 13);
  -  protected FastStringBuffer m_chars = new FastStringBuffer(5, 13);
  -
  -  /** This vector holds offset and length data.
  +   * Minimum chunk size pushed up now that SAX2RTFDTM is in use (larger
  +   * minimum allocation, lower overhead as it grows). 
  +   * %REVIEW% Variable size disabled in FSB. Consider (13,13).
  +   */
  +  protected FastStringBuffer m_chars = new FastStringBuffer(10, 13);
  +
  +  /** This vector holds _integer pairs_ representing the "node value"
  +   * referenced by m_dataOrQName. It's basically a kluge to save a word 
  +   * per node for nodes which don't carry this information... AND is
  +   * overloaded to handle two distinct cases.
  +   * 
  +   * In: index (and index+1) from m_dataOrQName 
  +   * 
  +   * Out: Offset and length references into m_chars (for character content)
  +   * 	***OR***
  +   * 	(IF m_dataOrQName returned a negated index for an Attr node,
  +   *    indicating a prefixed attribute):
  +   * 	m_valuesOrPrefixes identifiers of prefix and value 
  +   *
  +   * %REVIEW% Is this really the best solution? I hae me doots!
      */
     protected SuballocatedIntVector m_data;
   
  @@ -164,7 +193,7 @@
     protected DTMTreeWalker m_walker = new DTMTreeWalker();
   
     /** pool of string values that come as strings. */
  -  private DTMStringPool m_valuesOrPrefixes = new DTMStringPool();
  +  protected DTMStringPool m_valuesOrPrefixes = new DTMStringPool();
   
     /** End document has been reached.
      * Made protected rather than private so SAX2RTFDTM can access it.
  @@ -237,9 +266,34 @@
      */
     protected IntVector m_sourceColumn;
     
  +  /** Index of most recently started Document, or NULL if the DTM is shared and empty.  */
  +  private int m_currentDocumentNode=0;
  +  
  +  /** Tail-pruning mark: Number of nodes in use. Null if not a shared DTM. */
  +  IntStack mark_size=null;
  +  /** Tail-pruning mark: Number of data items in use. Null if not a shared DTM. */
  +  IntStack mark_data_size=null;
  +  /** Tail-pruning mark: Number of size-of-data fields in use. Null if not a shared DTM. */
  +  IntStack mark_char_size=null;
  +  /** Tail-pruning mark: Number of dataOrQName slots in use. Null if not a shared DTM. */
  +  IntStack mark_doq_size=null;
  +  /** Tail-pruning mark: Number of namespace declaration sets in use. Null if not a shared DTM.
  +   * %REVIEW% I don't think number of NS sets is ever different from number
  +   * of NS elements. We can probabably reduce these to a single stack and save
  +   * some storage.
  +   * */
  +  IntStack mark_nsdeclset_size=null;
  +  /** Tail-pruning mark: Number of namespace declaration elements in use. Null if not a shared DTM.
  +   * %REVIEW% I don't think number of NS sets is ever different from number
  +   * of NS elements. We can probabably reduce these to a single stack and save
  +   * some storage.
  +   */
  +  IntStack mark_nsdeclelem_size=null;
  +    
     /**
      * Construct a SAX2DTM object ready to be constructed from SAX2
  -   * ContentHandler events.
  +   * ContentHandler events. DTMs produced by this constructor do _NOT_
  +   * support shared mode.
      *
      * @param mgr The DTMManager who owns this DTM.
      * @param source the JAXP 1.1 Source object for this DTM.
  @@ -261,8 +315,10 @@
             
       // %REVIEW%  Initial size pushed way down to reduce weight of RTFs
       // (I'm not entirely sure 0 would work, so I'm playing it safe for now.)
  +    // %REVIEW% Given shared RTF DTM, we might be able to push this
  +    // back up again...?
       //m_data = new SuballocatedIntVector(doIndexing ? (1024*2) : 512, 1024);
  -    m_data = new SuballocatedIntVector(32, 1024);
  +    m_data = new SuballocatedIntVector(32);
   
       m_data.addElement(0);   // Need placeholder in case index into here must be <0.
   
  @@ -279,6 +335,57 @@
     }
   
     /**
  +   * Construct a SAX2DTM object ready to be constructed from SAX2
  +   * ContentHandler events. DTMs produced by this constructor may support
  +   * shared mode.
  +   *
  +   * @param mgr The DTMManager who owns this DTM.
  +   * @param source the JAXP 1.1 Source object for this DTM.
  +   * @param dtmIdentity The DTM identity ID for this DTM.
  +   * @param whiteSpaceFilter The white space filter for this DTM, which may
  +   *                         be null.
  +   * @param xstringfactory XMLString factory for creating character content.
  +   * @param doIndexing true if the caller considers it worth it to use 
  +   *    indexing schemes. HOWEVER: Indexes may be suppressed if shared is
  +   *    true, since they tend to be hard to prune efficiently.
  +   * @param shared true if the caller may want to write multiple documents
  +   *    into this DTM and prune them away again. This should be set true
  +   *    only for Result-Tree-Fragment/Temporary-Tree DTMs.
  +   */
  +  public SAX2DTM(DTMManager mgr, Source source, int dtmIdentity,
  +                 DTMWSFilter whiteSpaceFilter,
  +                 XMLStringFactory xstringfactory,
  +                 boolean doIndexing, boolean shared)
  +  {
  +  	// Normal construction. Note doIndexing forced false when shared is true.
  +  	this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
  +         doIndexing & !shared);
  +         
  +    m_isSharedDTM=shared;
  +         
  +    if(shared)
  +    {
  +		// NEVER track source locators for RTFs; they aren't meaningful. I think.
  +		// (If we did track them, we'd need to tail-prune these too.)
  +		m_useSourceLocationProperty=false; //org.apache.xalan.processor.TransformerFactoryImpl.m_source_location;
  +		m_sourceSystemId =  null;
  +		m_sourceLine = null;
  +		m_sourceColumn = null;
  +		
  +		// Initialize data structures for tail-pruning
  +		mark_size=new IntStack();
  +		mark_data_size=new IntStack();
  +		mark_char_size=new IntStack();
  +		mark_doq_size=new IntStack();
  +		mark_nsdeclset_size=new IntStack();
  +		mark_nsdeclelem_size=new IntStack();
  +		
  +		// Safety-net, to help make sure we're using this as intended
  +		m_currentDocumentNode=NULL;
  +    }
  +  }
  +             
  +  /**
      * Get the data or qualified name for the given node identity.
      *
      * @param identity The node identity.
  @@ -304,6 +411,32 @@
           return m_dataOrQName.elementAt(identity);
       }
     }
  +  
  +  /**
  +   * Given a node identifier, find the owning document node.  Unlike the DOM,
  +   * this considers the owningDocument of a Document to be itself. Note that
  +   * in shared DTMs this may be nonzero.
  +   *
  +   * @param nodeId the id of the node.
  +   * @return int Node identifier of owning document, or the nodeId if it is
  +   *             a Document.
  +   */
  +  protected int _documentRoot(int nodeIdentifier)
  +  {
  +  	if(nodeIdentifier==NULL) return NULL;
  +  	
  +  	if(!m_isSharedDTM)
  +  		return 0;
  +
  +  	// Otherwise, shared DTM and we have to do this the slow way.
  +    for(int parent=_parent(nodeIdentifier);
  +    	parent!=NULL;
  +    	nodeIdentifier=parent,parent=_parent(nodeIdentifier))
  +    	;
  +    
  +    return nodeIdentifier;
  +  }
  +  
   
     /**
      * Ask the CoRoutine parser to doTerminate and clear the reference.
  @@ -569,8 +702,7 @@
     {
   
       int expandedTypeID = getExpandedTypeID(nodeHandle);
  -    // If just testing nonzero, no need to shift...
  -    int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID);                     
  +    int namespaceID =  m_expandedNameTable.getNamespaceID(expandedTypeID);
   
       if (0 == namespaceID)
       {
  @@ -617,8 +749,8 @@
     public String getNodeNameX(int nodeHandle)
     {
   
  -    int expandedTypeID = getExpandedTypeID(nodeHandle);    
  -    int namespaceID = m_expandedNameTable.getNamespaceID(expandedTypeID);                      
  +    int expandedTypeID = getExpandedTypeID(nodeHandle);
  +    int namespaceID =  m_expandedNameTable.getNamespaceID(expandedTypeID);
   
       if (0 == namespaceID)
       {
  @@ -690,13 +822,13 @@
   
       identity += 1;
   
  -    while (identity >= m_size)
  -    {
  -      if (null == m_incrementalSAXSource)
  -        return DTM.NULL;
  +    while (identity >= m_size && nextNode())
  +    	;
   
  -      nextNode();
  -    }
  +	// If we exited because nextNode ran off the end of the document,
  +	// rather than because we found the node we needed, return null.
  +	if(identity>=m_size)
  +		return DTM.NULL;
   
       return identity;
     }
  @@ -746,8 +878,13 @@
   
     /**
      * This method should try and build one or more nodes in the table.
  +   * 
  +   * %OPT% When working with Xerces2, an incremental parsing step may not
  +   * actually generate a SAX event that causes a node to be built. Our higher-
  +   * level code is already looping to see if the desired node was obtained...
  +   * but should we also be looping more tightly here?
      *
  -   * @return The true if a next node is found or false if
  +   * @return True if parsing proceeded normally or false if
      *         there are no more nodes.
      */
     protected boolean nextNode()
  @@ -1103,6 +1240,12 @@
           return getPrefix(qname, null);
         }
       }
  +    else if (DTM.NAMESPACE_NODE == type)
  +    {
  +    	if(!"xmlns".equals(getLocalName(nodeHandle)))
  +    		return "xmlns";
  +    	// else return "".
  +    }
   
       return "";
     }
  @@ -1138,6 +1281,54 @@
   
       return DTM.NULL;
     }
  +  
  +  /**
  +   * Given a DTM, find the owning document node. In the case of
  +   * SAX2RTFDTM, which may contain multiple documents, this returns
  +   * the <b>most recently started</b> document, or null if the DTM is
  +   * empty or no document is currently under construction.
  +   *
  +   * %REVIEW% Should we continue to report the most recent after
  +   * construction has ended? I think not, given that it may have been
  +   * tail-pruned.
  +   *
  +   *  @param nodeHandle the id of the node.
  +   *  @return int Node handle of Document node, or null if this DTM does not
  +   *  contain an "active" document.
  +   * */
  +  public int getDocument()
  +  {
  +  	// %REVIEW% Would adding these lines affect speed, and if so which way?
  +  	// if(!m_isSharedDTM)
  +  	//	return m_dtmIdent.elementAt(0); // like DTMDefaultBase
  +    return makeNodeHandle(m_currentDocumentNode);
  +  }
  +  
  +  /**
  +   * Given a node handle, find the owning document node, using DTM semantics
  +   * (Document owns itself) rather than DOM semantics (Document has no owner).
  +   *
  +   * (I'm counting on the fact that getOwnerDocument() is implemented on top
  +   * of this call, in the superclass, to avoid having to rewrite that one.
  +   * Be careful if that code changes!)
  +   *
  +   * @param nodeHandle the id of the node.
  +   * @return int Node handle of owning document
  +   */
  +  public int getDocumentRoot(int nodeHandle)
  +  {
  +  	if(!m_isSharedDTM)
  +  		return getDocument();
  +  	
  +  	// If shared, we have to do it the hard way
  +    for(int id=makeNodeIdentity(nodeHandle);
  +		id!=NULL;
  +		id=_parent(id))
  +		if(_type(id)==DTM.DOCUMENT_NODE)
  +  			return makeNodeHandle(id);
  +
  +    return DTM.NULL; // Safety net; should never happen
  +  }
   
     /**
      * Return the public identifier of the external subset,
  @@ -1171,8 +1362,13 @@
      */
     public String getNamespaceURI(int nodeHandle)
     {
  +  	int identity=makeNodeIdentity(nodeHandle);
  +  	
  +  	// DOM says all namespace nodes are in the namespace namespace.
  +  	if (_type(identity) == NAMESPACE_NODE)
  +  		return "http://www.w3.org/XML/1998/namespace";
   
  -    return m_expandedNameTable.getNamespace(_exptype(makeNodeIdentity(nodeHandle)));
  +    return m_expandedNameTable.getNamespace(_exptype(identity));
     }
   
     /**
  @@ -1302,7 +1498,7 @@
      *
      * @return The prefix if there is one, or null.
      */
  -  private String getPrefix(String qname, String uri)
  +  protected String getPrefix(String qname, String uri)
     {
   
       String prefix;
  @@ -1545,6 +1741,18 @@
     {
       if (DEBUG)
         System.out.println("startDocument");
  +      
  +    if(m_isSharedDTM)
  +    {
  +		// (Re)initialize the tree construction process
  +		// %REVIEW% Slightly wasteful on the first document written to 
  +		// the shared DTM, since these have already been allocated.
  +		m_endDocumentOccured = false;
  +		m_prefixMappings = new java.util.Vector();
  +		m_contextIndexes = new IntStack();
  +		m_parents = new IntStack();
  +	    m_currentDocumentNode=m_size;
  +    }
   
   		
       int doc = addNode(DTM.DOCUMENT_NODE,
  @@ -1569,12 +1777,12 @@
       if (DEBUG)
         System.out.println("endDocument");
   
  -		charactersFlush();
  +	charactersFlush();
   
  -    m_nextsib.setElementAt(NULL,0);
  +    m_nextsib.setElementAt(NULL,m_currentDocumentNode);
   
  -    if (m_firstch.elementAt(0) == NOTPROCESSED)
  -      m_firstch.setElementAt(NULL,0);
  +    if (m_firstch.elementAt(m_currentDocumentNode) == NOTPROCESSED)
  +      m_firstch.setElementAt(NULL,m_currentDocumentNode);
   
       if (DTM.NULL != m_previous)
         m_nextsib.setElementAt(DTM.NULL,m_previous);
  @@ -1583,6 +1791,15 @@
       m_prefixMappings = null;
       m_contextIndexes = null;
   
  +	// This is debatable. Clearing it in shared DTMs does help keep
  +	// us honest, by ensuring against using getDocument() in a situation
  +	// where we aren't sure which document is being referred to.
  +	// We _shouldn't_ clear it in non-shared DTMs, since -- at this time,
  +	// anyway -- some of the start-up code assumes that getDocument() on the
  +	// source document will work after the doc is closed.
  +    if(!JJK_LEAVE_DOCUMENT_CURRENT && m_isSharedDTM)
  +	    m_currentDocumentNode= NULL; // no longer open
  +	    
       m_endDocumentOccured = true;
     }
   
  @@ -1679,7 +1896,7 @@
       return false;
     }
   	
  -	boolean m_pastFirstElement=false;
  +	protected boolean m_pastFirstElement=false;
   
     /**
      * Receive notification of the start of an element.
  @@ -2349,4 +2566,100 @@
       }
       return null;
     }
  +  
  +  /** "Tail-pruning" support for RTFs.
  +   * 
  +   * This function pushes information about the current size of the
  +   * DTM's data structures onto a stack, for use by popRewindMark()
  +   * (which see).
  +   * 
  +   * This will fail with null-pointer exceptions if called on a non-shared
  +   * DTM. That's deliberate, since it's considered a severe coding error.
  +   * 
  +   * %REVIEW% I have no idea how to rewind m_elemIndexes. However,
  +   * RTFs should not be indexed, so I can simply panic if that case
  +   * arises. Hey, it works...
  +   * */
  +  public void pushRewindMark()
  +  {
  +    if(m_indexing || m_elemIndexes!=null) 
  +      throw new java.lang.NullPointerException("Coding error; Don't try to mark/rewind an indexed DTM");
  +
  +    // Values from DTMDefaultBase
  +    // %REVIEW% Can the namespace stack sizes ever differ? If not, save space!
  +    mark_size.push(m_size);
  +    mark_nsdeclset_size.push( (m_namespaceDeclSets==null) ? 0 : m_namespaceDeclSets.size() );
  +    mark_nsdeclelem_size.push( (m_namespaceDeclSetElements==null) ? 0 : m_namespaceDeclSetElements.size() );
  +    
  +    // Values from SAX2DTM
  +    mark_data_size.push(m_data.size());
  +    mark_char_size.push(m_chars.size());
  +    mark_doq_size.push(m_dataOrQName.size());	
  +  }
  +  
  +  /** "Tail-pruning" support for RTFs.
  +   * 
  +   * This function pops the information previously saved by
  +   * pushRewindMark (which see) and uses it to discard all nodes added
  +   * to the DTM after that time. We expect that this will allow us to
  +   * reuse storage more effectively.
  +   * 
  +   * This is _not_ intended to be called while a document is still being
  +   * constructed -- only between endDocument and the next startDocument
  +   * 
  +   * %REVIEW% WARNING: This is the first use of some of the truncation
  +   * methods.  If Xalan blows up after this is called, that's a likely
  +   * place to check.
  +   * 
  +   * %REVIEW% Our original design for DTMs permitted them to share
  +   * string pools.  If there any risk that this might be happening, we
  +   * can _not_ rewind and recover the string storage. One solution
  +   * might to assert that DTMs used for RTFs Must Not take advantage
  +   * of that feature, but this seems excessively fragile. Another, much
  +   * less attractive, would be to just let them leak... Nah.
  +   * 
  +   * This will fail with null-pointer exceptions if called on a non-shared
  +   * DTM. That's deliberate, since it's considered a severe coding error.
  +   * 
  +   * @return true if and only if the pop completely emptied the
  +   * RTF. That response is used when determining how to unspool
  +   * RTF-started-while-RTF-open situations.
  +   * */
  +  public boolean popRewindMark()
  +  {
  +    boolean top=mark_size.empty();
  +    
  +    m_size=top ? 0 : mark_size.pop();
  +    m_exptype.setSize(m_size);
  +    m_firstch.setSize(m_size);
  +    m_nextsib.setSize(m_size);
  +    m_prevsib.setSize(m_size);
  +    m_parent.setSize(m_size);
  +
  +    m_elemIndexes=null;
  +
  +    int ds= top ? 0 : mark_nsdeclset_size.pop();
  +    if (m_namespaceDeclSets!=null)
  +      m_namespaceDeclSets.setSize(ds);
  +      
  +    int ds1= top ? 0 : mark_nsdeclelem_size.pop();
  +    if (m_namespaceDeclSetElements!=null)
  +      m_namespaceDeclSetElements.setSize(ds1);
  +  
  +    // Values from SAX2DTM
  +    m_data.setSize(top ? 0 : mark_data_size.pop());
  +    m_chars.setLength(top ? 0 : mark_char_size.pop());
  +    m_dataOrQName.setSize(top ? 0 : mark_doq_size.pop());
  +
  +    // Return true iff DTM now empty
  +    return m_size==0;
  +  }
  +  
  +  /** @return true if a DTM tree is currently under construction.
  +   * */
  +  public boolean isTreeIncomplete()
  +  {
  +  	return !m_endDocumentOccured;
  +  	
  +  }  
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +191 -0    xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/AbstractSchema.java
  
  
  
  
  1.1.2.1   +558 -0    xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/DOMValidationConfigurationSwipedFromXerces.java
  
  
  
  
  1.1.4.1   +622 -0    xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/DTM2XNI.java
  
  
  
  
  1.2.4.1   +123 -116  xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/DTM_XSequence.java
  
  
  
  
  1.1.2.1   +87 -0     xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/ElemImportSchema.java
  
  
  
  
  1.1.2.1   +41 -0     xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/FuncData.java
  
  
  
  
  1.1.2.1   +63 -0     xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/FuncInstanceOf.java
  
  
  
  
  1.1.2.1   +75 -0     xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/FuncTreatAs.java
  
  
  
  
  1.1.4.1   +185 -0    xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/FuncValidate.java
  
  
  
  
  1.1.2.1   +321 -0    xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/NamespaceSupportAtDTMNode.java
  
  
  
  
  1.2.4.1   +688 -615  xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/XNI2DTM.java
  
  
  
  
  1.1.4.1   +326 -0    xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/XNISource.java
  
  
  
  
  1.1.2.1   +656 -0    xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/XPath2Type.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.2.1  +4 -8      xml-xalan/java/src/org/apache/xml/utils/DefaultErrorHandler.java
  
  Index: DefaultErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/DefaultErrorHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.10.2.1
  diff -u -r1.10 -r1.10.2.1
  --- DefaultErrorHandler.java	8 Jul 2002 22:07:23 -0000	1.10
  +++ DefaultErrorHandler.java	14 Aug 2002 19:45:36 -0000	1.10.2.1
  @@ -60,10 +60,6 @@
   import javax.xml.transform.ErrorListener;
   import javax.xml.transform.TransformerException;
   import javax.xml.transform.SourceLocator;
  -
  -import org.apache.xalan.res.XSLMessages;
  -import org.apache.xalan.res.XSLTErrorResources;
  - 
   import java.io.PrintWriter;
   import java.io.PrintStream;
   
  @@ -338,12 +334,12 @@
         String id = (null != locator.getPublicId() )
                     ? locator.getPublicId()
                       : (null != locator.getSystemId())
  -                      ? locator.getSystemId() : XSLMessages.createMessage(XSLTErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
  +                      ? locator.getSystemId() : "SystemId Unknown";
   
  -      pw.print(id + "; " +XSLMessages.createMessage("line", null) + locator.getLineNumber()
  -                         + "; " +XSLMessages.createMessage("column", null) + locator.getColumnNumber()+"; ");
  +      pw.print(id + "; Line " + locator.getLineNumber()
  +                         + "; Column " + locator.getColumnNumber()+"; ");
       }
       else
  -      pw.print("("+XSLMessages.createMessage(XSLTErrorResources.ER_LOCATION_UNKNOWN, null)+")");
  +      pw.print("(Location of error unknown)");
     }
   }
  
  
  
  1.21.2.1  +158 -0    xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java
  
  Index: FastStringBuffer.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java,v
  retrieving revision 1.21
  retrieving revision 1.21.2.1
  diff -u -r1.21 -r1.21.2.1
  --- FastStringBuffer.java	3 Jun 2002 13:27:55 -0000	1.21
  +++ FastStringBuffer.java	14 Aug 2002 19:45:36 -0000	1.21.2.1
  @@ -1373,4 +1373,162 @@
       source.m_chunkSize = 1 << (source.m_chunkBits);
       source.m_chunkMask = source.m_chunkSize - 1;
     }
  +
  +	/** Support for DTM2XNI. Rather than push XNI awareness into this class,
  +	 * (as we did for SAX in sendSAX*), yield the content in a reasonably
  +	 * efficient manner for the caller to pass along.
  +	 * */
  +  public CharacterBlockEnumeration enumerateCharacterBlocks(int start, int length)
  +  {
  +  	return new FSBCharacterBlockEnumeration(start,length);
  +  }
  +  
  +	/** Support for DTM2XNI. Rather than push XNI awareness into this class,
  +	 * (as we did for SAX in sendSAX*), yield the content in a reasonably
  +	 * efficient manner for the caller to pass along.
  +	 * 
  +	 * %BUG% %REVIEW% Currently does _NOT_ support inner FSBs.
  +	 * We need to either rearchitect those or get rid of 'em...
  +	 * */
  +  protected class FSBCharacterBlockEnumeration
  +  extends CharacterBlockEnumeration
  +  {
  +  	int f_remaining;
  +  	int f_chunk;
  +  	
  +  	FSBCharacterBlockEnumeration(int start,int length)
  +  	{
  +  		if(m_innerFSB!=null)
  +			throw new UnsupportedOperationException("Can't handle innerFSBs yet");
  +  		
  +  		int l=length();
  +  		if(start>l)
  +  		{
  +  			// Don't start off end -- take that as empty
  +  			_start=_length=f_remaining=0;
  +  			_chars=m_array[0];
  +  		}
  +  		else
  +  		{
  +  			// Don't run off end -- truncate to fit
  +	  		l-=start;
  + 	 		f_remaining = (l>length) ? length : l;
  + 	 		
  + 	 		// Set up first chunk
  + 	 		f_chunk=start>>>m_chunkBits;
  + 	 		
  + 	 		_start=start & m_chunkMask;
  + 	 		
  + 	 		l=m_chunkSize-start;
  + 	 		_length = (l>f_remaining) ? f_remaining : l;
  + 	 		
  +  			f_remaining -= _length;
  +  		}
  +  	}
  +
  +  	/** Not supported in this implementaton */
  +	public FSBCharacterBlockEnumeration()
  +	{
  +		throw new UnsupportedOperationException("Not supported in this implementaton");
  +	}
  +	
  +  	/** Not supported in this implementaton */
  +	public FSBCharacterBlockEnumeration(String s)
  +	{
  +		throw new UnsupportedOperationException("Not supported in this implementaton");
  +	}
  +	
  +  	/** Not supported in this implementaton */
  +	public FSBCharacterBlockEnumeration(String s, int start, int length)
  +	{
  +		throw new UnsupportedOperationException("Not supported in this implementaton");
  +	}
  +	
  +  	/** Not supported in this implementaton */
  +	public FSBCharacterBlockEnumeration(char[] ch)
  +	{
  +		throw new UnsupportedOperationException("Not supported in this implementaton");
  +	}
  +
  +  	/** Not supported in this implementaton */
  +	public FSBCharacterBlockEnumeration(char[] ch, int start, int length)
  +	{
  +		throw new UnsupportedOperationException("Not supported in this implementaton");
  +	}
  +	
  +	/** @return true if another character block can be accessed by calling
  +	 * nextElement()
  +	 */
  +	public boolean hasMoreElements()
  +	{
  +		return f_remaining>0;
  +	}
  +	
  +	/** Advance to the next character block. 
  +	 * 
  +	 * @returns either this CharacterBlockEnumeration object (as a
  +	 * transient accessor to the "element") or null if no more elements are available.
  +	 * This is a bit of a kluge, but it allows us to claim that we
  +	 * implement the Java Enumeration interface if we want to do so, and
  +	 * it seems to be as good or bad as any other return value.
  +	 * */
  +	public Object nextElement()
  +	{
  +		if(f_remaining==0)
  +			return null;
  +			
  +		// Next chunk
  +		++f_chunk;
  +		_start=0;
  + 		_length = (m_chunkSize>f_remaining) ? f_remaining : m_chunkSize;
  +		f_remaining -= _length;
  +		return this;
  +	}
  +	
  +	
  +	/** @return the starting offset in the current block's character array
  +	 * */
  +	public int getStart()
  +	{
  +		return _start;
  +	}
  +
  +	/** @return the length of the the current block
  +	 * */
  +	public int getLength()
  +	{
  +		return _length;
  +	}
  +
  +	/** 
  +	 * @return the current block's character array. Data will begin at
  +	 * offset {start}.
  +	 * */
  +	public char[] getChars()
  +	{
  +		char[] ch=(_length>0)
  +			? m_array[f_chunk] 
  +			: EMPTY;
  +		return ch;
  +	}
  +
  +	/** @param target A char[] to be copied into. If a buffer is not supplied
  +	 * we will create one.
  +	 *
  +	 * @param targetStart Offset in the target at which copying should begin.
  +	 * 
  +	 * @return the buffer, filled with {length} characters starting at offset
  +	 * {targetStart}. Characters before or after that block should be unaffected.
  +	 * */
  +	public char[] getChars(char[] target, int targetStart)
  +	{
  +		if(_length>0)
  +		{
  +			System.arraycopy(m_array[f_chunk],_start,target,targetStart,_length);
  +		}
  +			
  +		return target;
  +	}
  +  	
  +  }
   }
  
  
  
  1.2.2.1   +11 -15    xml-xalan/java/src/org/apache/xml/utils/ListingErrorHandler.java
  
  Index: ListingErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/ListingErrorHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- ListingErrorHandler.java	7 Jun 2002 17:13:54 -0000	1.2
  +++ ListingErrorHandler.java	14 Aug 2002 19:45:36 -0000	1.2.2.1
  @@ -57,22 +57,19 @@
   
   package org.apache.xml.utils;
   
  +import org.xml.sax.*;
  +import javax.xml.transform.ErrorListener;
  +import javax.xml.transform.TransformerException;
  +import javax.xml.transform.SourceLocator;
  +import java.io.PrintWriter;
  +
   import java.io.BufferedReader;
  -import java.io.InputStream;
  +import java.io.IOException;
   import java.io.InputStreamReader;
  -import java.io.PrintWriter;
  -import java.net.MalformedURLException;
   import java.net.URL;
   import java.net.URLConnection;
  -
  -import javax.xml.transform.ErrorListener;
  -import javax.xml.transform.SourceLocator;
  -import javax.xml.transform.TransformerException;
  -import org.apache.xalan.res.XSLMessages;
  -import org.apache.xalan.res.XSLTErrorResources;
  -import org.xml.sax.ErrorHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.SAXParseException;
  +import java.io.InputStream;
  +import org.apache.xml.utils.SystemIDResolver;
   
   
   /**
  @@ -97,8 +94,7 @@
       public ListingErrorHandler(PrintWriter pw)
       {
           if (null == pw)
  -            throw new NullPointerException(XSLMessages.createMessage(XSLTErrorResources.ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER, null));
  -            // "ListingErrorHandler created with null PrintWriter!");
  +            throw new NullPointerException("ListingErrorHandler created with null PrintWriter!");
               
           m_pw = pw;
       }
  
  
  
  1.9.2.1   +27 -183   xml-xalan/java/src/org/apache/xml/utils/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/QName.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- QName.java	24 Jul 2002 14:15:03 -0000	1.9
  +++ QName.java	14 Aug 2002 19:45:36 -0000	1.9.2.1
  @@ -125,41 +125,16 @@
      */
     public QName(String namespaceURI, String localName)
     {
  -    this(namespaceURI, localName, false); 
  -  }
  -
  -  /**
  -   * Constructs a new QName with the specified namespace URI and
  -   * local name.
  -   *
  -   * @param namespaceURI The namespace URI if known, or null
  -   * @param localName The local name
  -   * @param validate If true the new QName will be validated and an IllegalArgumentException will
  -   *                 be thrown if it is invalid.
  -   */
  -  public QName(String namespaceURI, String localName, boolean validate) 
  -  {
   
  -    // This check was already here.  So, for now, I will not add it to the validation
  -    // that is done when the validate parameter is true.
       if (localName == null)
         throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
               XPATHErrorResources.ER_ARG_LOCALNAME_NULL, null)); //"Argument 'localName' is null");
   
  -    if (validate) 
  -    {
  -        if (!XMLChar.isValidNCName(localName))
  -        {
  -            throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
  -            XPATHErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName");
  -        }
  -    }
  -    
       _namespaceURI = namespaceURI;
       _localName = localName;
  -    m_hashCode = toString().hashCode();
  +    m_hashCode = calcHashCode();
     }
  -  
  +
     /**
      * Constructs a new QName with the specified namespace URI, prefix
      * and local name.
  @@ -167,106 +142,36 @@
      * @param namespaceURI The namespace URI if known, or null
      * @param prefix The namespace prefix is known, or null
      * @param localName The local name
  -   * 
      */
     public QName(String namespaceURI, String prefix, String localName)
     {
  -     this(namespaceURI, prefix, localName, false);
  -  }
  -  
  - /**
  -   * Constructs a new QName with the specified namespace URI, prefix
  -   * and local name.
  -   *
  -   * @param namespaceURI The namespace URI if known, or null
  -   * @param prefix The namespace prefix is known, or null
  -   * @param localName The local name
  -   * @param validate If true the new QName will be validated and an IllegalArgumentException will
  -   *                 be thrown if it is invalid.
  -   */
  -  public QName(String namespaceURI, String prefix, String localName, boolean validate)
  -  {
   
  -    // This check was already here.  So, for now, I will not add it to the validation
  -    // that is done when the validate parameter is true.
       if (localName == null)
         throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
               XPATHErrorResources.ER_ARG_LOCALNAME_NULL, null)); //"Argument 'localName' is null");
   
  -    if (validate)
  -    {    
  -        if (!XMLChar.isValidNCName(localName))
  -        {
  -            throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
  -            XPATHErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName");
  -        }
  -
  -        if ((null != prefix) && (!XMLChar.isValidNCName(prefix)))
  -        {
  -            throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
  -            XPATHErrorResources.ER_ARG_PREFIX_INVALID,null )); //"Argument 'prefix' not a valid NCName");
  -        }
  -
  -    }
       _namespaceURI = namespaceURI;
       _prefix = prefix;
       _localName = localName;
  -    m_hashCode = toString().hashCode();
  -  }  
  +    m_hashCode = calcHashCode();
  +  }
   
     /**
      * Construct a QName from a string, without namespace resolution.  Good
      * for a few odd cases.
      *
      * @param localName Local part of qualified name
  -   * 
      */
     public QName(String localName)
     {
  -    this(localName, false);
  -  }
  -  
  -  /**
  -   * Construct a QName from a string, without namespace resolution.  Good
  -   * for a few odd cases.
  -   *
  -   * @param localName Local part of qualified name
  -   * @param validate If true the new QName will be validated and an IllegalArgumentException will
  -   *                 be thrown if it is invalid.
  -   */
  -  public QName(String localName, boolean validate)
  -  {
   
  -    // This check was already here.  So, for now, I will not add it to the validation
  -    // that is done when the validate parameter is true.
       if (localName == null)
         throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
               XPATHErrorResources.ER_ARG_LOCALNAME_NULL, null)); //"Argument 'localName' is null");
   
  -    if (validate)
  -    {    
  -        if (!XMLChar.isValidNCName(localName))
  -        {
  -            throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
  -            XPATHErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName");
  -        }
  -    }
       _namespaceURI = null;
       _localName = localName;
  -    m_hashCode = toString().hashCode();
  -  }  
  -
  -  /**
  -   * Construct a QName from a string, resolving the prefix
  -   * using the given namespace stack. The default namespace is
  -   * not resolved.
  -   *
  -   * @param qname Qualified name to resolve
  -   * @param namespaces Namespace stack to use to resolve namespace
  -   */
  -  public QName(String qname, Stack namespaces)
  -  {
  -    this(qname, namespaces, false);
  +    m_hashCode = calcHashCode();
     }
   
     /**
  @@ -276,10 +181,8 @@
      *
      * @param qname Qualified name to resolve
      * @param namespaces Namespace stack to use to resolve namespace
  -   * @param validate If true the new QName will be validated and an IllegalArgumentException will
  -   *                 be thrown if it is invalid.
      */
  -  public QName(String qname, Stack namespaces, boolean validate)
  +  public QName(String qname, Stack namespaces)
     {
   
       String namespace = null;
  @@ -294,7 +197,6 @@
         {
           namespace = S_XMLNAMESPACEURI;
         }
  -      // Do we want this?
         else if (prefix.equals("xmlns"))
         {
           return;
  @@ -333,18 +235,9 @@
   
       _localName = (indexOfNSSep < 0)
                    ? qname : qname.substring(indexOfNSSep + 1);
  -                 
  -    if (validate)
  -    {
  -        if ((_localName == null) || (!XMLChar.isValidNCName(_localName))) 
  -        {
  -           throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
  -            XPATHErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName");
  -        }
  -    }                 
       _namespaceURI = namespace;
       _prefix = prefix;
  -    m_hashCode = toString().hashCode();
  +    m_hashCode = calcHashCode();
     }
   
     /**
  @@ -359,23 +252,6 @@
     public QName(String qname, Element namespaceContext,
                  PrefixResolver resolver)
     {
  -      this(qname, namespaceContext, resolver, false);
  -  }
  -
  -  /**
  -   * Construct a QName from a string, resolving the prefix
  -   * using the given namespace context and prefix resolver. 
  -   * The default namespace is not resolved.
  -   * 
  -   * @param qname Qualified name to resolve
  -   * @param namespaceContext Namespace Context to use
  -   * @param resolver Prefix resolver for this context
  -   * @param validate If true the new QName will be validated and an IllegalArgumentException will
  -   *                 be thrown if it is invalid.
  -   */
  -  public QName(String qname, Element namespaceContext,
  -               PrefixResolver resolver, boolean validate)
  -  {
   
       _namespaceURI = null;
   
  @@ -393,12 +269,6 @@
           {
             _namespaceURI = S_XMLNAMESPACEURI;
           }
  -        
  -        // Do we want this?
  -        else if (prefix.equals("xmlns"))
  -        {
  -          return;
  -        }
           else
           {
             _namespaceURI = resolver.getNamespaceForPrefix(prefix,
  @@ -422,20 +292,9 @@
   
       _localName = (indexOfNSSep < 0)
                    ? qname : qname.substring(indexOfNSSep + 1);
  -
  -    if (validate)
  -    {
  -        if ((_localName == null) || (!XMLChar.isValidNCName(_localName))) 
  -        {
  -           throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
  -            XPATHErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName");
  -        }
  -    }                 
  -                 
  -    m_hashCode = toString().hashCode();
  +    m_hashCode = calcHashCode();
     }
   
  -
     /**
      * Construct a QName from a string, resolving the prefix
      * using the given namespace stack. The default namespace is
  @@ -446,38 +305,26 @@
      */
     public QName(String qname, PrefixResolver resolver)
     {
  -    this(qname, resolver, false);
  -  }
   
  -  /**
  -   * Construct a QName from a string, resolving the prefix
  -   * using the given namespace stack. The default namespace is
  -   * not resolved.
  -   *
  -   * @param qname Qualified name to resolve
  -   * @param resolver Prefix resolver for this context
  -   * @param validate If true the new QName will be validated and an IllegalArgumentException will
  -   *                 be thrown if it is invalid.
  -   */
  -  public QName(String qname, PrefixResolver resolver, boolean validate)
  -  {
  -
  -	String prefix = null;
       _namespaceURI = null;
   
       int indexOfNSSep = qname.indexOf(':');
   
       if (indexOfNSSep > 0)
       {
  -      prefix = qname.substring(0, indexOfNSSep);
  -
  +      String prefix = qname.substring(0, indexOfNSSep);
  +      _prefix = prefix;
  +      
         if (prefix.equals("xml"))
         {
           _namespaceURI = S_XMLNAMESPACEURI;
         }
         else
         {
  -        _namespaceURI = resolver.getNamespaceForPrefix(prefix);
  +        if(null != resolver) // Bad idea, I know.  -sb
  +          _namespaceURI = resolver.getNamespaceForPrefix(prefix);
  +        else
  +          _namespaceURI = prefix;
         }
   
         if (null == _namespaceURI)
  @@ -489,21 +336,9 @@
         }
       }
   
  -	_localName = (indexOfNSSep < 0)
  -                 ? qname : qname.substring(indexOfNSSep + 1);   
  -                 
  -    if (validate)
  -    {
  -        if ((_localName == null) || (!XMLChar.isValidNCName(_localName))) 
  -        {
  -           throw new IllegalArgumentException(XSLMessages.createXPATHMessage(
  -            XPATHErrorResources.ER_ARG_LOCALNAME_INVALID,null )); //"Argument 'localName' not a valid NCName");
  -        }
  -    }                 
  -
  -              
  -    m_hashCode = toString().hashCode();
  -    _prefix = prefix;
  +    _localName = (indexOfNSSep < 0)
  +                 ? qname : qname.substring(indexOfNSSep + 1);
  +    m_hashCode = calcHashCode();
     }
   
     /**
  @@ -587,6 +422,15 @@
     public String getLocalPart()
     {
       return getLocalName();
  +  }
  +  
  +  /**
  +   * Calculate the hash code for this object.
  +   * @return int The hashcode to be used.
  +   */
  +  int calcHashCode()
  +  {
  +    return _localName.hashCode();
     }
   
     /**
  
  
  
  1.3.2.1   +5 -25     xml-xalan/java/src/org/apache/xml/utils/StringToIntTable.java
  
  Index: StringToIntTable.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/StringToIntTable.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- StringToIntTable.java	10 Jul 2002 16:06:32 -0000	1.3
  +++ StringToIntTable.java	14 Aug 2002 19:45:36 -0000	1.3.2.1
  @@ -64,8 +64,6 @@
   public class StringToIntTable
   {
   
  -  public static final int INVALID_KEY = -10000;
  -  
     /** Block size to allocate          */
     private int m_blocksize;
   
  @@ -157,8 +155,7 @@
      *
      * @param key String to look for
      *
  -   * @return The String's int value
  -   * 
  +   * @return The String's int value or a bogus value if not found 
      */
     public final int get(String key)
     {
  @@ -169,7 +166,7 @@
           return m_values[i];
       }
   
  -	return INVALID_KEY;
  +    return -10000;  // Bogus value, needs to throw exception.
     }
   
     /**
  @@ -177,13 +174,13 @@
      *
      * @param key String to look for
      *
  -   * @return The string's int value
  +   * @return The string's int value, or a bogus value if not found
      */
     public final int getIgnoreCase(String key)
     {
   
       if (null == key)
  -        return INVALID_KEY;
  +      return -10000;  // Bogus value, needs to throw exception.
   
       for (int i = 0; i < m_firstFree; i++)
       {
  @@ -191,7 +188,7 @@
           return m_values[i];
       }
   
  -    return INVALID_KEY;
  +    return -10000;  // Bogus value, needs to throw exception.
     }
   
     /**
  @@ -212,21 +209,4 @@
   
       return false;
     }
  -  
  -  /**
  -   * Return array of keys in the table.
  -   * 
  -   * @return Array of strings
  -   */
  -  public final String[] keys()
  -  {
  -    String [] keysArr = new String[m_firstFree];
  -
  -    for (int i = 0; i < m_firstFree; i++)
  -    {
  -      keysArr[i] = m_map[i];
  -    }
  -
  -    return keysArr;
  -  }  
   }
  
  
  
  1.16.2.1  +2 -2      xml-xalan/java/src/org/apache/xml/utils/SystemIDResolver.java
  
  Index: SystemIDResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/SystemIDResolver.java,v
  retrieving revision 1.16
  retrieving revision 1.16.2.1
  diff -u -r1.16 -r1.16.2.1
  --- SystemIDResolver.java	30 Jul 2002 18:00:00 -0000	1.16
  +++ SystemIDResolver.java	14 Aug 2002 19:45:36 -0000	1.16.2.1
  @@ -263,8 +263,8 @@
       // Not so sure if this is good.  But, for now, I'll try it. We really must 
       // make sure the return from this function is a URL!
       if((Character.isLetter(uriStr.charAt(0)) && (uriStr.charAt(1) == ':') 
  -     && (uriStr.charAt(2) == '/') && (uriStr.length() == 3 || uriStr.charAt(3) != '/'))
  -       || ((uriStr.charAt(0) == '/') && (uriStr.length() == 1 || uriStr.charAt(1) != '/')))
  +     && (uriStr.charAt(2) == '/') && (uriStr.charAt(3) != '/'))
  +       || ((uriStr.charAt(0) == '/') && (uriStr.charAt(1) != '/')))
       {
       	uriStr = "file:///"+uriStr;
       }
  
  
  
  1.15.2.1  +3 -20     xml-xalan/java/src/org/apache/xml/utils/TreeWalker.java
  
  Index: TreeWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/TreeWalker.java,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- TreeWalker.java	29 Jul 2002 21:51:15 -0000	1.15
  +++ TreeWalker.java	14 Aug 2002 19:45:36 -0000	1.15.2.1
  @@ -71,7 +71,6 @@
    * This class does a pre-order walk of the DOM tree, calling a ContentHandler
    * interface as it goes.
    */
  -
   public class TreeWalker
   {
   
  @@ -168,13 +167,8 @@
     }
   
     /**
  -   * Perform a pre-order traversal non-recursive style.  
  +   * Perform a pre-order traversal non-recursive style.
      *
  -   * Note that TreeWalker assumes that the subtree is intended to represent 
  -   * a complete (though not necessarily well-formed) document and, during a 
  -   * traversal, startDocument and endDocument will always be issued to the 
  -   * SAX listener.
  -   *  
      * @param pos Node in the tree where to start traversal
      *
      * @throws TransformerException
  @@ -182,8 +176,6 @@
     public void traverse(Node pos) throws org.xml.sax.SAXException
     {
   
  -   	this.m_contentHandler.startDocument();
  -
       Node top = pos;
   
       while (null != pos)
  @@ -219,16 +211,10 @@
   
         pos = nextNode;
       }
  -    this.m_contentHandler.endDocument();
     }
   
     /**
      * Perform a pre-order traversal non-recursive style.
  -
  -   * Note that TreeWalker assumes that the subtree is intended to represent 
  -   * a complete (though not necessarily well-formed) document and, during a 
  -   * traversal, startDocument and endDocument will always be issued to the 
  -   * SAX listener.
      *
      * @param pos Node in the tree where to start traversal
      * @param top Node in the tree where to end traversal
  @@ -238,8 +224,6 @@
     public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
     {
   
  -	this.m_contentHandler.startDocument();
  -	
       while (null != pos)
       {
         startNode(pos);
  @@ -270,7 +254,6 @@
   
         pos = nextNode;
       }
  -    this.m_contentHandler.endDocument();
     }
   
     /** Flag indicating whether following text to be processed is raw text          */
  @@ -342,7 +325,7 @@
         // ??;
         break;
       case Node.DOCUMENT_NODE :
  -    
  +      this.m_contentHandler.startDocument();
         break;
       case Node.ELEMENT_NODE :
         NamedNodeMap atts = ((Element) node).getAttributes();
  @@ -471,8 +454,8 @@
       switch (node.getNodeType())
       {
       case Node.DOCUMENT_NODE :
  +      this.m_contentHandler.endDocument();
         break;
  -      
       case Node.ELEMENT_NODE :
         String ns = m_dh.getNamespaceOfNode(node);
         if(null == ns)
  
  
  
  1.7.2.1   +1 -0      xml-xalan/java/src/org/apache/xml/utils/URI.java
  
  Index: URI.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/URI.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- URI.java	8 Jun 2002 20:41:00 -0000	1.7
  +++ URI.java	14 Aug 2002 19:45:36 -0000	1.7.2.1
  @@ -91,6 +91,7 @@
    * default port for a specific scheme). Rather, it only knows the
    * grammar and basic set of operations that can be applied to a URI.
    *
  + * @version  $Id$
    *
    */
   public class URI implements Serializable
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.1   +253 -0    xml-xalan/java/src/org/apache/xml/utils/Attic/CharacterBlockEnumeration.java
  
  
  
  
  1.1.2.1   +1101 -0   xml-xalan/java/src/org/apache/xml/utils/Attic/DateTimeObj.java
  
  
  
  
  1.1.2.1   +863 -0    xml-xalan/java/src/org/apache/xml/utils/Attic/Duration.java
  
  
  
  
  1.1.2.1   +173 -0    xml-xalan/java/src/org/apache/xml/utils/Attic/SparseVector.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.1   +1 -0      xml-xalan/java/src/org/apache/xml/utils/synthetic/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/synthetic/JavaUtils.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- JavaUtils.java	7 Jun 2002 17:13:55 -0000	1.4
  +++ JavaUtils.java	14 Aug 2002 19:45:36 -0000	1.4.2.1
  @@ -54,6 +54,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>. 
    *
  + * $Id$ 
    */
   
   package org.apache.xml.utils.synthetic;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org