discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSXML* classes


From: Ivan Vučica
Subject: Re: NSXML* classes
Date: Sun, 26 Feb 2012 18:58:55 +0100

On Wed, Feb 22, 2012 at 17:32, Gregory Casamento <greg.casamento@gmail.com> wrote:
Ivan,

I will have some time to look into the cause tonight.

GC

Hi Gregory,

you've talked about my use of fast iteration making it hard for you to use SlaveOPML for debugging. I've found my few uses using regex and have pushed the changes. As a reminder, here is the code:
  http://bitbucket.org/ivucica/opml/

Currently, when creating a new node in a blank file, [NSXMLNode elementWithName:stringValue:] seems to be recursing incessantly. An excerpt of the backtrace:
#2157 0x00ca1957 in +[NSXMLNode elementWithName:stringValue:] (self=0xee6cd0, 
    _cmd=0xee7ab0, name=0x8072288, string=0x824ccbc) at NSXMLNode.m:751
#2158 0x00ca1957 in +[NSXMLNode elementWithName:stringValue:] (self=0xee6cd0, 
    _cmd=0xee7ab0, name=0x8072288, string=0x824ccbc) at NSXMLNode.m:751
#2159 0x00ca1957 in +[NSXMLNode elementWithName:stringValue:] (self=0xee6cd0, 
    _cmd=0xee7ab0, name=0x8072288, string=0x824ccbc) at NSXMLNode.m:751

This patch fixes this trivial lapsus calami:
Index: Source/NSXMLNode.m
===================================================================
--- Source/NSXMLNode.m (revision 34818)
+++ Source/NSXMLNode.m (working copy)
@@ -748,7 +748,7 @@
 {
   NSXMLElement *e;
   
-  e = [self elementWithName: name stringValue: string];
+  e = [[[NSXMLElement alloc] initWithName: name stringValue: string] autorelease];
   return e;
 }

However, looks like an XPath query called on an NSXMLNode still doesn't return results as under OS X. That is, having called:

  NSArray *opmlNodes = [self nodesForXPath:@"./opml" error:nil];
  [self setOpmlRoot:[opmlNodes objectAtIndex:0]];

with self being a subclass of NSXMLDocument, and thus getting the root node, the following call does not return the <body/> subnode of the <opml/> root node, instead returning an array with zero entries:

  bodyNodes = [_opmlRoot nodesForXPath:@"./body" error:nil];

Looking at execute_xpath() in NSXMLNode.m, I must admit I have no idea what may be going wrong. 

If anyone wants to debug using my code, feel free to focus on the following files that actually deal with the data model:
OPMLOutline.h
OPMLOutline.m
OPMLOutline+Private.h
OPMLOutlineXMLElement.h
OPMLOutlineXMLElement.m

--
Ivan Vučica - ivan@vucica.net



reply via email to

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