Re: [xml] Multiple CDATA blocks
- From: Philip Van Hoof <spamfrommailing freax org>
- To: veillard redhat com
- Cc: xml gnome org, gtk-app-devel-list gnome org
- Subject: Re: [xml] Multiple CDATA blocks
- Date: Thu, 02 Sep 2004 21:13:17 +0200
On Thu, 2004-09-02 at 14:45 -0400, Daniel Veillard wrote:
On Thu, Sep 02, 2004 at 06:35:07PM +0200, Philip Van Hoof wrote:
So basically, yea I know that you people are going to slaughter me using
an axe after tearing of my fingernails one by one and worst of all
really really going to hate me for using this older libraries.
No it's even simpler than that, I don't want to hear about it.
Since the older gnome-xml isn't parsing it correctly for me, I assume
that I can't do much about it.
So in stead of letting libxml-2 handle the situation of a "]]>" in my
CDATA-body by creating two such blocks, I decided to replace it with
Could it be that this is behaviour of libxml-2 when in my data, the
string "]]>" is found?
Yes that's the usual way to proceed, e.g.
see the paragraphs suggesting this.
For now I've created a small check-data for "]]>" at the writer side and
a "undo-that-check"-type of function at the reader-side:
At the writer-side I am lucky since I have it as a GString, which means
finding and replacing is trivial
So this replaces "]]>" to "]]>"
p = strstr (gstr->str, "]]>");
if (p != NULL)
i = gstr->str - p; i = -i; i+=2;
gstr = g_string_erase (gstr, i, 1);
gstr = g_string_insert (gstr, i, ">");
At the reader-side, it's not a GString so I created this ugly thing
which replaces ">" with '>'.
r = strstr (s, ">");
if (r != NULL)
gint len = strlen (s) - 3;
gchar *tmp=(gchar*)g_malloc0(sizeof (gchar) * len);
*r='\0'; strcpy (tmp, s);
*r++='>'; *r++='>'; *r++='>';
*r='>'; strcat (tmp, r);
g_free (s); s=tmp;
This solves my problem for now, nevertheless I am open for better
suggestions from the mailinglist of course. Lucky me we have all the
memory and cpu-power we want, I'd dislike using this for high-
performance situations :-\
Thanks for the very fast answer Daniel
Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
gnome: pvanhoof at gnome dot org
work: Philip dot VanHoof at Cronos dot Be
] [Thread Prev