sboag       01/05/15 09:08:44

  Modified:    java/src/org/apache/xml/dtm Tag: DTM_EXP
                        CoroutineSAXParser.java DTMManagerDefault.java
               java/src/org/apache/xml/dtm/sax2dtm Tag: DTM_EXP
                        SAX2DTM.java
  Log:
  > Inactive means no parse in progress. Boolean.TRUE is the parameter meaning 
we want more nodes. So the question is why we're telling the parser to send us 
more when the CoroutineParser thinks it has already sent us everything it 
has... or the parser thinks that it never got a request to begin parsing in the 
first place.
  
  Here's what's going on.  The DTMManagerDefault calls 
coParser.doParse(xmlSource, appCoroutine);.  The document is very short 
(<doc>hello</doc>), so the parse is done immediately.  Then, SAX2DTM gets into 
nextNode() (where I moved the CoRoutine stuff), and doesn't know that the parse 
has completed, and so na�vely calls m_coroutineParser.doMore(true, 
m_appCoroutineID);.
  
  I can make it work by setting a flag in the endDocument event of SAX2DTM, and 
then catching this in nextNode() and calling the CoRoutine parser to 
doTerminate and nulling out the reference (I can't do this in the endDocument 
event because it's on the same thread and calling doTerminate hangs things).
  
  An alternative would be to check the return of doParse and then, if not true, 
call setCoroutineParser(null) on the SAX2DTM?
  
  > Re the other glitch: I have no clue why the Xerces parser would throw an 
out-of-bounds exception in response to  the parse() method being called, which 
appears to be what's going on in line 506. Are you sure the InputSource you're 
passing in is properly constructed?
  
  This was a nested exception, as I thought, thrown from SAX2DTM.  Dumb bug 
that I introduced when mucking with the character handling, as I suspected.
  
  We still get some failures and then leftover threads for some idkey test 
cases.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.9   +19 -2     
xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineSAXParser.java
  
  Index: CoroutineSAXParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/CoroutineSAXParser.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- CoroutineSAXParser.java   2001/05/15 06:31:42     1.1.2.8
  +++ CoroutineSAXParser.java   2001/05/15 16:08:26     1.1.2.9
  @@ -603,8 +603,25 @@
           // should never arise during normal operation.
           // Should this rethrow the parse exception?
           if (result instanceof Exception) {
  -          System.out.println("\nParser threw exception:");
  -          ((Exception)result).printStackTrace();
  +          if(result instanceof SAXException)
  +          {
  +            SAXException se = (SAXException)result;
  +            Exception e = se.getException();
  +            if(null != e)
  +            {
  +              e.printStackTrace();
  +            }
  +            else
  +            {
  +              System.out.println("\nParser threw exception:");
  +              se.printStackTrace();
  +            }
  +          }
  +          else
  +          {
  +            System.out.println("\nParser threw exception:");
  +            ((Exception)result).printStackTrace();
  +          }
           }
   
           return result;
  
  
  
  1.1.2.8   +10 -3     
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMManagerDefault.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- DTMManagerDefault.java    2001/05/15 06:31:42     1.1.2.7
  +++ DTMManagerDefault.java    2001/05/15 16:08:27     1.1.2.8
  @@ -216,16 +216,23 @@
           try
           {
             // This is a strange way to start the parse.
  -          coParser.doParse(xmlSource, appCoroutine);
  +          Object gotMore = coParser.doParse(xmlSource, appCoroutine);
  +          if (gotMore != Boolean.TRUE)
  +          {
  +      
  +            dtm.clearCoRoutine();
  +          }
           }
           catch(RuntimeException re)
           {
  -          coroutineManager.co_exit(appCoroutine);
  +          // coroutineManager.co_exit(appCoroutine);
  +          dtm.clearCoRoutine();
             throw re;
           }
           catch(Exception e)
           {
  -          coroutineManager.co_exit(appCoroutine);
  +          // coroutineManager.co_exit(appCoroutine);
  +          dtm.clearCoRoutine();
             throw new org.apache.xml.utils.WrappedRuntimeException(e);
           }
           finally
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.8   +28 -6     
xml-xalan/java/src/org/apache/xml/dtm/sax2dtm/Attic/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/sax2dtm/Attic/SAX2DTM.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- SAX2DTM.java      2001/05/15 06:31:44     1.1.2.7
  +++ SAX2DTM.java      2001/05/15 16:08:38     1.1.2.8
  @@ -157,6 +157,9 @@
   
     /** pool of string values that come as strings. */
     private DTMStringPool m_valuesOrPrefixes = new DTMStringPool();
  +  
  +  /** End document has been reached. */
  +  private boolean m_endDocumentOccured = false;
   
     /**
      * This represents the number of integers per node in the
  @@ -260,6 +263,18 @@
     {
       return m_appCoroutineID;
     }
  +  
  +  /**
  +   * Ask the CoRoutine parser to doTerminate and clear the reference.
  +   */
  +  public void clearCoRoutine()
  +  {
  +    if(null != m_coroutineParser)
  +    {
  +      m_coroutineParser.doTerminate(m_appCoroutineID);
  +      m_coroutineParser = null;
  +    }
  +  }
   
     /**
      * Bind a CoroutineParser to this DTM. If we discover we need nodes
  @@ -626,9 +641,16 @@
   
       if (null == m_coroutineParser)
         return false;
  +    
  +    if(m_endDocumentOccured)
  +    {
  +      clearCoRoutine();
   
  -    Object gotMore = m_coroutineParser.doMore(true, m_appCoroutineID);
  +      return false;
  +    }
   
  +    Object gotMore = m_coroutineParser.doMore(true, m_appCoroutineID);
  +   
       // gotMore may be a Boolean (TRUE if still parsing, FALSE if
       // EOF) or an exception if CoroutineParser malfunctioned
       // (code error rather than user error).
  @@ -640,8 +662,7 @@
       {
   
         // for now...
  -      m_coroutineParser.doTerminate(m_appCoroutineID);
  -      m_coroutineParser = null;
  +      clearCoRoutine();
   
         return false;
   
  @@ -652,8 +673,7 @@
       {
   
         // EOF reached without satisfying the request
  -      m_coroutineParser.doTerminate(m_appCoroutineID);
  -      m_coroutineParser = null;  // Drop connection, stop trying
  +      clearCoRoutine();  // Drop connection, stop trying
   
         // %TBD% deregister as its listener?
       }
  @@ -1414,6 +1434,8 @@
   
       m_level--;
       
  +    m_endDocumentOccured = true;
  +    
     }
   
     /**
  @@ -1719,7 +1741,7 @@
   
       if (m_textPending)
       {
  -      int lastNodeIdentity = m_previous;
  +      int lastNodeIdentity = m_size;
   
         dataIndex = getNodeInfoNoWait(lastNodeIdentity, OFFSET_DATA_OR_QNAME)
                     + 1;
  
  
  

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

Reply via email to