Changeset 7488


Ignore:
Timestamp:
11/24/06 14:19:51 (5 years ago)
Author:
sys
Message:

bug bloquant xsl:attribute dans certaines conditions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Res_Xalan/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java

    r7031 r7488  
    2121import java.util.Hashtable; 
    2222import java.util.Vector; 
     23 
    2324import javax.xml.transform.Source; 
    2425import javax.xml.transform.SourceLocator; 
    2526 
    26 import org.apache.xml.dtm.*; 
    27 import org.apache.xml.dtm.ref.*; 
    28 import org.apache.xml.utils.StringVector; 
    29 import org.apache.xml.utils.IntVector; 
     27import org.apache.xml.dtm.DTM; 
     28import org.apache.xml.dtm.DTMManager; 
     29import org.apache.xml.dtm.DTMWSFilter; 
     30import org.apache.xml.dtm.ref.DTMDefaultBaseIterators; 
     31import org.apache.xml.dtm.ref.DTMManagerDefault; 
     32import org.apache.xml.dtm.ref.DTMStringPool; 
     33import org.apache.xml.dtm.ref.DTMTreeWalker; 
     34import org.apache.xml.dtm.ref.NodeLocator; 
     35import org.apache.xml.res.XMLErrorResources; 
     36import org.apache.xml.res.XMLMessages; 
    3037import org.apache.xml.utils.FastStringBuffer; 
    3138import org.apache.xml.utils.IntStack; 
     39import org.apache.xml.utils.IntVector; 
     40import org.apache.xml.utils.StringVector; 
    3241import org.apache.xml.utils.SuballocatedIntVector; 
    3342import org.apache.xml.utils.SystemIDResolver; 
    34 import org.apache.xml.utils.WrappedRuntimeException; 
    3543import org.apache.xml.utils.XMLString; 
    3644import org.apache.xml.utils.XMLStringFactory; 
    37 import org.apache.xml.res.XMLErrorResources; 
    38 import org.apache.xml.res.XMLMessages; 
    39 import org.xml.sax.*; 
    40 import org.xml.sax.ext.*; 
     45import org.xml.sax.Attributes; 
     46import org.xml.sax.ContentHandler; 
     47import org.xml.sax.DTDHandler; 
     48import org.xml.sax.EntityResolver; 
     49import org.xml.sax.ErrorHandler; 
     50import org.xml.sax.InputSource; 
     51import org.xml.sax.Locator; 
     52import org.xml.sax.SAXException; 
     53import org.xml.sax.SAXParseException; 
     54import org.xml.sax.ext.DeclHandler; 
     55import org.xml.sax.ext.LexicalHandler; 
    4156 
    4257/** 
     
    5065  /** Set true to monitor SAX events and similar diagnostic info. */ 
    5166  private static final boolean DEBUG = false; 
    52  
    53   /** 
    54    * If we're building the model incrementally on demand, we need to 
    55    * be able to tell the source when to send us more data. 
    56    * 
    57    * Note that if this has not been set, and you attempt to read ahead 
    58    * of the current build point, we'll probably throw a null-pointer 
    59    * exception. We could try to wait-and-retry instead, as a very poor 
    60    * fallback, but that has all the known problems with multithreading 
    61    * on multiprocessors and we Don't Want to Go There. 
    62    * 
    63    * @see setIncrementalSAXSource 
    64    */ 
    65   private IncrementalSAXSource m_incrementalSAXSource = null; 
    6667 
    6768  /** 
     
    347348  public void clearCoRoutine(boolean callDoTerminate) 
    348349  { 
    349  
    350     if (null != m_incrementalSAXSource) 
    351     { 
    352       if (callDoTerminate) 
    353         m_incrementalSAXSource.deliverMoreNodes(false); 
    354  
    355       m_incrementalSAXSource = null; 
    356     } 
    357   } 
    358  
    359   /** 
    360    * Bind a IncrementalSAXSource to this DTM. If we discover we need nodes 
    361    * that have not yet been built, we will ask this object to send us more 
    362    * events, and it will manage interactions with its data sources. 
    363    * 
    364    * Note that we do not actually build the IncrementalSAXSource, since we don't 
    365    * know what source it's reading from, what thread that source will run in, 
    366    * or when it will run. 
    367    * 
    368    * @param incrementalSAXSource The parser that we want to recieve events from 
    369    * on demand. 
    370    * @param appCoRID The CoRoutine ID for the application. 
    371    */ 
    372   public void setIncrementalSAXSource(IncrementalSAXSource incrementalSAXSource) 
    373   { 
    374  
    375     // Establish coroutine link so we can request more data 
    376     // 
    377     // Note: It's possible that some versions of IncrementalSAXSource may 
    378     // not actually use a CoroutineManager, and hence may not require 
    379     // that we obtain an Application Coroutine ID. (This relies on the 
    380     // coroutine transaction details having been encapsulated in the 
    381     // IncrementalSAXSource.do...() methods.) 
    382     m_incrementalSAXSource = incrementalSAXSource; 
    383  
    384     // Establish SAX-stream link so we can receive the requested data 
    385     incrementalSAXSource.setContentHandler(this); 
    386     incrementalSAXSource.setLexicalHandler(this); 
    387     incrementalSAXSource.setDTDHandler(this); 
    388  
    389     // Are the following really needed? incrementalSAXSource doesn't yet 
    390     // support them, and they're mostly no-ops here... 
    391     //incrementalSAXSource.setErrorHandler(this); 
    392     //incrementalSAXSource.setDeclHandler(this); 
    393350  } 
    394351 
     
    407364  public ContentHandler getContentHandler() 
    408365  { 
    409  
    410     if (m_incrementalSAXSource instanceof IncrementalSAXSource_Filter) 
    411       return (ContentHandler) m_incrementalSAXSource; 
    412     else 
    413366      return this; 
    414367  } 
     
    426379  public LexicalHandler getLexicalHandler() 
    427380  { 
    428  
    429     if (m_incrementalSAXSource instanceof IncrementalSAXSource_Filter) 
    430       return (LexicalHandler) m_incrementalSAXSource; 
    431     else 
    432381      return this; 
    433382  } 
     
    481430  public boolean needsTwoThreads() 
    482431  { 
    483     return null != m_incrementalSAXSource; 
     432    return false; 
    484433  } 
    485434 
     
    519468      int length = m_data.elementAt(dataIndex + 1); 
    520469 
    521       if(normalize) 
    522         m_chars.sendNormalizedSAXcharacters(ch, offset, length); 
    523       else 
    524         m_chars.sendSAXcharacters(ch, offset, length); 
     470      //On n'envoie que si du texte doit etre envoyé (sinon xsl:attribute ne marche plus). 
     471      if(length > 0) { 
     472              if(normalize) 
     473                m_chars.sendNormalizedSAXcharacters(ch, offset, length); 
     474              else 
     475                m_chars.sendSAXcharacters(ch, offset, length); 
     476      } 
    525477    } 
    526478    else 
     
    718670    identity += 1; 
    719671 
    720     while (identity >= m_size) 
    721     { 
    722       if (null == m_incrementalSAXSource) 
    723         return DTM.NULL; 
    724  
    725       nextNode(); 
     672    if (identity >= m_size) 
     673    { 
     674      return DTM.NULL; 
    726675    } 
    727676 
     
    780729  protected boolean nextNode() 
    781730  { 
    782  
    783     if (null == m_incrementalSAXSource) 
    784       return false; 
    785  
    786     if (m_endDocumentOccured) 
    787     { 
    788       clearCoRoutine(); 
    789  
    790       return false; 
    791     } 
    792  
    793     Object gotMore = m_incrementalSAXSource.deliverMoreNodes(true); 
    794  
    795     // gotMore may be a Boolean (TRUE if still parsing, FALSE if 
    796     // EOF) or an exception if IncrementalSAXSource malfunctioned 
    797     // (code error rather than user error). 
    798     // 
    799     // %REVIEW% Currently the ErrorHandlers sketched herein are 
    800     // no-ops, so I'm going to initially leave this also as a 
    801     // no-op. 
    802     if (!(gotMore instanceof Boolean)) 
    803     { 
    804       if(gotMore instanceof RuntimeException) 
    805       { 
    806         throw (RuntimeException)gotMore; 
    807       } 
    808       else if(gotMore instanceof Exception) 
    809       { 
    810         throw new WrappedRuntimeException((Exception)gotMore); 
    811       } 
    812       // for now... 
    813       clearCoRoutine(); 
    814  
    815       return false; 
    816  
    817       // %TBD% 
    818     } 
    819  
    820     if (gotMore != Boolean.TRUE) 
    821     { 
    822  
    823       // EOF reached without satisfying the request 
    824       clearCoRoutine();  // Drop connection, stop trying 
    825  
    826       // %TBD% deregister as its listener? 
    827     } 
    828  
    829     return true; 
     731    return false; 
    830732  } 
    831733 
Note: See TracChangeset for help on using the changeset viewer.