jkesselm    02/05/21 08:28:01

  Modified:    java/src/org/apache/xml/dtm Tag: Xalan3 DTMManager.java
               java/src/org/apache/xml/dtm/ref Tag: Xalan3
                        DTMDefaultBase.java DTMDefaultBaseIterators.java
                        DTMDefaultBaseTraversers.java
                        DTMManagerDefault.java ExpandedNameTable.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: Xalan3
                        SAX2RTFDTM.java
               java/src/org/apache/xml/dtm/ref/xni2dtm Tag: Xalan3
                        XNI2DTM.java
  Log:
  Merge changes from recent main-line Xalan, apply fix to schematype lookup.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.10.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.9
  retrieving revision 1.9.10.1
  diff -u -r1.9 -r1.9.10.1
  --- DTMManager.java   23 Jan 2002 22:53:47 -0000      1.9
  +++ DTMManager.java   21 May 2002 15:28:00 -0000      1.9.10.1
  @@ -486,7 +486,7 @@
             System.err.println("DTM: found  " + serviceId);
           }
   
  -        BufferedReader rd = new BufferedReader(new InputStreamReader(is));
  +        BufferedReader rd = new BufferedReader(new 
InputStreamReader(is,"UTF-8"));
   
           foundFactory = rd.readLine();
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.27.2.3  +15 -4     
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.27.2.2
  retrieving revision 1.27.2.3
  diff -u -r1.27.2.2 -r1.27.2.3
  --- DTMDefaultBase.java       29 Apr 2002 17:49:31 -0000      1.27.2.2
  +++ DTMDefaultBase.java       21 May 2002 15:28:00 -0000      1.27.2.3
  @@ -176,9 +176,6 @@
     /** The XMLString factory for creating XMLStrings. */
     protected XMLStringFactory m_xstrf;
   
  -  /** The identity of the root node. */
  -  public static final int ROOTNODE = 0;
  -
     /**
      * The table for exandedNameID lookups.  This may or may not be the same
      * table as is contained in the DTMManagerDefault.
  @@ -1404,7 +1401,7 @@
      */
     public int getDocument()
     {
  -    return m_dtmIdent.elementAt(0); // makeNodeHandle(0)
  +    return m_dtmIdent.elementAt(0);
     }
   
     /**
  @@ -1439,6 +1436,20 @@
     public int getDocumentRoot(int nodeHandle)
     {
       return getDocument();
  +  }
  +
  +  /**
  +   * 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;
     }
   
     /**
  
  
  
  1.11.6.3  +16 -18    
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.11.6.2
  retrieving revision 1.11.6.3
  diff -u -r1.11.6.2 -r1.11.6.3
  --- DTMDefaultBaseIterators.java      15 May 2002 16:57:22 -0000      1.11.6.2
  +++ DTMDefaultBaseIterators.java      21 May 2002 15:28:00 -0000      1.11.6.3
  @@ -402,7 +402,7 @@
   
         _currentNode = END;
   
  -      return result;
  +      return returnNode(result);
       }
     }  // end of ParentIterator
   
  @@ -1131,7 +1131,7 @@
       private final int _maxAncestors = 8;
   
       /**
  -     * The stack of start node + ancestors up to ROOTNODE,
  +     * The stack of start node + ancestors up to the root of the tree,
        *  which we must avoid.
        */
       private int[] _stack = new int[_maxAncestors];
  @@ -1196,25 +1196,23 @@
           int parent, index;
   
           _startNode = node;
  -        _currentNode = ROOTNODE;  // Remember it's the identity, not the 
full handle.
           _stack[index = 0] = node;
   
  -        if (node > ROOTNODE)
  -        {
  -          while ((parent = _parent(node)) != ROOTNODE)
  -          {
  -            if (++index == _stack.length)
  -            {
  -              final int[] stack = new int[index + 4];
  -
  -              System.arraycopy(_stack, 0, stack, 0, index);
  -
  -              _stack = stack;
  -            }
  -
  -            _stack[index] = node = parent;
  -          }
  +             parent=node;
  +             while ((parent = _parent(parent)) != NULL)
  +             {
  +                     if (++index == _stack.length)
  +                     {
  +                             final int[] stack = new int[index + 4];
  +                             System.arraycopy(_stack, 0, stack, 0, index);
  +                             _stack = stack;
  +                     }
  +                     _stack[index] = parent;
           }
  +        if(index>0)
  +             --index; // Pop actual root node (if not start) back off the 
stack
  +
  +        _currentNode=_stack[index]; // Last parent before root node
   
           _oldsp = _sp = index;
   
  
  
  
  1.8.10.2  +73 -13    
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.8.10.1
  retrieving revision 1.8.10.2
  diff -u -r1.8.10.1 -r1.8.10.2
  --- DTMDefaultBaseTraversers.java     29 Apr 2002 17:49:32 -0000      1.8.10.1
  +++ DTMDefaultBaseTraversers.java     21 May 2002 15:28:00 -0000      1.8.10.2
  @@ -517,7 +517,7 @@
       {
         return (m_indexing
                 && ExpandedNameTable.ELEMENT
  -                 == m_expandedNameTable.getType(expandedTypeID));
  +                 == m_expandedNameTable.getType(expandedTypeID)); 
       }
   
       /**
  @@ -1256,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);
   
  @@ -1285,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);
   
  @@ -1320,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);
   
  @@ -1348,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);
   
  @@ -1485,7 +1489,7 @@
        */
       public int first(int context)
       {
  -      return getDocument();
  +      return getDocumentRoot(context);
       }
   
       /**
  @@ -1498,7 +1502,7 @@
        */
       public int first(int context, int expandedTypeID)
       {
  -      return (getExpandedTypeID(getDocument()) == expandedTypeID)
  +      return (getExpandedTypeID(getDocumentRoot(context)) == expandedTypeID)
                ? context : next(context, context, expandedTypeID);
       }
   
  @@ -1618,8 +1622,7 @@
        */
       protected int getSubtreeRoot(int handle)
       {
  -                     // %REVIEW% Shouldn't this always be 0?
  -      return makeNodeIdentity(getDocument());
  +      return _documentRoot(makeNodeIdentity(handle));
       }
   
       /**
  @@ -1631,7 +1634,35 @@
        */
       public int first(int context)
       {
  -      return getDocument();
  +      return getDocumentRoot(context);
  +    }
  +    
  +    /**
  +     * By the nature of the stateless traversal, the context node can not be
  +     * returned or the iteration will go into an infinate loop.  So to 
traverse
  +     * an axis, the first function must be used to get the first node.
  +     *
  +     * <p>This method needs to be overloaded only by those axis that process
  +     * the self node. <\p>
  +     *
  +     * @param context The context node of this traversal. This is the point
  +     * of origin for the traversal -- its "root node" or starting point.
  +     * @param expandedTypeID The expanded type ID that must match.
  +     *
  +     * @return the first node in the traversal.
  +     */
  +    public int first(int context, int expandedTypeID)
  +    {
  +      if (isIndexed(expandedTypeID))
  +      {
  +        int identity = _documentRoot(makeNodeIdentity(context));
  +        int firstPotential = getFirstPotential(identity);
  +
  +        return makeNodeHandle(getNextIndexed(identity, firstPotential, 
expandedTypeID));
  +      }
  +
  +      int root = first(context); 
  +      return next(root, root, expandedTypeID);
       }
     }
     
  @@ -1652,7 +1683,7 @@
        */
       protected int getFirstPotential(int identity)
       {
  -      return _firstch(0);
  +      return _firstch(_documentRoot(identity));
       }
   
       /**
  @@ -1662,7 +1693,7 @@
        */
       protected int getSubtreeRoot(int handle)
       {
  -      return 0;
  +      return _documentRoot(makeNodeIdentity(handle));
       }
   
       /**
  @@ -1674,8 +1705,37 @@
        */
       public int first(int context)
       {
  -      return makeNodeHandle(_firstch(0));
  +      return 
makeNodeHandle(_firstch(_documentRoot(makeNodeIdentity(context))));
       }
  +    
  +    /**
  +     * By the nature of the stateless traversal, the context node can not be
  +     * returned or the iteration will go into an infinate loop.  So to 
traverse
  +     * an axis, the first function must be used to get the first node.
  +     *
  +     * <p>This method needs to be overloaded only by those axis that process
  +     * the self node. <\p>
  +     *
  +     * @param context The context node of this traversal. This is the point
  +     * of origin for the traversal -- its "root node" or starting point.
  +     * @param expandedTypeID The expanded type ID that must match.
  +     *
  +     * @return the first node in the traversal.
  +     */
  +    public int first(int context, int expandedTypeID)
  +    {
  +      if (isIndexed(expandedTypeID))
  +      {
  +        int identity = _documentRoot(makeNodeIdentity(context)); 
  +        int firstPotential = getFirstPotential(identity);
  +
  +        return makeNodeHandle(getNextIndexed(identity, firstPotential, 
expandedTypeID));
  +      }
  +
  +      int root = getDocumentRoot(context); 
  +      return next(root, root, expandedTypeID);
  +    }
  +    
     }
   
   }
  
  
  
  1.41.2.5  +7 -3      
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.2.4
  retrieving revision 1.41.2.5
  diff -u -r1.41.2.4 -r1.41.2.5
  --- DTMManagerDefault.java    29 Apr 2002 16:07:40 -0000      1.41.2.4
  +++ DTMManagerDefault.java    21 May 2002 15:28:00 -0000      1.41.2.5
  @@ -121,12 +121,14 @@
    * */
   public class DTMManagerDefault extends DTMManager
   {
  +  /** Set false to disable the new XNI support and force SAX instead
  +   * */
     static final boolean JJK_ENABLE_XNI=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;
   
     /**
  @@ -316,6 +318,8 @@
           // we need to consider architectural improvements.
           dtm = new SAX2RTFDTM(this, source, documentID, whiteSpaceFilter,
                                xstringFactory, doIndexing);
  +        if(DEBUG)
  +             System.out.println("CREATING RTF DTM: "+dtm);
         }
         else // Create the basic SAX2DTM.
         {
  @@ -854,10 +858,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.3.10.5  +111 -76   
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.3.10.4
  retrieving revision 1.3.10.5
  diff -u -r1.3.10.4 -r1.3.10.5
  --- ExpandedNameTable.java    3 May 2002 14:44:40 -0000       1.3.10.4
  +++ ExpandedNameTable.java    21 May 2002 15:28:00 -0000      1.3.10.5
  @@ -59,6 +59,7 @@
   import org.apache.xml.dtm.DTM;
   
   import java.util.Vector;
  +import java.util.Hashtable;
   
   /**
    * This is a default implementation of a table that manages mappings from
  @@ -76,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;
  @@ -104,6 +110,12 @@
     public static final int NOTATION = ((int)DTM.NOTATION_NODE) ;
     public static final int NAMESPACE = ((int)DTM.NAMESPACE_NODE) ;
     
  +  Hashtable m_hashtable = new Hashtable();
  +  
  +     /** Workspace for lookup. NOT THREAD SAFE!
  +      * */
  +     ExtendedType hashET=new ExtendedType(-1,"","");  
  +  
   
     /**
      * Create an expanded name table that uses private string pool lookup.
  @@ -139,7 +151,9 @@
       int i;
       for (i = 0; i < DTM.NTYPES; i++)
       {
  -      m_extendedTypes.addElement(new ExtendedType(i, "", "") ); 
  +      ExtendedType newET = new ExtendedType(i, "", ""); 
  +      m_extendedTypes.addElement(newET); 
  +      m_hashtable.put(newET, new Integer(i));
       }
       m_nextType = m_extendedTypes.size();
     }
  @@ -166,16 +180,21 @@
   */
       if (null == namespace) 
         namespace = "";
  -      if (null == localName) 
  +    if (null == localName) 
         localName = "";
  -      int length=m_extendedTypes.size();
  -    for (int i = 0; i < length; i++)
  -    {
  -      ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt(i);
  -      if( type == etype.nodetype && namespace.equals(etype.namespace) && 
localName.equals(etype.localName)) 
  -        return i;
  -    }
  -    m_extendedTypes.addElement(new ExtendedType(type, namespace, localName));
  +    // Set our reusable ExpandedType so we can look
  +    // it up in the hashtable. Not threadsafe, but
  +    // avoids creating a new object until we know
  +    // this isn't one we've seen before.
  +    hashET.redefine(type,namespace,localName);
  +    
  +    Object eType;
  +    if ((eType = m_hashtable.get(hashET)) != null )
  +      return ((Integer)eType).intValue();
  +    
  +    ExtendedType newET=new ExtendedType(type, namespace, localName);
  +    m_extendedTypes.addElement(newET);
  +    m_hashtable.put(newET, new Integer(m_nextType));
       return m_nextType++;
     }
     
  @@ -189,18 +208,8 @@
      * @return the expanded-name id of the node.
      */
     public int getExpandedTypeID(int type)
  -  {
  -    /*int expandedTypeID = (type << (BITS_PER_NAMESPACE+BITS_PER_LOCALNAME));
  -
  -    return expandedTypeID;
  -    */
  -    for (int i = 0; i < m_extendedTypes.size(); i++)
  -    {
  -      ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt(i);
  -      if( type == etype.nodetype ) 
  -        return i;
  -    }
  -    return -1; // something's very wrong!
  +  {    
  +    return type;    
     }
   
     /**
  @@ -278,74 +287,100 @@
       return (short)etype.nodetype;
     }
     
  -  /**
  -   * Given an expanded-name ID, return the default schema type object
  -   *
  -   * @param ExpandedNameID an ID that represents an expanded-name.
  -   * @return a schema type object -- probably an XNI PSVI type.
  -   */
  -  public final Object getSchemaType(int ExpandedNameID)
  -  {
  -    ExtendedType etype = (ExtendedType)m_extendedTypes.elementAt 
(ExpandedNameID);
  -    return (etype.schemaType==ExtendedType.NULL_SCHEMATYPE) ? null : 
etype.schemaType;
  -  }
  -  
  -  /**
  -   * Given an expanded-name ID, set the default schema type object if not
  -   * previously set.
  -   *
  -   * @param ExpandedNameID an ID that represents an expanded-name.
  -   * @param schemaType a schema type object -- probably an XNI PSVI type.
  -   * @return false if previously set to something different
  -   *  (as determined by Object.equals), otherwise true. False can
  -   *  be used as a hint that we should record a type override for this
  -   *  node.
  -   */
  -  public final boolean setSchemaType(int ExpandedNameID, Object schemaType)
  +  /** 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 etype = (ExtendedType)m_extendedTypes.elementAt 
(ExpandedNameID);
  -    Object oldtype=etype.schemaType;
  -    if(oldtype==null)
  +    ExtendedType et=(ExtendedType)m_extendedTypes.elementAt (ExpandedNameID);
  +    if(et.schemaType==UNKNOWN_SCHEMA_TYPE)
       {
  -      etype.schemaType=(schemaType==null) ? ExtendedType.NULL_SCHEMATYPE : 
schemaType;
  +      et.schemaType=schemaType;
         return true;
       }
  -    else return oldtype.equals(schemaType);
  +    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;
  +  }
  +
     /**
  -   * Inner class representing an extended type object.
  +   * Private class representing an extended type object 
      */
  -   class ExtendedType
  +  private class ExtendedType
     {
  -     int nodetype;
  -     String namespace;
  -     String localName;
  -    Object schemaType=null; // Default, for XNI PSVI support
  -
  -    /** We need a value other than NULL which can be used to indicate that
  -     the default (first-seen) schemaType really is null rather than
  -     not-yet-established. This singleton is a bit of a kluge, but it
  -     does the job...
  -
  -     %REVIEW%
  -     This is mostly an issue because I implemented XNI2DTM as a subclass
  -     of SAX2DTM and tried to leverage the existing code -- which means
  -     we're trying to set the default type _after_ the ExpandedNameTable
  -     entry has been constructed. Architecturally, it'd be better to
  -     pass this info into the ctor, but that'd require a more
  -     substantial rewrite of XNI2DTM.addNode (more code duplication).
  -     Worth reconsidering.
  -    */
  -    public static final String NULL_SCHEMATYPE="NULL_SCHEMATYPE";
  +    protected Object schemaType=UNKNOWN_SCHEMA_TYPE;
       
  -     ExtendedType (int nodetype, String namespace, String localName)
  +    protected int nodetype;
  +    protected String namespace;
  +    protected String localName;
  +    protected int hash;
  +    
  +    protected ExtendedType (int nodetype, String namespace, String localName)
       {
         this.nodetype = nodetype;
         this.namespace = namespace;
         this.localName = localName;
  +      this.hash=nodetype+namespace.hashCode()+localName.hashCode();
       }
  +
  +     /* This is intended to be used ONLY on the hashET
  +      * object. Using it elsewhere will mess up existing
  +      * hashtable entries!
  +      * */
  +    protected void redefine(int nodetype, String namespace, String localName)
  +    {
  +      this.nodetype = nodetype;
  +      this.namespace = namespace;
  +      this.localName = localName;
  +      this.hash=nodetype+namespace.hashCode()+localName.hashCode();
  +    }
  +    
  +    /* Override super method
  +      * */
  +    public int hashCode() 
  +    {
  +     return hash;
  +    }
  +
  +    /* Override super method
  +      * */
  +     public boolean equals(Object other)
  +     {
  +             //Usually an optimization, but 
  +             // won't arise in our usage:
  +             //if(other==this) return true;
  +             try
  +             {
  +                     ExtendedType et=(ExtendedType)other;
  +                     return et.nodetype==this.nodetype &&
  +                             et.localName.equals(this.localName) &&
  +                             et.namespace.equals(this.namespace);
  +             }
  +             catch(ClassCastException e)
  +             {
  +                     return false;
  +             }
  +             catch(NullPointerException e)
  +             {
  +                     return false;
  +             }
  +     }
     }
     
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.6.1   +23 -3     
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2RTFDTM.java
  
  Index: SAX2RTFDTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2RTFDTM.java,v
  retrieving revision 1.3
  retrieving revision 1.3.6.1
  diff -u -r1.3 -r1.3.6.1
  --- SAX2RTFDTM.java   8 Feb 2002 23:33:50 -0000       1.3
  +++ SAX2RTFDTM.java   21 May 2002 15:28:01 -0000      1.3.6.1
  @@ -108,9 +108,6 @@
    * */
   public class SAX2RTFDTM extends SAX2DTM
   {
  -  /** Set true to monitor SAX events and similar diagnostic info. */
  -  private static final boolean DEBUG = false;
  -  
     /** Most recently started Document, or null if the DTM is empty.  */
     private int m_currentDocumentNode=NULL;
     
  @@ -192,6 +189,29 @@
   
       return DTM.NULL; // Safety net; should never happen
     }
  +
  +  /**
  +   * 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)
  +  {
  +     if(nodeIdentifier==NULL) return NULL;
  +     
  +    for(int parent=_parent(nodeIdentifier);
  +     parent!=NULL;
  +     nodeIdentifier=parent,parent=_parent(nodeIdentifier))
  +     ;
  +    
  +    return nodeIdentifier;
  +  }
  +
  +  
     
     /**
      * Receive notification of the beginning of a new RTF document.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.6   +6 -7      
xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/XNI2DTM.java
  
  Index: XNI2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/xni2dtm/Attic/XNI2DTM.java,v
  retrieving revision 1.2.2.5
  retrieving revision 1.2.2.6
  diff -u -r1.2.2.5 -r1.2.2.6
  --- XNI2DTM.java      3 May 2002 14:44:40 -0000       1.2.2.5
  +++ XNI2DTM.java      21 May 2002 15:28:01 -0000      1.2.2.6
  @@ -206,13 +206,12 @@
        // The goal is to not consume storage for types unless they actualy 
exist,
        // and to minimize per-node overhead.
        //
  -     // %BUG% %OPT% %REVIEW% (and various other expressions of "GONK!"):
  -     // The solution shown here does not achieve the latter. It's just a
  -     // quick get-the-API-working prototype. I suspect the Right Answer is
  -     // going to be to enhance the concept of Expanded Type to include 
semantic
  -     // (schema) types as well as syntactic (QName/nodetype) types.
  -     
  -     if(actualType != null)
  +     // NOTE: Record first-seen as default even if it is null, because
  +     // otherwise late changes of type will bash previously recorded
  +     // nodes. This is NOT necessarily maximally efficient, but to really
  +     // optimize we would have to rewrite data to make the default the most
  +     // common -- and since Scott insists that overrides will be uncommon,
  +     // I don't want to go there.
        {
          // Try to record as default for this nodetype
          if(!m_expandedNameTable.setSchemaType(m_exptype.elementAt(identity),
  
  
  

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

Reply via email to