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.
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.