johng       01/08/23 21:49:31

  Modified:    java/src/org/apache/xml/dtm DTM.java
               java/src/org/apache/xml/dtm/ref DTMDefaultBase.java
                        DTMDocumentImpl.java DTMManagerDefault.java
  Log:
  added document registration and release events to the DTM interface
  Submitted by: John Gentilin
  
  Revision  Changes    Path
  1.4       +29 -12    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DTM.java  2001/07/11 04:00:13     1.3
  +++ DTM.java  2001/08/24 04:49:31     1.4
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Xalan" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -197,9 +197,9 @@
     public void setProperty(String property, Object value);
   
     // ========= Document Navigation Functions =========
  -  
  +
     /**
  -   * This returns a stateless "traverser", that can navigate over an 
  +   * This returns a stateless "traverser", that can navigate over an
      * XPath axis, though not in document order.
      *
      * @param axis One of Axes.ANCESTORORSELF, etc.
  @@ -207,9 +207,9 @@
      * @return A DTMAxisIterator, or null if the givin axis isn't supported.
      */
     public DTMAxisTraverser getAxisTraverser(final int axis);
  -  
  +
     /**
  -   * This is a shortcut to the iterators that implement 
  +   * This is a shortcut to the iterators that implement
      * XPath axes.
      * Returns a bare-bones iterator that must be initialized
      * with a start node (using iterator.setStartNode()).
  @@ -221,10 +221,10 @@
     public DTMAxisIterator getAxisIterator(final int axis);
   
     /**
  -   * Get an iterator that can navigate over an XPath Axis, predicated by 
  +   * Get an iterator that can navigate over an XPath Axis, predicated by
      * the extended type ID.
      *
  -   * @param axis 
  +   * @param axis
      * @param type An extended type ID.
      *
      * @return A DTMAxisIterator, or null if the givin axis isn't supported.
  @@ -550,7 +550,7 @@
      */
     public short getLevel(int nodeHandle);
   
  -  // ============== Document query functions ============== 
  +  // ============== Document query functions ==============
   
     /**
      * Tests whether DTM DOM implementation implements a specific feature and
  @@ -818,7 +818,7 @@
      *
      * @param nodeHandle The node ID.
      * @param ch A non-null reference to a ContentHandler.
  -   * @param normalize true if the content should be normalized according to 
  +   * @param normalize true if the content should be normalized according to
      * the rules for the XPath
      * <a 
href="http://www.w3.org/TR/xpath#function-normalize-space";>normalize-space</a>
      * function.
  @@ -947,4 +947,21 @@
      * is available
      */
     public SourceLocator getSourceLocatorFor(int node);
  +
  +  /**
  +   * As the DTM is registered with the DTMManager, this method
  +   * will be called. This will give the DTM implementation a
  +   * chance to initialize any subsystems that are required to
  +   * build the DTM
  +   */
  +  public void documentRegistration();
  +
  +  /**
  +   * As documents are released from the DTMManager, the DTM implementation
  +   * will be notified of the event. This will allow the DTM implementation
  +   * to shutdown any subsystem activity that may of been assoiated with
  +   * the active DTM Implementation.
  +   */
  +
  +   public void documentRelease();
   }
  
  
  
  1.16      +63 -44    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DTMDefaultBase.java       2001/08/10 17:57:37     1.15
  +++ DTMDefaultBase.java       2001/08/24 04:49:31     1.16
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Xalan" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -122,13 +122,13 @@
   
     /** Previous sibling values, one array element for each node. */
     protected SuballocatedIntVector m_parent;
  -  
  +
     /** Experemental.  -sb */
   //  protected boolean m_haveSeenNamespace = false;
  -  
  +
     /** Vector of SuballocatedIntVectors of NS decl sets  -jjk */
     protected Vector m_namespaceDeclSets = null;
  -  
  +
     /** SuballocatedIntVector  of elements at which corresponding
      * namespaceDeclSets were defined -jjk */
     protected SuballocatedIntVector m_namespaceDeclSetElements = null;
  @@ -350,7 +350,7 @@
      * @param list A list of integers.
      * @param start The start index to begin the search.
      * @param len The number of items to search.
  -   * @param value Find the slot that has a value that is greater than or 
  +   * @param value Find the slot that has a value that is greater than or
      * identical to this argument.
      *
      * @return The index in the list of the slot that is higher or identical
  @@ -454,7 +454,7 @@
   //     */
   //    protected void ensureSize(int index)
   //    {
  -//        // We've cut over to Suballocated*Vector, which are self-sizing. 
  +//        // We've cut over to Suballocated*Vector, which are self-sizing.
   //    }
   
     /**
  @@ -538,8 +538,8 @@
       // Boiler-plate code for each of the _xxx functions, except for the array.
       int info = (identity >= m_size) ? NOTPROCESSED : m_firstch.elementAt(identity);
   
  -    // Check to see if the information requested has been processed, and, 
  -    // if not, advance the iterator until we the information has been 
  +    // Check to see if the information requested has been processed, and,
  +    // if not, advance the iterator until we the information has been
       // processed.
       while (info == NOTPROCESSED)
       {
  @@ -571,8 +571,8 @@
       // Boiler-plate code for each of the _xxx functions, except for the array.
       int info = (identity >= m_size) ? NOTPROCESSED : m_nextsib.elementAt(identity);
   
  -    // Check to see if the information requested has been processed, and, 
  -    // if not, advance the iterator until we the information has been 
  +    // Check to see if the information requested has been processed, and,
  +    // if not, advance the iterator until we the information has been
       // processed.
       while (info == NOTPROCESSED)
       {
  @@ -604,8 +604,8 @@
       if (identity < m_size)
         return m_prevsib.elementAt(identity);
   
  -    // Check to see if the information requested has been processed, and, 
  -    // if not, advance the iterator until we the information has been 
  +    // Check to see if the information requested has been processed, and,
  +    // if not, advance the iterator until we the information has been
       // processed.
       while (true)
       {
  @@ -631,8 +631,8 @@
       if (identity < m_size)
         return m_parent.elementAt(identity);
   
  -    // Check to see if the information requested has been processed, and, 
  -    // if not, advance the iterator until we the information has been 
  +    // Check to see if the information requested has been processed, and,
  +    // if not, advance the iterator until we the information has been
       // processed.
       while (true)
       {
  @@ -655,13 +655,13 @@
         File f = new File("DTMDump"+((Object)this).hashCode()+".txt");
         System.err.println("Dumping... "+f.getAbsolutePath());
         PrintStream ps = new PrintStream(new FileOutputStream(f));
  -  
  +
         while (nextNode()){}
  -  
  +
         int nRecords = m_size;
  -  
  +
         ps.println("Total nodes: " + nRecords);
  -  
  +
         for (int i = 0; i < nRecords; i++)
         {
           ps.println("=========== " + i + " ===========");
  @@ -670,15 +670,15 @@
           ps.println("LocalName: " + getLocalName(i));
           ps.println("NamespaceURI: " + getNamespaceURI(i));
           ps.println("Prefix: " + getPrefix(i));
  -  
  +
           int exTypeID = getExpandedTypeID(i);
  -  
  +
           ps.println("Expanded Type ID: "
                              + Integer.toHexString(exTypeID));
  -  
  +
           int type = getNodeType(i);
           String typestring;
  -  
  +
           switch (type)
           {
           case DTM.ATTRIBUTE_NODE :
  @@ -727,47 +727,47 @@
             typestring = "Unknown!";
             break;
           }
  -  
  +
           ps.println("Type: " + typestring);
  -  
  +
           int firstChild = _firstch(i);
  -  
  +
           if (DTM.NULL == firstChild)
             ps.println("First child: DTM.NULL");
           else if (NOTPROCESSED == firstChild)
             ps.println("First child: NOTPROCESSED");
           else
             ps.println("First child: " + firstChild);
  -  
  +
           int prevSibling = _prevsib(i);
  -  
  +
           if (DTM.NULL == prevSibling)
             ps.println("Prev sibling: DTM.NULL");
           else if (NOTPROCESSED == prevSibling)
             ps.println("Prev sibling: NOTPROCESSED");
           else
             ps.println("Prev sibling: " + prevSibling);
  -  
  +
           int nextSibling = _nextsib(i);
  -  
  +
           if (DTM.NULL == nextSibling)
             ps.println("Next sibling: DTM.NULL");
           else if (NOTPROCESSED == nextSibling)
             ps.println("Next sibling: NOTPROCESSED");
           else
             ps.println("Next sibling: " + nextSibling);
  -  
  +
           int parent = _parent(i);
  -  
  +
           if (DTM.NULL == parent)
             ps.println("Parent: DTM.NULL");
           else if (NOTPROCESSED == parent)
             ps.println("Parent: NOTPROCESSED");
           else
             ps.println("Parent: " + parent);
  -  
  +
           int level = _level(i);
  -  
  +
           ps.println("Level: " + level);
           ps.println("Node Value: " + getNodeValue(i));
           ps.println("String Value: " + getStringValue(i));
  @@ -937,7 +937,7 @@
     }
   
     /**
  -   * Given a node handle, advance to the next attribute. 
  +   * Given a node handle, advance to the next attribute.
      * If an attr, we advance to
      * the next attr on the same node.  If not an attribute, we return NULL.
      *
  @@ -1021,7 +1021,7 @@
           m_namespaceDeclSetElements.addElement(elementNodeIndex);
           nsList=new SuballocatedIntVector();
           m_namespaceDeclSets.addElement(nsList);
  -                
  +
           SuballocatedIntVector inherited= 
findNamespaceContext(_parent(elementNodeIndex));
   
           if(inherited!=null)
  @@ -1053,7 +1053,7 @@
         }
       nsList.addElement(namespaceNodeIndex | m_dtmIdent);
     }
  -    
  +
     /** Retrieve list of namespace declaration locations
        * active at this node. List is an SuballocatedIntVector whose
        * entries are the namespace node HANDLES declared at that ID.
  @@ -1083,7 +1083,7 @@
           int ancestor=_parent(elementNodeIndex);
           while(wouldBeAt>=0 && ancestor>0)
             {
  -            candidate=m_namespaceDeclSetElements.elementAt(wouldBeAt); 
  +            candidate=m_namespaceDeclSetElements.elementAt(wouldBeAt);
   
               if(candidate==ancestor) // Found ancestor in list
                   return 
(SuballocatedIntVector)m_namespaceDeclSets.elementAt(wouldBeAt);
  @@ -1133,7 +1133,7 @@
             first = i + 1; // looked ot early
           }
         }
  -            
  +
         if (first > i) {
           i = first; // Clean up at loop end
         }
  @@ -1159,7 +1159,7 @@
     public int getFirstNamespaceNode(int nodeHandle, boolean inScope)
     {
           if(inScope)
  -        {      
  +        {
               SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & 
m_mask);
               if(nsContext==null || nsContext.size()<1)
                 return NULL;
  @@ -1529,7 +1529,7 @@
       return (short) (_level(identity) + 1);
     }
   
  -  // ============== Document query functions ============== 
  +  // ============== Document query functions ==============
   
     /**
      * Tests whether DTM DOM implementation implements a specific feature and
  @@ -1833,7 +1833,7 @@
      *
      * @param nodeHandle The node ID.
      * @param ch A non-null reference to a ContentHandler.
  -   * @param normalize true if the content should be normalized according to 
  +   * @param normalize true if the content should be normalized according to
      * the rules for the XPath
      * <a 
href="http://www.w3.org/TR/xpath#function-normalize-space";>normalize-space</a>
      * function.
  @@ -1963,4 +1963,23 @@
       if (null != m_shouldStripWhitespaceStack)
         m_shouldStripWhitespaceStack.setTop(shouldStrip);
     }
  +
  +  /**
  +   * A dummy routine to satisify the abstract interface. If the DTM
  +   * implememtation that extends the default base requires notification
  +   * of registration, they can override this method.
  +   */
  +   public void documentRegistration()
  +   {
  +   }
  +
  +  /**
  +   * A dummy routine to satisify the abstract interface. If the DTM
  +   * implememtation that extends the default base requires notification
  +   * when the document is being released, they can override this method
  +   */
  +   public void documentRelease()
  +   {
  +   }
  +
   }
  
  
  
  1.6       +121 -100  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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DTMDocumentImpl.java      2001/08/10 17:57:37     1.5
  +++ DTMDocumentImpl.java      2001/08/24 04:49:31     1.6
  @@ -92,7 +92,7 @@
    * <p>State: In progress!!</p>
    *
    * %REVIEW% I _think_ the SAX convention is that "no namespace" is expressed
  - * as "" rather than as null (which is the DOM's convention). What should 
  + * as "" rather than as null (which is the DOM's convention). What should
    * DTM expect? What should it do with the other?
    *
    * <p>Origin: the implemention is a composite logic based on the DTM of XalanJ1 and
  @@ -106,7 +106,7 @@
           protected static final byte DOCHANDLE_SHIFT = 22;
           // Masks the lower order of node handle.
           // Same as {@link DTMConstructor.IDENT_NODE_DEFAULT}
  -        protected static final int NODEHANDLE_MASK = (1 << (DOCHANDLE_SHIFT + 1)) - 
1; 
  +        protected static final int NODEHANDLE_MASK = (1 << (DOCHANDLE_SHIFT + 1)) - 
1;
           // Masks the higher order Document handle
           // Same as {@link DTMConstructor.IDENT_DOC_DEFAULT}
           protected static final int DOCHANDLE_MASK = -1 - NODEHANDLE_MASK;
  @@ -132,7 +132,7 @@
           boolean m_isError = false;
   
           private final boolean DEBUG = false;
  -        
  +
           /** The document base URI. */
           protected String m_documentBaseURI;
   
  @@ -144,7 +144,7 @@
      * exception. We could try to wait-and-retry instead, as a very poor
      * fallback, but that has all the known problems with multithreading
      * on multiprocessors and we Don't Want to Go There.
  -   * 
  +   *
      * @see setIncrementalSAXSource
      */
     private IncrementalSAXSource m_incrSAXSource=null;
  @@ -182,9 +182,9 @@
           // an interface _implemented_ by this class... which might be simplest!
           private ExpandedNameTable m_expandedNames=
                   new ExpandedNameTable(m_localNames,m_nsNames);
  -                
  +
           private XMLStringFactory m_xsf;
  -  
  +
   
           /**
            * Construct a DTM.
  @@ -196,7 +196,7 @@
            * DTMManager's responsibility to assign a unique number to each
            * document.
            */
  -        public DTMDocumentImpl(DTMManager mgr, int documentNumber, 
  +        public DTMDocumentImpl(DTMManager mgr, int documentNumber,
                                  DTMWSFilter whiteSpaceFilter,
                                  XMLStringFactory xstringfactory){
                   initDocument(documentNumber);         // clear nodes and document 
handle
  @@ -228,7 +228,7 @@
       //source.setDTDHandler(this);
       //source.setDeclHandler(this);
     }
  -  
  +
           /**
            * Wrapper for ChunkedIntArray.append, to automatically update the
            * previous sibling's "next" reference (if necessary) and periodically
  @@ -337,7 +337,7 @@
            void setContentBuffer(FastStringBuffer buffer) {
                    m_char = buffer;
            }
  - 
  +
            /**
             * Get a reference pointer to the content-text repository
             *
  @@ -363,7 +363,7 @@
       else
         return this;
     }
  -  
  +
     /**
      * Return this DTM's lexical handler.
      *
  @@ -382,7 +382,7 @@
       else
         return this;
     }
  -  
  +
     /**
      * Return this DTM's EntityResolver.
      *
  @@ -393,7 +393,7 @@
   
       return null;
     }
  -  
  +
     /**
      * Return this DTM's DTDHandler.
      *
  @@ -415,7 +415,7 @@
   
       return null;
     }
  -  
  +
     /**
      * Return this DTM's DeclHandler.
      *
  @@ -425,8 +425,8 @@
     {
   
       return null;
  -  }  
  -  
  +  }
  +
     /** @return true iff we're building this model incrementally (eg
      * we're partnered with a IncrementalSAXSource) and thus require that the
      * transformation and the parse run simultaneously. Guidance to the
  @@ -462,7 +462,7 @@
           m_char_current_start=len;
         }
     }
  -  public void endDocument() 
  +  public void endDocument()
          throws org.xml.sax.SAXException
     {
       // May need to tell the low-level builder code to pop up a level.
  @@ -470,7 +470,7 @@
       appendEndDocument();
     }
     public void endElement(java.lang.String namespaceURI, java.lang.String localName,
  -      java.lang.String qName) 
  +      java.lang.String qName)
          throws org.xml.sax.SAXException
     {
       processAccumulatedText();
  @@ -478,39 +478,39 @@
       // pop up a level.
       appendEndElement();
     }
  -  public void endPrefixMapping(java.lang.String prefix) 
  +  public void endPrefixMapping(java.lang.String prefix)
          throws org.xml.sax.SAXException
     {
       // No-op
     }
  -  public void ignorableWhitespace(char[] ch, int start, int length) 
  +  public void ignorableWhitespace(char[] ch, int start, int length)
          throws org.xml.sax.SAXException
     {
       // %TBD% I believe ignorable text isn't part of the DTM model...?
     }
  -  public void processingInstruction(java.lang.String target, java.lang.String data) 
  +  public void processingInstruction(java.lang.String target, java.lang.String data)
          throws org.xml.sax.SAXException
     {
       processAccumulatedText();
       // %TBD% Which pools do target and data go into?
     }
  -  public void setDocumentLocator(Locator locator) 
  +  public void setDocumentLocator(Locator locator)
     {
       // No-op for DTM
     }
  -  public void skippedEntity(java.lang.String name) 
  +  public void skippedEntity(java.lang.String name)
          throws org.xml.sax.SAXException
     {
       processAccumulatedText();
       //%TBD%
     }
  -  public void startDocument() 
  +  public void startDocument()
          throws org.xml.sax.SAXException
     {
       appendStartDocument();
     }
     public void startElement(java.lang.String namespaceURI, java.lang.String 
localName,
  -      java.lang.String qName, Attributes atts) 
  +      java.lang.String qName, Attributes atts)
          throws org.xml.sax.SAXException
     {
       processAccumulatedText();
  @@ -532,7 +532,7 @@
       // %TBD% Is there an easier way to test for NSDecl?
       int nAtts=(atts==null) ? 0 : atts.getLength();
       // %TBD% Countdown is more efficient if nobody cares about sequence.
  -    for(int i=nAtts-1;i>=0;--i)      
  +    for(int i=nAtts-1;i>=0;--i)
         {
           qName=atts.getQName(i);
           if(qName.startsWith("xmlns:") || "xmlns".equals(qName))
  @@ -548,7 +548,7 @@
                   // %REVEIW% Null or ""?
                   prefix=null; // Default prefix
                 }
  -            
  +
   
               appendNSDeclaration(
                                       m_prefixNames.stringToIndex(prefix),
  @@ -556,8 +556,8 @@
                                       atts.getType(i).equalsIgnoreCase("ID"));
             }
         }
  -    
  -    for(int i=nAtts-1;i>=0;--i)      
  +
  +    for(int i=nAtts-1;i>=0;--i)
         {
           qName=atts.getQName(i);
           if(!(qName.startsWith("xmlns:") || "xmlns".equals(qName)))
  @@ -577,11 +577,11 @@
                   prefix=""; // Default prefix
                   localName=qName;
                 }
  -            
  -            
  +
  +
               m_char.append(atts.getValue(i)); // Single-string value
               int contentEnd=m_char.length();
  -            
  +
               if(!("xmlns".equals(prefix) || "xmlns".equals(qName)))
                 appendAttribute(m_nsNames.stringToIndex(atts.getURI(i)),
                                     m_localNames.stringToIndex(localName),
  @@ -592,7 +592,7 @@
             }
         }
     }
  -  public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) 
  +  public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          throws org.xml.sax.SAXException
     {
       // No-op in DTM, handled during element/attr processing?
  @@ -602,42 +602,42 @@
     // LexicalHandler support. Not all SAX2 parsers support these events
     // but we may want to pass them through when they exist...
     //
  -  public void comment(char[] ch, int start, int length) 
  +  public void comment(char[] ch, int start, int length)
          throws org.xml.sax.SAXException
     {
       processAccumulatedText();
   
       m_char.append(ch,start,length); // Single-string value
       appendComment(m_char_current_start,length);
  -    m_char_current_start+=length;    
  +    m_char_current_start+=length;
     }
  -  public void endCDATA() 
  +  public void endCDATA()
          throws org.xml.sax.SAXException
     {
       // No-op in DTM
     }
  -  public void endDTD() 
  +  public void endDTD()
          throws org.xml.sax.SAXException
     {
       // No-op in DTM
     }
  -  public void endEntity(java.lang.String name) 
  +  public void endEntity(java.lang.String name)
          throws org.xml.sax.SAXException
     {
       // No-op in DTM
     }
  -  public void startCDATA() 
  +  public void startCDATA()
          throws org.xml.sax.SAXException
     {
       // No-op in DTM
     }
     public void startDTD(java.lang.String name, java.lang.String publicId,
  -      java.lang.String systemId) 
  +      java.lang.String systemId)
          throws org.xml.sax.SAXException
     {
       // No-op in DTM
     }
  -  public void startEntity(java.lang.String name) 
  +  public void startEntity(java.lang.String name)
          throws org.xml.sax.SAXException
     {
       // No-op in DTM
  @@ -831,14 +831,14 @@
   //    * @param name The element name
   //    */
   //   public void endElement(String ns, String name)
  -//   { 
  +//   {
   //           // pop up the stacks
   
  -//           // 
  +//           //
   //           if (previousSiblingWasParent)
   //                   nodes.writeEntry(previousSibling, 2, NULL);
   
  -//           // Pop parentage 
  +//           // Pop parentage
   //           previousSibling = currentParent;
   //           nodes.readSlot(currentParent, gotslot);
   //           currentParent = gotslot[1] & 0xFFFF;
  @@ -877,10 +877,10 @@
   //           if (colonpos > 0) {
   //                   String prefix = qname.substring(0, colonpos);
   //                   if (prefix.equals("xml")) {
  -//                           //w0 = ATTRIBUTE_NODE | 
  +//                           //w0 = ATTRIBUTE_NODE |
   //                           //      
(org.apache.xalan.templates.Constants.S_XMLNAMESPACEURI << 16);
   //                   } else {
  -//                           //w0 = ATTRIBUTE_NODE | 
  +//                           //w0 = ATTRIBUTE_NODE |
   //                   }
   //           } else {
   //                   w0 = ATTRIBUTE_NODE;
  @@ -924,7 +924,7 @@
   //    */
   //   public int createTextNode(String text)
   //   throws DTMException
  -//   { 
  +//   {
   //           // wraps around the index value based createTextNode method
   //           return createTextNode(text.toCharArray(), 0, text.length());
   //   }
  @@ -1047,7 +1047,7 @@
            * @return int DTM node-number of first child, or DTM.NULL to indicate none 
exists.
            */
           public int getFirstChild(int nodeHandle) {
  -                
  +
                   // ###shs worry about tracing/debug later
                   nodeHandle &= NODEHANDLE_MASK;
                   // Read node into variable
  @@ -1057,7 +1057,7 @@
                   short type = (short) (gotslot[0] & 0xFFFF);
   
                   // Check to see if Element or Document node
  -                if ((type == ELEMENT_NODE) || (type == DOCUMENT_NODE) || 
  +                if ((type == ELEMENT_NODE) || (type == DOCUMENT_NODE) ||
                                   (type == ENTITY_REFERENCE_NODE)) {
   
                           // In case when Document root is given
  @@ -1073,19 +1073,19 @@
                                   // points to next sibling
                                   kid = gotslot[2];
                                   // Return NULL if node has only attributes
  -                                if (kid == NULL) return NULL; 
  +                                if (kid == NULL) return NULL;
                                   nodes.readSlot(kid, gotslot);
                           }
                           // If parent slot matches given parent, return kid
  -                        if (gotslot[1] == nodeHandle)        
  +                        if (gotslot[1] == nodeHandle)
                           {
                             int firstChild = kid | m_docHandle;
  -                          
  +
                             return firstChild;
                           }
                   }
                   // No child found
  -                
  +
                   return NULL;
           }
   
  @@ -1107,7 +1107,7 @@
                                   nextkid = getNextSibling(nextkid)) {
                           lastChild = nextkid;
                   }
  -                return lastChild | m_docHandle;              
  +                return lastChild | m_docHandle;
           }
   
           /**
  @@ -1161,7 +1161,7 @@
                           return NULL;
                   // First Attribute (if any) should be at next position in table
                   nodeHandle++;
  -                return(ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF)) 
? 
  +                return(ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF)) 
?
                   nodeHandle | m_docHandle : NULL;
           }
   
  @@ -1218,7 +1218,7 @@
                   }
                   // Next Sibling is in the next position if it shares the same parent
                   int thisParent = nodes.readEntry(nodeHandle, 1);
  -                
  +
                   if (nodes.readEntry(++nodeHandle, 1) == thisParent)
                           return (m_docHandle | nodeHandle);
   
  @@ -1442,26 +1442,26 @@
            * @return A string object that represents the string-value of the given 
node.
            */
           public XMLString getStringValue(int nodeHandle) {
  -        // ###zaj - researching 
  +        // ###zaj - researching
           nodes.readSlot(nodeHandle, gotslot);
  -        int nodetype=gotslot[0] & 0xFF;              
  +        int nodetype=gotslot[0] & 0xFF;
           String value=null;
   
  -        switch (nodetype) {                  
  -        case TEXT_NODE:   
  +        switch (nodetype) {
  +        case TEXT_NODE:
           case COMMENT_NODE:
  -        case CDATA_SECTION_NODE: 
  -                value= m_char.getString(gotslot[2], gotslot[3]);             
  +        case CDATA_SECTION_NODE:
  +                value= m_char.getString(gotslot[2], gotslot[3]);
                   break;
           case PROCESSING_INSTRUCTION_NODE:
  -        case ATTRIBUTE_NODE: 
  +        case ATTRIBUTE_NODE:
           case ELEMENT_NODE:
           case ENTITY_REFERENCE_NODE:
           default:
                   break;
           }
  -        return m_xsf.newstr( value ); 
  -               
  +        return m_xsf.newstr( value );
  +
           }
   
           /**
  @@ -1490,7 +1490,7 @@
           //###zaj - tbd
           public int getStringValueChunkCount(int nodeHandle)
           {
  -                //###zaj    return value 
  +                //###zaj    return value
                   return 0;
           }
   
  @@ -1518,7 +1518,7 @@
            *                    the chunk will be returned.
            *
            * @return The character array reference where the chunk occurs.  */
  -        //###zaj - tbd 
  +        //###zaj - tbd
           public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
                                                                                       
                                                            int[] startAndLen) {return 
new char[0];}
   
  @@ -1531,13 +1531,13 @@
            */
           public int getExpandedTypeID(int nodeHandle) {
              nodes.readSlot(nodeHandle, gotslot);
  -           String qName = m_localNames.indexToString(gotslot[3]); 
  +           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
  -           String namespace = m_nsNames.indexToString(gotslot[0] << 16); 
  +           String namespace = m_nsNames.indexToString(gotslot[0] << 16);
              // Create expanded name
              String expandedName = namespace + ":" + localName;
              int expandedNameID = m_nsNames.stringToIndex(expandedName);
  @@ -1578,7 +1578,7 @@
           public String getLocalNameFromExpandedNameID(int ExpandedNameID) {
   
              // Get expanded name
  -           String expandedName = m_localNames.indexToString(ExpandedNameID); 
  +           String expandedName = m_localNames.indexToString(ExpandedNameID);
              // Remove prefix from expanded name
              int colonpos = expandedName.indexOf(":");
              String localName = expandedName.substring(colonpos+1);
  @@ -1595,7 +1595,7 @@
           */
           public String getNamespaceFromExpandedNameID(int ExpandedNameID) {
   
  -           String expandedName = m_localNames.indexToString(ExpandedNameID); 
  +           String expandedName = m_localNames.indexToString(ExpandedNameID);
              // Remove local name from expanded name
              int colonpos = expandedName.indexOf(":");
              String nsName = expandedName.substring(0, colonpos);
  @@ -1605,8 +1605,8 @@
   
   
           /**
  -         * fixednames 
  -        */ 
  +         * fixednames
  +        */
           static final String[] fixednames=
           {
                   null,null,                                                   // 
nothing, Element
  @@ -1632,7 +1632,7 @@
                   if (null == name) {
                     int i=gotslot[3];
                     /**/System.out.println("got i="+i+" "+(i>>16)+"/"+(i&0xffff));
  -                  
  +
                     name=m_localNames.indexToString(i & 0xFFFF);
                     String prefix=m_prefixNames.indexToString(i >>16);
                     if(prefix!=null && prefix.length()>0)
  @@ -1729,9 +1729,9 @@
                   switch (nodetype) {                  // ###zaj todo - document 
nodetypes
                   case ATTRIBUTE_NODE:
                           nodes.readSlot(nodeHandle+1, gotslot);
  -                case TEXT_NODE:   
  +                case TEXT_NODE:
                   case COMMENT_NODE:
  -                case CDATA_SECTION_NODE: 
  +                case CDATA_SECTION_NODE:
                           value=m_char.getString(gotslot[2], gotslot[3]);             
 //###zaj
                           break;
                   case PROCESSING_INSTRUCTION_NODE:
  @@ -1740,7 +1740,7 @@
                   default:
                           break;
                   }
  -                return value; 
  +                return value;
           }
   
           /**
  @@ -1797,10 +1797,10 @@
            */
           public String getDocumentBaseURI()
           {
  -      
  +
             return m_documentBaseURI;
           }
  -        
  +
           /**
            * Set the base URI of the document entity.
            *
  @@ -1808,10 +1808,10 @@
            */
           public void setDocumentBaseURI(String baseURI)
           {
  -      
  +
             m_documentBaseURI = baseURI;
           }
  -        
  +
           /**
            * Return the system identifier of the document entity. If
            * it is not known, the value of this property is unknown.
  @@ -2052,7 +2052,7 @@
   
           public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
           throws org.xml.sax.SAXException {}
  -        
  +
           /**
            * Return an DOM node for the given node.
            *
  @@ -2133,7 +2133,7 @@
       int ourslot = appendNode(w0, w1, w2, w3);
       previousSibling = ourslot;
     }
  -  
  +
     /** Append a comment child at the current insertion point. Assumes that the
      * actual content of the comment has previously been appended to the m_char
      * buffer (shared with the builder).
  @@ -2156,12 +2156,12 @@
       int ourslot = appendNode(w0, w1, w2, w3);
       previousSibling = ourslot;
     }
  -  
  -  
  +
  +
     /** Append an Element child at the current insertion point. This
      * Element then _becomes_ the insertion point; subsequent appends
      * become its lastChild until an appendEndElement() call is made.
  -   * 
  +   *
      * Assumes that the symbols (local name, namespace URI and prefix)
      * have already been added to the pools
      *
  @@ -2199,7 +2199,7 @@
                   if (m_docElement == NULL)
                           m_docElement = ourslot;
     }
  -  
  +
     /** Append a Namespace Declaration child at the current insertion point.
      * Assumes that the symbols (namespace URI and prefix) have already been
      * added to the pools
  @@ -2276,7 +2276,7 @@
       // Add node
       int ourslot = appendNode(w0, w1, w2, w3);
       previousSibling = ourslot;       // Should attributes be previous siblings
  -    
  +
       // Attribute's content is currently appended as a Text Node
   
       // W0: Node Type
  @@ -2293,9 +2293,9 @@
       previousSiblingWasParent = true;
       return ;//(m_docHandle | ourslot);
     }
  -  
  +
     /**
  -   * This returns a stateless "traverser", that can navigate over an 
  +   * This returns a stateless "traverser", that can navigate over an
      * XPath axis, though not in document order.
      *
      * @param axis One of Axes.ANCESTORORSELF, etc.
  @@ -2306,7 +2306,7 @@
     {
       return null;
     }
  -  
  +
     /**
      * This is a shortcut to the iterators that implement the
      * supported XPath axes (only namespace::) is not supported.
  @@ -2324,11 +2324,11 @@
     }
   
     /**
  -   * Get an iterator that can navigate over an XPath Axis, predicated by 
  +   * Get an iterator that can navigate over an XPath Axis, predicated by
      * the extended type ID.
      *
      *
  -   * @param axis 
  +   * @param axis
      * @param type An extended type ID.
      *
      * @return A DTMAxisIterator, or null if the given axis isn't supported.
  @@ -2346,29 +2346,29 @@
     void appendEndElement()
     {
       // pop up the stacks
  -    
  +
       if (previousSiblingWasParent)
         nodes.writeEntry(previousSibling, 2, NULL);
  -    
  -    // Pop parentage 
  +
  +    // Pop parentage
       previousSibling = currentParent;
       nodes.readSlot(currentParent, gotslot);
       currentParent = gotslot[1] & 0xFFFF;
  -    
  +
       // The element just being finished will be
       // the previous sibling for the next operation
       previousSiblingWasParent = true;
  -    
  +
       // Pop a level of namespace table
       // namespaceTable.removeLastElem();
     }
  -  
  +
     /**  Starting a new document. Perform any resets/initialization
      * not already handled.
      * */
     void appendStartDocument()
     {
  -    
  +
       // %TBD% reset slot 0 to indicate ChunkedIntArray reuse or wait for
       //       the next initDocument().
       m_docElement = NULL;      // reset nodeHandle to the root of the actual dtm doc 
content
  @@ -2395,7 +2395,7 @@
     public void setProperty(String property, Object value)
     {
     }
  -  
  +
     /**
      * Source information is not handled yet, so return
      * <code>null</code> here.
  @@ -2407,4 +2407,25 @@
     {
       return null;
     }
  +
  +
  +  /**
  +   * A dummy routine to satisify the abstract interface. If the DTM
  +   * implememtation that extends the default base requires notification
  +   * of registration, they can override this method.
  +   */
  +   public void documentRegistration()
  +   {
  +   }
  +
  +  /**
  +   * A dummy routine to satisify the abstract interface. If the DTM
  +   * implememtation that extends the default base requires notification
  +   * when the document is being released, they can override this method
  +   */
  +   public void documentRelease()
  +   {
  +   }
  +
  +
   }
  
  
  
  1.21      +33 -31    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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DTMManagerDefault.java    2001/08/12 18:06:58     1.20
  +++ DTMManagerDefault.java    2001/08/24 04:49:31     1.21
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Xalan" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -102,28 +102,29 @@
   public class DTMManagerDefault extends DTMManager
   {
   
  -  /** 
  -   * Vector of DTMs that this manager manages. 
  +  /**
  +   * Vector of DTMs that this manager manages.
      */
     protected DTM m_dtms[] = new DTM[IDENT_MAX_DTMS];
  -    
  +
     /**
      * Add a DTM to the DTM table.
  -   * 
  +   *
      * @param dtm Should be a valid reference to a DTM.
      */
     public void addDTM(DTM dtm, int id)
     {
       m_dtms[id] = dtm;
  +    dtm.documentRegistration();
     }
  -  
  +
     /**
      * Get the first free DTM ID available.
      */
     public int getFirstFreeDTMID()
     {
       int n = m_dtms.length;
  -    for (int i = 1; i < n; i++) 
  +    for (int i = 1; i < n; i++)
       {
         if(null == m_dtms[i])
         {
  @@ -132,7 +133,7 @@
       }
       throw new 
DTMException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_DTMIDS_AVAIL, null)); 
//"No more DTM IDs are available!");
     }
  -  
  +
     /**
      * The default table for exandedNameID lookups.
      */
  @@ -147,7 +148,7 @@
   
     /** 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. */
     private static final boolean DEBUG = false;
   
  @@ -167,13 +168,13 @@
      *                         be null.
      * @param incremental true if the DTM should be built incrementally, if
      *                    possible.
  -   * @param doIndexing true if the caller considers it worth it to use 
  +   * @param doIndexing true if the caller considers it worth it to use
      *                   indexing schemes.
      *
      * @return a non-null DTM reference.
      */
     public DTM getDTM(Source source, boolean unique,
  -                    DTMWSFilter whiteSpaceFilter, boolean incremental, 
  +                    DTMWSFilter whiteSpaceFilter, boolean incremental,
                       boolean doIndexing)
     {
   
  @@ -242,7 +243,7 @@
           SAX2DTM dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
                                     xstringFactory, doIndexing);
   
  -        // Go ahead and add the DTM to the lookup table.  This needs to be 
  +        // Go ahead and add the DTM to the lookup table.  This needs to be
           // done before any parsing occurs.
           addDTM(dtm, dtmPos);
   
  @@ -253,7 +254,7 @@
           if (haveXercesParser)
             incremental = true;  // No matter what.  %REVIEW%
   
  -        // If the reader is null, but they still requested an incremental build, 
  +        // 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) */)
           {
  @@ -283,7 +284,7 @@
              filter.setXMLReader(reader);
              coParser=filter;
            }
  -         
  +
             }
   
             // Have the DTM set itself up as the IncrementalSAXSource's listener.
  @@ -374,7 +375,7 @@
         else
         {
   
  -        // It should have been handled by a derived class or the caller 
  +        // 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);
         }
  @@ -404,7 +405,7 @@
         //
         // NOTE that since a DOM2DTM may represent a subtree rather
         // than a full document, we have to be prepared to check more
  -      // than one -- and there is no guarantee that we will find 
  +      // than one -- and there is no guarantee that we will find
         // one that contains ancestors or siblings of the node we're
         // seeking.
         //
  @@ -424,24 +425,24 @@
               if(handle!=DTM.NULL) return handle;
             }
            }
  -      
  -      // Since the real root of our tree may be a DocumentFragment, we need to 
  -      // use getParent to find the root, instead of getOwnerDocument.  Otherwise 
  +
  +      // Since the real root of our tree may be a DocumentFragment, we need to
  +      // use getParent to find the root, instead of getOwnerDocument.  Otherwise
         // DOM2DTM#getHandleOfNode will be very unhappy.
         Node root = node;
  -      for (Node p = root.getParentNode(); p != null; p = p.getParentNode()) 
  +      for (Node p = root.getParentNode(); p != null; p = p.getParentNode())
         {
           root = p;
         }
  -        
  +
         DTM dtm = getDTM(new javax.xml.transform.dom.DOMSource(root), false,
                          null, true, true);
   
         int handle = ((DOM2DTM)dtm).getHandleOfNode(node);
  -      
  +
         if(DTM.NULL == handle)
           throw new 
RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_COULD_NOT_RESOLVE_NODE,
 null)); //"Could not resolve the node to a handle!");
  -      
  +
         return handle;
       }
     }
  @@ -466,7 +467,7 @@
       {
         XMLReader reader = (inputSource instanceof SAXSource)
                            ? ((SAXSource) inputSource).getXMLReader() : null;
  -                         
  +
         boolean isUserReader = (reader != null);
   
         if (null == reader)
  @@ -509,7 +510,7 @@
           // TODO: User diagnostics.
         }
   
  -        // Commented out as per discussion with [EMAIL PROTECTED] 
  +        // Commented out as per discussion with [EMAIL PROTECTED]
           // about bug 2124.
   //      if(!isUserReader)
   //      {
  @@ -520,7 +521,7 @@
   //        }
   //        catch (org.xml.sax.SAXException se)
   //        {
  -//  
  +//
   //          // What can we do?
   //          // TODO: User diagnostics.
   //        }
  @@ -564,7 +565,7 @@
       // [But we can't do it... sorry.  -sb]
       int n = m_dtms.length;
   
  -    for (int i = 0; i < n; i++) 
  +    for (int i = 0; i < n; i++)
       {
         DTM tdtm = m_dtms[i];
   
  @@ -599,6 +600,7 @@
         m_dtms[i] = null;
       }
   
  +    dtm.documentRelease();
       return true;
     }
   
  @@ -694,7 +696,7 @@
       /** @todo: implement this org.apache.xml.dtm.DTMManager abstract method */
       return null;
     }
  -  
  +
     /**
      * return the expanded name table.
      *
  
  
  

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

Reply via email to