expat whitespace in CDATA sections

  • Thread starter Chris Waddingham
  • Start date
C

Chris Waddingham

I am experiencing 2 problems with CDATA sections. These are:

1. Expat appears to be collapsing adjacent linefeeds into one inside CDATA
sections.
2. Expat (XML_CharacterDataHandler) returns the wrong len value for CDATA
sections containing ']'.

I would be grateful of any help you can offer.

My XML application contains code like this:

<![CDATA[
namespace
{
int max=10;

unsigned char buffer[10];
]]>

My C++ character_data_handler looks like this - note in particular the cout
diagnostic:

void character_data_handler( const XML_Char* s, int len )
{
if ( m_element_data != "" )
{
m_element_data += "\n";
}

cout << "s=" << s << ", len=" << len << endl;
if ( len == 0 )
{
m_element_data += "\n";
}
else
{
m_element_data.append( s, len );
}
}

My problems are that character_data_handler returns the following:

<![CDATA[
namespace
{
int max=10;
unsigned char buffer[10
];
]]>

As you can see line 5 is lost and line 6 is broken at the ']'.

The diagnostic output from character_data_handler is:

s=namespace, len=9
s={, len=1
s= int max=10;, len=15
s= unsigned char buffer[10];, len=27
s=];, len=2

Best regards,

Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top