Hi Dee Jay,

If you derive your handler from LexicalHandler, you can install the handler
into the parser using setLexicalHandler(), and handle the startCDATA() and
endCDATA() events.  Probably the easiest way is to have a boolean flag in
your handler that is toggled by the calls.

Dave



                                                                                       
                                          
                      Dee Jay Randall                                                  
                                          
                      <randal@circularrea         To:      [EMAIL PROTECTED] 
                                          
                      soning.com>                 cc:      (bcc: David N 
Bertoni/CAM/Lotus)                                      
                                                  Subject: handling whitespace and 
CDATA with SAX2 characters() handler          
                      09/14/2001 02:20 PM                                              
                                          
                      Please respond to                                                
                                          
                      xerces-c-dev                                                     
                                          
                                                                                       
                                          
                                                                                       
                                          




  I am trying to parse the following xml using the SAX2 parser:

<Value>
  <![CDATA[some text]]>
</Value>

  The problem I am running into is that I want the
result of parsing this to be:

  "some text"

but instead I am getting:

  "\n  some text\n"

because my characters() handler is getting everything
between <Value> and </Value> instead of just what is
inside the CDATA. (I realize that this is what should
happen. Right?)

  Is there a way to tell from inside my characters()
handler whether or not I'm inside CDATA?

  It isn't sufficient to just strip leading and trailing
whitespace because I also want to parse:

  <Value> <![CDATA[ some text]]></Value>

into " some text" (one leading space, not two).

  Is the only solution to make sure that there is no
whitespace between my <Value> and CDATA elements?

  Thanks,
  Dee Jay

+-----------------------------+------------------+-----------------------+
| Founding Partner            | Software Engineer| Dee Jay Randall, B.Sc.|
| Circular Reasoning          | Accrue Software  | M.Sc. Student, CS     |
| [EMAIL PROTECTED]| www.accrue.com   | ICQ # 43551676        |
+-----------------------------+------------------+-----------------------+
What is the average rank of every song ever written? 42  -- www.launch.com

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






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

Reply via email to