gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

failing GSXML parsing


From: David Wetzel
Subject: failing GSXML parsing
Date: Tue, 5 Oct 2010 17:41:01 -0700

Hi,

HTML code like:

<OPTION VALUE="unknown" SELECTED>

fails:

(gdb) p  key
$3 = (class NSString *) 0x7f7ff9006470
(gdb) po  key
selected
(gdb) p obj  
$4 = (class NSString *) 0x0

[dict setObject: obj forKey: key]; <<-- will raise

My current local fix is:

static void
startElementFunction(void *ctx, const unsigned char *name,
  const unsigned char **atts)
{
  NSMutableDictionary *dict;

  NSCAssert(ctx,@"No Context");
  dict = [NSMutableDictionary dictionary];
  if (atts != NULL)
    {
      int i = 0;

      while (atts[i] != NULL)
        {
          NSString      *key = UTF8Str(atts[i++]);
          NSString      *obj = UTF8Str(atts[i++]);
    
    // we seem to have a problem with
    // <OPTION VALUE="unknown" SELECTED>
    // which produced an key "selected", but nil value for obj

    if (obj) {
      [dict setObject: obj forKey: key];
    } else {
      // log warning?
    }

        }
    }
  [HANDLER startElement: UTF8Str(name)
             attributes: dict];
}

Which is probably not what we always want, because the 'selected' information 
is lost.
Probably we could just use NSNull as obj so that we know later that its just a 
dummy.

Cheers,

David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]