sboag       01/01/09 14:35:50

  Modified:    java/src/org/apache/xalan/stree SourceTreeHandler.java
  Log:
  Move the shouldStripWS test from SourceTreeHandler to
  StreeDOMBuilder, so that the test can be done after the text
  has been accumulated from potentially multiple text nodes.
  This addresses #SCUU4SPUML : Crimson: position70 has whitespace differences
  
  Steps to Reproduce:
  WinNT 4.0 SP5, JDK 1.1.8, Xalan 2.0.D06, xml-crimson built from CVS approx 
03-Jan-01
  xml-xalan\test
  Copy crimson.jar into xml-xalan\java\bin
  ConformanceTest.bat -crimson [-category position]
  (Note the -crimson flag automatically adds crimson.jar instead of xerces.jar 
in classpath, and sets two -D flags to use crimson jaxp classes)
  
  From ConformanceTest.xml/.html: Note missing whitespace in various places 
(only some shown)
  gold-parse-type;[xml]; test-parse-type;[xml]; 
mismatch-value;TEXT_NODE(#text)len=253;TEXT_NODE(#text)len=232;lengths do not 
match mismatch-value-gold;TEXT_NODE(#text);
   A(1):attC(2): This is the 1st comment T(3): text-in-doc E(4):innerT(1): 
inner-text C(2): This is the 2nd comment E(3):subT(1):subtext T(4): text-after 
T(5): text-in-doc2 E(6):inner2A(1):blatE(1):subT(1):subtext T(2):final-text
  
  mismatch-value-text;TEXT_NODE(#text);
   A(1):attC(2): This is the 1st comment T(3): text-in-docE(4):innerT(1): 
inner-textC(2): This is the 2nd comment E(3):subT(1):subtext T(4): text-after 
T(5): text-in-doc2E(6):inner2A(1):blatE(1):subT(1):subtext T(2):final-text
  
  =====
  Get the transformer thread via createTransformerThread.  From email
  on this subject:
  
  In response to this I've created the following method in 
org.apache.xalan.TransformerImpl:
  
    /**
     * Create a thread for the transform.  This can be overridden by derived
     * implementations to provide their own thread, for thread pooling and the
     * like.
     *
     * @return thread suitable to use for the transformation.
     */
    public Thread createTransformThread()
    {
      return new Thread(this);
    }
  
  Someone who is using XalanJ2 in an EJB environment or the like can set the 
javax.xml.transform.TransformerFactory system property to provide a derivation 
from TransformerImpl, and provide a thread suitable for the environment.
  
  I don't know if this will do the trick.  Please advise.
  
  -scott
  
        "Roytman, Alex" <[EMAIL PROTECTED]> 01/07/2001 12:14 AM Please respond 
to xalan-dev        To: "'[email protected]'" <[email protected]> 
 cc: "'[email protected]'" <[email protected]>, (bcc: 
Scott Boag/CAM/Lotus)  Subject: Xalan2 in server environment (was Xalan2 Stree 
Module spans sec ond thread to do transform?)
  
  Scott,
  Thank you very much for your reply.
  One part which is sensitive to thread origin in my opinion is Extensions
  In extensions people can do all sorts of things. I am not very experienced
  with EJB implementation but I can imagine that many things (transactional
  context, bean environment, etc.) depend on threads and some static variables
  which helps with setting /switching context for beans being managed by the
  server.
  
  Example: in J2EE it is recommended to create JNDI initial context using
  default constructor InitialContext(). The result of the instantiation
  depends on the context where it was executed and the context is set by the
  server for the thread on which your component is running. So if you call new
  InitialContext() in your extension (in sql extension to get JDBC DataSource
  for example ) it might fail.
  
  Do extension run on the second (created by Xalan) thread?
  
  I will forward your message to Tomcat news group lets see what Tomcat
  developers think.
  
  Alex
  
  -----Original Message-----
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  Sent: Saturday, January 06, 2001 11:39 PM
  To: [email protected]
  Subject: Re: Xalan2 Stree Module spans second thread to do transform?
  
  > In many
  > cases component should not attempt to create its own threads.
  > For example thread's ContextClassLoader or ThreadLocal variables might
  need
  > to be initialized by the server.
  > Also it defeats thread pooling done by the server etc.
  >
  > Could you please comment on this issue
  
  Yeah, I've been a bit worried about this.  However, I've not yet heard of
  any problems that have been caused by it, and XalanJ1 has long had a two
  threaded system (though not as effective as in XalanJ2).   Ultimately, I
  would rather use a pull model for this, and only have one thread, but a)
  there is no standard "pull" API for XML parsers, and b) this doesn't work
  anyway when SAX events are used, for whatever reason.
  
  I'm open to any input to how Xalan might request the thread from the
  servlet environment, though it has to be able to be run outside a servlet
  environment too.  Also, it would be good if someone with deep knowledge of
  EJB's and the like could comment.  I talked this over in a hallway
  conversation with someone who is fairly familiar with EJB's, and he didn't
  think there was a problem, though I forget why.  It seems insane/crazy to
  me that a component can't use a thread in it's internal modules.
  
  -scott
  
                      "Roytman,
  
                      Alex"                 To:
  "'[email protected]'" <[email protected]>
                      <[EMAIL PROTECTED]        cc:     (bcc: Scott
  Boag/CAM/Lotus)
                      etech.com>            Subject:     Xalan2 Stree Module
  spans second thread to do transform?
  
                      01/06/2001
  
                      10:48 PM
                      Please respond
  
                      to xalan-dev
  
  Dear Xalan developers,
  I have a question about using upcoming Xalan2 in server env.
  
  In Xalan2 design specs it is said:
  
  "The Stree module implements the default Source Tree for Xalan, that is to
  be transformed. It implements read-only DOM2 interfaces, and provides some
  information needed for fast transforms, such as document order indexes. It
  also attempts to allow a streaming transform by launching the transform on
  a
  secondary thread as soon as the SAX2 StartDocument event has occurred."
  
  In server environment server usually controls threads creation. In many
  cases component should not attempt to create its own threads.
  For example thread's ContextClassLoader or ThreadLocal variables might need
  to be initialized by the server.
  Also it defeats thread pooling done by the server etc.
  
  Could you please comment on this issue
  
  Thank you very much in advance
  
  Alex Roytman
  
  Revision  Changes    Path
  1.30      +1 -5      
xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java
  
  Index: SourceTreeHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- SourceTreeHandler.java    2001/01/09 19:41:43     1.29
  +++ SourceTreeHandler.java    2001/01/09 22:35:48     1.30
  @@ -393,7 +393,7 @@
           else
             m_transformer.setSourceTreeDocForThread(m_root);
   
  -        Thread t = new Thread(m_transformer);
  +        Thread t = m_transformer.createTransformThread();
   
           m_transformer.setTransformThread(t);
   
  @@ -616,10 +616,6 @@
   
       synchronized (m_root)
       {
  -      if (m_shouldStripWS
  -              && XMLCharacterRecognizer.isWhiteSpace(ch, start, length))
  -        return;
  -
         if (m_isCData)
           m_sourceTreeHandler.cdata(ch, start, length);
         else
  
  
  

Reply via email to