jkesselm    01/05/09 15:02:56

  Modified:    java/src/org/apache/xml/dtm Tag: DTM_EXP
                        ChunkedIntArray.java ComposeDTM.java
                        DTMBuilder.java DTMConstructor.java
                        DTMDocumentImpl.java ExpandedNameTable.java
                        TestDTM.java TestDTMNodes.java
  Log:
  Merge localname tables
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +11 -1     
xml-xalan/java/src/org/apache/xml/dtm/Attic/ChunkedIntArray.java
  
  Index: ChunkedIntArray.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/ChunkedIntArray.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ChunkedIntArray.java      2001/04/27 15:27:38     1.1.2.1
  +++ ChunkedIntArray.java      2001/05/09 22:02:51     1.1.2.2
  @@ -164,6 +164,12 @@
       }
     }
     
  +  // Check that the node at index "position" is not an ancestor
  +  // of the node at index "startPos". IF IT IS, DO NOT ACCEPT IT AND
  +  // RETURN -1. If position is NOT an ancestor, return position.
  +  // Special case: The Document node (position==0) is acceptable.
  +  //
  +  // This test supports DTM.getNextPreceding.
     int specialFind(int startPos, int position)
     {
          // We have to look all the way up the ancestor chain
  @@ -171,13 +177,17 @@
          int ancestor = startPos;
          while(ancestor > 0)
          {
  +             // Get the node whose index == ancestor
                ancestor*=slotsize;
                int chunkpos = ancestor >> lowbits;
                int slotpos = ancestor & lowmask;
                int[] chunk = chunks.elementAt(chunkpos);
                                                        
  +             // Get that node's parent (Note that this assumes w[1]
  +             // is the parent node index. That's really a DTM feature
  +             // rather than a ChunkedIntArray feature.)
                ancestor = chunk[slotpos + 1];
  -               
  +
                if(ancestor == position)
                         break;
          }
  
  
  
  1.1.2.2   +2 -3      
xml-xalan/java/src/org/apache/xml/dtm/Attic/ComposeDTM.java
  
  Index: ComposeDTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/ComposeDTM.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ComposeDTM.java   2001/05/08 16:45:11     1.1.2.1
  +++ ComposeDTM.java   2001/05/09 22:02:52     1.1.2.2
  @@ -26,8 +26,7 @@
                cdtm.constructDoc();
   
                cdtm.newDoc.setNsNameTable(cdtm.symbolTable);
  -             cdtm.newDoc.setElementNameTable(cdtm.symbolTable);
  -             cdtm.newDoc.setAttributeNameTable(cdtm.symbolTable);
  +             cdtm.newDoc.setLocalNameTable(cdtm.symbolTable);
                cdtm.newDoc.setPrefixNameTable(cdtm.symbolTable);
                cdtm.composeDoc();
   
  @@ -67,7 +66,7 @@
        // instantiate a DTM document
        public void constructDoc() {
   
  -             newDoc = new DTMDocumentImpl();
  +             newDoc = new DTMDocumentImpl(0);
   
        }
   
  
  
  
  1.1.2.4   +7 -13     
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMBuilder.java
  
  Index: DTMBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMBuilder.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- DTMBuilder.java   2001/04/27 18:12:07     1.1.2.3
  +++ DTMBuilder.java   2001/05/09 22:02:52     1.1.2.4
  @@ -123,13 +123,11 @@
   
     // Scott suggests sharing pools between DTMs. Note that this will require
     // threadsafety at the pool level.
  -  private static DTMStringPool commonLocalElementNames=new 
DTMSafeStringPool();
  -  private static DTMStringPool commonLocalAttributeNames=new 
DTMSafeStringPool();
  +  private static DTMStringPool commonLocalNames=new DTMSafeStringPool();
     private static DTMStringPool commonNamespaceNames=new DTMSafeStringPool();
     private static DTMStringPool commonPrefixes=new DTMSafeStringPool();
   
  -  private DTMStringPool localElementNames; // For this DTM, may be common
  -  private DTMStringPool localAttributeNames; // For this DTM, may be common
  +  private DTMStringPool localNames; // For this DTM, may be common
     private DTMStringPool namespaceNames; // For this DTM, may be common
     private DTMStringPool prefixes; 
     private FastStringBuffer content; // Unique per DTM
  @@ -158,13 +156,9 @@
       
       // Start with persistant shared pools unless the DTM expresses
       // other preferences
  -    localElementNames=m_dtm.getElementNameTable();
  -    if(localElementNames==null)
  -      m_dtm.setElementNameTable(localElementNames=commonLocalElementNames);
  -
  -    localAttributeNames=m_dtm.getAttributeNameTable();
  -    if(localAttributeNames==null)
  -      
m_dtm.setAttributeNameTable(localAttributeNames=commonLocalAttributeNames);
  +    localNames=m_dtm.getLocalNameTable();
  +    if(localNames==null)
  +      m_dtm.setLocalNameTable(localNames=commonLocalNames);
   
       namespaceNames=m_dtm.getNsNameTable();
       if(namespaceNames==null)
  @@ -301,7 +295,7 @@
   
       // %TBD% Where do we pool expandedName, or is it just the union, or...
       m_dtm.startElement(namespaceNames.stringToIndex(namespaceURI),
  -                  localElementNames.stringToIndex(localName),
  +                  localNames.stringToIndex(localName),
                     prefixes.stringToIndex(prefix)); /////// %TBD%
   
       // %TBD% I'm assuming that DTM will require resequencing of
  @@ -360,7 +354,7 @@
            
            if(!("xmlns".equals(prefix) || "xmlns".equals(qName)))
              
m_dtm.appendAttribute(namespaceNames.stringToIndex(atts.getURI(i)),
  -                               localAttributeNames.stringToIndex(localName),
  +                               localNames.stringToIndex(localName),
                                  prefixes.stringToIndex(prefix),
                                  atts.getType(i).equalsIgnoreCase("ID"),
                                  contentStart, contentEnd-contentStart);
  
  
  
  1.1.2.3   +1 -1      
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMConstructor.java
  
  Index: DTMConstructor.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMConstructor.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DTMConstructor.java       2001/05/06 02:09:40     1.1.2.2
  +++ DTMConstructor.java       2001/05/09 22:02:52     1.1.2.3
  @@ -138,7 +138,7 @@
         // allocate a unique DTM instance and insert at the first available 
slot
         // or add to the end of the DTM allocation table
         if (unique || dtmReuseList.isEmpty()){
  -          dtmImpl = new DTMDocumentImpl();
  +          dtmImpl = new DTMDocumentImpl(0);
             if (!dtmIndexReuseList.isEmpty()){
                 iobj = (Integer)dtmIndexReuseList.lastElement();
                 dtmIndexReuseList.removeElementAt(dtmIndexReuseList.size());
  
  
  
  1.1.2.8   +47 -80    
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDocumentImpl.java
  
  Index: DTMDocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMDocumentImpl.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- DTMDocumentImpl.java      2001/05/09 19:10:19     1.1.2.7
  +++ DTMDocumentImpl.java      2001/05/09 22:02:52     1.1.2.8
  @@ -130,36 +130,31 @@
        // each of which is addressed by the absolute offset and length in the 
buffer
        private FastStringBuffer m_char = new FastStringBuffer();
   
  -     // node name table, name space table, attribute name table, and prefix 
name table
  -     // are can be defined as DTMStringPool(s).  But may be substituted with 
better data
  -     // structure that can support the DTMStringPool interface in the future.
  -
  -     private DTMStringPool m_elementNames = new DTMStringPool();
  +        // %TBD% INITIALIZATION/STARTUP ISSUES
  +     // -- Should we really be creating these, or should they be
  +        // passed in from outside? Scott want to be able to share
  +     // pools across multiple documents, so setting them here is
  +     // probably not the right default.
  +        // %TBD% If we use an ExpandedNameTable mapper, it needs to be bound
  +        // to the NS and local name pools. Which means it needs to attach
  +     // to them AFTER we've resolved their startup. Or it needs to attach
  +        // to this document and retieve them each time...?
  +     private DTMStringPool m_localNames = new DTMStringPool();
        private DTMStringPool m_nsNames = new DTMStringPool();
  -     private DTMStringPool m_attributeNames = new DTMStringPool();
        private DTMStringPool m_prefixNames = new DTMStringPool();
   
  -     // ###jjk m_expandedNames is not needed, as far as I can tell,
  -     // since expanded name indices are currently defined as L bits
  -     // of localname index, N bits of namespace index, and
  -     // (possibly) T bits of node type (current proposal is L=14
  -     // N=14 T=4).  In that setup, it's probably best to index into
  -     // the localname and namespace pools and reconstruct the
  -     // string form if and only if it is actually called for --
  -     // which will be _extremely_ rare -- rather than storing it in
  -     // Yet Another String Pool.
  -        // private DTMStringPool m_expandedNames = new DTMStringPool(); 
//###zaj
  -
        /**
         * Construct a DTM.
         *
  -      * %REVIEW% Do we really want to support a no-arguments constructor
  -      * defaulting to document number 0? Or do we want to insist the
  -      * document ID number always be supplied, and let the caller pass 0
  -      * if that's really what they intend? The latter seems safer.
  +      * @param documentNumber the ID number assigned to this document.
  +      * It will be shifted up into the high bits and returned as part of
  +      * all node ID numbers, so those IDs indicate which document they
  +      * came from as well as a location within the document. It is the
  +      * DTMManager's responsibility to assign a unique number to each
  +      * document.
         */
  -     public DTMDocumentImpl(){
  -             initDocument(0);                 // clear nodes and document 
handle
  +     public DTMDocumentImpl(int documentNumber){
  +             initDocument(documentNumber);    // clear nodes and document 
handle
        }
   
        /**
  @@ -176,8 +171,7 @@
         */
        private final int appendNode(int w0, int w1, int w2, int w3)
        {
  -             // A decent compiler will probably inline this.
  -             // %REVIEW% jjk Do we want to rely on "a decent JIT compiler"?
  +             // A decent compiler may inline this.
                int slotnumber = nodes.appendSlot(w0, w1, w2, w3);
   
                if (DEBUG) System.out.println(slotnumber+": "+w0+" "+w1+" 
"+w2+" "+w3);
  @@ -216,8 +210,8 @@
         *
         * @param poolRef DTMStringPool reference to an instance of table.
         */
  -     public void setElementNameTable(DTMStringPool poolRef) {
  -             m_elementNames = poolRef;
  +     public void setLocalNameTable(DTMStringPool poolRef) {
  +             m_localNames = poolRef;
        }
   
           /**
  @@ -225,8 +219,8 @@
         *
         * @return DTMStringPool reference to an instance of table.
         */
  -        public DTMStringPool getElementNameTable() {
  -                 return m_elementNames;
  +        public DTMStringPool getLocalNameTable() {
  +                 return m_localNames;
            }
   
        /**
  @@ -250,26 +244,6 @@
            }
   
        /**
  -      * Set a reference pointer to the attribute name symbol table.
  -      * %REVIEW% Should this really be Public? Changing it while
  -      * DTM is in use would be a disaster.
  -      *
  -      * @param poolRef DTMStringPool reference to an instance of table.
  -      */
  -     public void setAttributeNameTable(DTMStringPool poolRef) {
  -             m_attributeNames = poolRef;
  -     }
  -
  -        /**
  -      * Get a reference pointer to the attribute name symbol table.
  -      *
  -      * @return DTMStringPool reference to an instance of table.
  -      */
  -        public DTMStringPool getAttributeNameTable() {
  -                 return m_attributeNames;
  -         }
  -
  -     /**
         * Set a reference pointer to the prefix name symbol table.
         * %REVIEW% Should this really be Public? Changing it while
         * DTM is in use would be a disaster.
  @@ -289,18 +263,6 @@
                return m_prefixNames;
        }
   
  -     /**
  -      * Set a reference pointer to the expanded name symbol table.
  -      *
  -      * @param poolRef DTMStringPool reference to an instance of table.
  -      */
  -     //###zaj
  -     //### jjk see earlier discussion; this appears superfluous.
  -       //    public void setExpandedNameTable(DTMStringPool poolRef) {
  -       //            m_expandedNames = poolRef;
  -       //    }
  -
  -
            /**
             * Set a reference pointer to the content-text repository
             *
  @@ -333,18 +295,13 @@
         *
         * The DTMManager will invoke this method when the dtm is created.
         *
  -      * %REVIEW% Given the way getDocument() is currently coded,
  -      * the docHandle parameter is apparently supposed to be the
  -      * document number pre-shifted up into the high bits. Do we
  -      * really want to require that, or should we accept the
  -      * document number instead and shift it for them?
  -      *
         * @param docHandle int the handle for the DTM document.
         */
  -     final void initDocument(int docHandle)
  +     final void initDocument(int documentNumber)
        {
                // save masked DTM document handle
  -             m_docHandle = docHandle;
  +             m_docHandle = documentNumber<<DOCHANDLE_SHIFT;
  +
                // Initialize the doc -- no parent, no next-sib
                nodes.writeSlot(0,DOCUMENT_NODE,-1,-1,0);
                // wait for the first startElement to create the doc root node
  @@ -456,7 +413,7 @@
                // onverted to index values modified to match a
                // method.
                int nsIndex = NULL;
  -             int nameIndex = m_elementNames.stringToIndex(name);
  +             int nameIndex = m_localNames.stringToIndex(name);
                // note - there should be no prefix separator in the name 
because it is not associated
                // with a name space
   
  @@ -492,7 +449,7 @@
                // onverted to index values modified to match a
                // method.
                int nsIndex = m_nsNames.stringToIndex(ns);
  -             int nameIndex = m_elementNames.stringToIndex(name);
  +             int nameIndex = m_localNames.stringToIndex(name);
                // The prefixIndex is not needed by the indexed interface of 
the createElement method
                int prefixSep = name.indexOf(":");
                int prefixIndex = m_prefixNames.stringToIndex(name.substring(0, 
prefixSep));
  @@ -573,7 +530,7 @@
                // W2:  Next (not yet resolved)
                int w2 = 0;
                // W3:  Tag name
  -             int w3 = m_attributeNames.stringToIndex(attName);
  +             int w3 = m_localNames.stringToIndex(attName);
                // Add node
                int ourslot = appendNode(w0, w1, w2, w3);
                previousSibling = ourslot;      // Should attributes be 
previous siblings
  @@ -794,7 +751,7 @@
         */
        public int getAttributeNode(int nodeHandle, String namespaceURI, String 
name) {
                int nsIndex = m_nsNames.stringToIndex(namespaceURI),
  -                                                                     
nameIndex = m_attributeNames.stringToIndex(name);
  +                                                                     
nameIndex = m_localNames.stringToIndex(name);
                nodeHandle &= NODEHANDLE_MASK;
                nodes.readSlot(nodeHandle, gotslot);
                short type = (short) (gotslot[0] & 0xFFFF);
  @@ -1028,6 +985,15 @@
                        nodeHandle--;
                        if (ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 
0xFFFF))
                                continue;
  +
  +                     // if nodeHandle is _not_ an ancestor of
  +                     // axisContextHandle, specialFind will return it.
  +                     // If it _is_ an ancestor, specialFind will return -1
  +
  +                     // %REVIEW% unconditional return defeats the
  +                     // purpose of the while loop -- does this
  +                     // logic make any sense?
  +
                        return (m_docHandle | 
nodes.specialFind(axisContextHandle, nodeHandle));
                }
                return NULL;
  @@ -1186,8 +1152,9 @@
        public int getExpandedNameID(int nodeHandle) {
           nodes.readSlot(nodeHandle, gotslot);
   
  -           String qName = m_elementNames.indexToString(gotslot[3]); 
  -           // Remove prefix from localName
  +           String qName = m_localNames.indexToString(gotslot[3]); 
  +           // Remove prefix from qName
  +        // %TBD% jjk This is assuming the elementName is the qName.
           int colonpos = qName.indexOf(":");
           String localName = qName.substring(colonpos+1);
           // Get NS
  @@ -1213,7 +1180,7 @@
           public int getExpandedNameID(String namespace, String localName, int 
type) {
           // Create expanded name
          // %TBD% jjk Expanded name is bitfield-encoded as
  -       // typeID[4]nsuriID[14]localID[14]. Switch to that form, and to
  +       // typeID[6]nsuriID[10]localID[16]. Switch to that form, and to
          // accessing the ns/local via their tables rather than confusing
          // nsnames and expandednames.
           String expandedName = namespace + ":" + localName;
  @@ -1233,7 +1200,7 @@
        public String getLocalNameFromExpandedNameID(int ExpandedNameID) {
   
           // Get expanded name
  -        String expandedName = m_elementNames.indexToString(ExpandedNameID); 
  +        String expandedName = m_localNames.indexToString(ExpandedNameID); 
           // Remove prefix from expanded name
           int colonpos = expandedName.indexOf(":");
           String localName = expandedName.substring(colonpos+1);
  @@ -1251,7 +1218,7 @@
        */
        public String getNamespaceFromExpandedNameID(int ExpandedNameID) {
   
  -        String expandedName = m_elementNames.indexToString(ExpandedNameID); 
  +        String expandedName = m_localNames.indexToString(ExpandedNameID); 
           // Remove local name from expanded name
           int colonpos = expandedName.indexOf(":");
           String nsName = expandedName.substring(0, colonpos);
  @@ -1287,9 +1254,9 @@
                String name = fixednames[type];
                if (null == name) { 
                        if (type == ELEMENT_NODE) 
  -                             name = m_elementNames.indexToString(gotslot[3]);
  +                             name = m_localNames.indexToString(gotslot[3]);
                        else if (type == ATTRIBUTE_NODE)
  -                             name = 
m_attributeNames.indexToString(gotslot[3]);
  +                             name = m_localNames.indexToString(gotslot[3]);
                }
                return name;
        }
  
  
  
  1.1.2.4   +8 -4      
xml-xalan/java/src/org/apache/xml/dtm/Attic/ExpandedNameTable.java
  
  Index: ExpandedNameTable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/ExpandedNameTable.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ExpandedNameTable.java    2001/05/08 16:45:21     1.1.2.3
  +++ ExpandedNameTable.java    2001/05/09 22:02:53     1.1.2.4
  @@ -61,10 +61,14 @@
    * expanded names to expandedNameIDs.
    *
    * %REVIEW% Note that this is not really a separate table, or a
  - * separate pool. Instead, it's an access method build on top of three
  - * pieces of information: the index numbers for a node's namespaceURI,
  - * localName, and node type, which are combined to yield a composite
  - * index number.
  + * separate pool. Instead, it's an access method build on top of the
  + * existing pools, using three pieces of information: the index
  + * numbers for a node's namespaceURI, localName, and node type, which
  + * are combined to yield a composite index number.
  + *
  + * %TBD% startup sequence -- how this gets access to the appropriate
  + * string pools in the DTMDocument/stylesheet.
  + *
    * */
   public class ExpandedNameTable
   {
  
  
  
  1.1.2.5   +1 -1      xml-xalan/java/src/org/apache/xml/dtm/Attic/TestDTM.java
  
  Index: TestDTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/TestDTM.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- TestDTM.java      2001/05/09 20:05:07     1.1.2.4
  +++ TestDTM.java      2001/05/09 22:02:53     1.1.2.5
  @@ -20,7 +20,7 @@
                 *   <C>My Anaconda<D/>Words</C>
                 *  </top> */
   
  -             DTMDocumentImpl doc = new DTMDocumentImpl();
  +             DTMDocumentImpl doc = new DTMDocumentImpl(0);
                doc.createElement("top",  null);
                doc.createElement( "A", null);
                AttributesImpl atts = new AttributesImpl();
  
  
  
  1.1.2.4   +24 -10    
xml-xalan/java/src/org/apache/xml/dtm/Attic/TestDTMNodes.java
  
  Index: TestDTMNodes.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/TestDTMNodes.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- TestDTMNodes.java 2001/05/08 16:45:24     1.1.2.3
  +++ TestDTMNodes.java 2001/05/09 22:02:53     1.1.2.4
  @@ -2,17 +2,31 @@
   
   import org.apache.xml.dtm.ChunkedIntArray;
   
  +/** Debugging dump routine for DTMDocumentImpl. Note that it directly 
accesses
  + * that class's internal data... which probably shouldn't be exposed.
  + */
   public class TestDTMNodes {
   
  -     public static void printNodeTable(DTMDocumentImpl doc) {
  -             int length = doc.nodes.slotsUsed(), slot[] = new int[4];
  -             for (int i=0; i <= length; i++) {
  -                     doc.nodes.readSlot(i, slot);
  -                     short high = (short) (slot[0] >> 16), low = (short) 
(slot[0] & 0xFFFF);
  -                     System.out.println(i + ": (" + high + ") (" + low + ") 
" + slot[1] + 
  -                                                                             
                 " " + slot[2] + " " +slot[3] + " Node Name: " + 
  -                                                                             
                 doc.getNodeName(i) + " Node Value: " + doc.getNodeValue(i)); 
  -             }
  +  public static void printNodeTable(DTMDocumentImpl doc) {
  +    int length = doc.nodes.slotsUsed(), slot[] = new int[4];
  +    for (int i=0; i <= length; i++) {
  +      doc.nodes.readSlot(i, slot);
   
  -     }
  +      // Word0 is shown as its two halfwords
  +      short high = (short) (slot[0] >> 16);
  +      short low = (short) (slot[0] & 0xFFFF);
  +
  +      System.out.println(i + ": (" + high + ") (" + low +
  +                      ") " + slot[1] + " " + slot[2] +
  +                      " " +slot[3] +
  +                      "\n\tName: " +  doc.getNodeName(i) +
  +                      " Value: " + doc.getNodeValue(i) +
  +                      " Parent: " + doc.getParent(i) +
  +                      " FirstAttr: " + doc.getFirstAttribute(i) +
  +                      " FirstChild: " + doc.getFirstChild(i) +
  +                      " NextSib: " + doc.getNextSibling(i)
  +                      ); 
  +    }
  +
  +  }
   }
  
  
  

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

Reply via email to