You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Dee Jay Randall <ra...@circularreasoning.com> on 2001/09/14 20:20:08 UTC

handling whitespace and CDATA with SAX2 characters() handler

  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     |
| randal@circularreasoning.com| www.accrue.com   | ICQ # 43551676        |
+-----------------------------+------------------+-----------------------+
What is the average rank of every song ever written? 42  -- www.launch.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org