I noticed that the recent update of Mac OS X 10.5.8 breaks compatibility with previous versions regarding XQuery statements in NSXMLNode, specifically using the XQuery function tokenize. I originally reported this bug against a future version of Mac OS X and now seems to have slipped into the latest update of Mac OS X 10.5.

rdar://problem/7037807

The following code works on Mac OS X 10.5.0 - 10.5.7 but does not work on Mac OS X 10.5.8.

@interface Bug7037807 : NSObject
{
        NSXMLDocument* _document;
}
- (void)performXQuery:(NSString*)query;
@end

@implementation Bug7037807

- (id)init
{
        if (self = [super init]) {
_document = [[NSXMLDocument alloc] initWithXMLString:@"<html><title>title</title><body><h1>header</ h1><p>astring, bstring, cstring, dstring, estring</p><p>astring & bstring & cstring & dstring & estring</p></body></html>" options:NSXMLDocumentTidyHTML error:nil];
        }
        
        return self;
}

- (void)awakeFromNib
{
        [self performXQuery:@"/descendant-or-self::p[1]"];
        [self performXQuery:@"xs:string(/descendant-or-self::p[1])"];
[self performXQuery:@"tokenize(xs:string(/descendant-or-self::p[1]), ',')"];
}

- (void)performXQuery:(NSString*)query
{
        NSError* __error = nil;
        NSArray* __results;
        
        __results = [_document objectsForXQuery:query error:&__error];
        
        if (!__results) {
                NSLog(@"error: %@", __error);
        }
        else {
                NSLog(@"results: %@", __results);
        }
}

@end


Output on Mac OS X 10.5.0 - 10.5.7

2009-08-05 23:34:49.428 Bug7037807[577:10b] results: (
    <p>astring, bstring, cstring, dstring, estring
</p>
)
2009-08-05 23:34:49.431 Bug7037807[577:10b] results: (
    "astring, bstring, cstring, dstring, estring\n"
)
2009-08-05 23:34:49.432 Bug7037807[577:10b] results: (
    astring,
    " bstring",
    " cstring",
    " dstring",
    " estring\n"
)



Output on Mac OS X 10.5.8

2009-08-05 23:34:49.428 Bug7037807[577:10b] results: (
    <p>astring, bstring, cstring, dstring, estring
</p>
)
2009-08-05 23:34:49.431 Bug7037807[577:10b] results: (
    "astring, bstring, cstring, dstring, estring\n"
)
2009-08-05 23:34:49.432 Bug7037807[577:10b] error: XQueryError:17 - "invalid arguments to function - tokenize"

What does the 10.5.8 version of tokenize want as arguments? Any known work-around?

--
Michael

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to