469,270 Members | 1,728 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

expat whitespace in CDATA sections

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
0 1881

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Aidan | last post: by
reply views Thread by Fabian Kr?ger | last post: by
10 posts views Thread by Simon Brooke | last post: by
2 posts views Thread by Steveino | last post: by
12 posts views Thread by Peter Michaux | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.