By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,904 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,904 IT Pros & Developers. It's quick & easy.

expat whitespace in CDATA sections

P: n/a
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.
Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.