Overview
Comment: | Improve namespace handling. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5849b5aac8e677bfd250243ac1b1d8cf |
User & Date: | js on 2011-03-21 19:41:33 |
Other Links: | manifest | tags |
Context
2011-03-21
| ||
21:33 | Add missing files to Xcode project. check-in: c5378ff224 user: js tags: trunk | |
19:41 | Improve namespace handling. check-in: 5849b5aac8 user: js tags: trunk | |
16:59 | Update .hgignore for Xcode 4. check-in: ea8c3f76f0 user: js tags: trunk | |
Changes
Modified src/OFXMLElement.m from [1c6e965299] to [14f63e2483].
︙ | ︙ | |||
191 192 193 194 195 196 197 | } - (OFArray*)children { return [[children copy] autorelease]; } | | < | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | } - (OFArray*)children { return [[children copy] autorelease]; } - (OFString*)_stringValueWithParent: (OFXMLElement*)parent { OFAutoreleasePool *pool, *pool2; char *str_c; size_t len, i, j, attrs_count; OFString *prefix, *parent_prefix; OFXMLAttribute **attrs_carray; OFString *ret, *tmp; OFMutableDictionary *all_namespaces; OFString *def_ns; if (characters != nil) return [characters stringByXMLEscaping]; |
︙ | ︙ | |||
228 229 230 231 232 233 234 | */ str->isa = [OFString class]; return str; } pool = [[OFAutoreleasePool alloc] init]; def_ns = (defaultNamespace != nil | | > | | | > | | > > | > > | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | */ str->isa = [OFString class]; return str; } pool = [[OFAutoreleasePool alloc] init]; def_ns = (defaultNamespace != nil ? defaultNamespace : (parent != nil ? parent->defaultNamespace : nil)); if (parent != nil && parent->namespaces != nil) { OFEnumerator *key_enum = [namespaces keyEnumerator]; OFEnumerator *obj_enum = [namespaces objectEnumerator]; id key, obj; all_namespaces = [[parent->namespaces mutableCopy] autorelease]; while ((key = [key_enum nextObject]) != nil && (obj = [obj_enum nextObject]) != nil) [all_namespaces setObject: obj forKey: key]; } else all_namespaces = namespaces; prefix = [all_namespaces objectForKey: (ns != nil ? ns : @"")]; parent_prefix = [all_namespaces objectForKey: (parent != nil && parent->ns != nil ? parent->ns : @"")]; i = 0; len = [name cStringLength] + 3; str_c = [self allocMemoryWithSize: len]; /* Start of tag */ str_c[i++] = '<'; if (prefix != nil && ![ns isEqual: def_ns] && (![ns isEqual: (parent != nil ? parent->ns : nil)] || parent_prefix != nil)) { len += [prefix cStringLength] + 1; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (id e) { [self freeMemory: str_c]; @throw e; } memcpy(str_c + i, [prefix cString], [prefix cStringLength]); i += [prefix cStringLength]; str_c[i++] = ':'; } memcpy(str_c + i, [name cString], [name cStringLength]); i += [name cStringLength]; /* xmlns if necessary */ if (ns != nil && prefix == nil && ![ns isEqual: def_ns] && (![ns isEqual: (parent != nil ? parent->ns : nil)] || parent_prefix != nil)) { len += [ns cStringLength] + 9; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (id e) { [self freeMemory: str_c]; |
︙ | ︙ | |||
356 357 358 359 360 361 362 | append = [tmp methodForSelector: @selector(appendCStringWithoutUTF8Checking:)]; for (j = 0; j < children_count; j++) append(tmp, @selector( appendCStringWithoutUTF8Checking:), [[children_carray[j] | | < | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | append = [tmp methodForSelector: @selector(appendCStringWithoutUTF8Checking:)]; for (j = 0; j < children_count; j++) append(tmp, @selector( appendCStringWithoutUTF8Checking:), [[children_carray[j] _stringValueWithParent: self] cString]); len += [tmp cStringLength] + [name cStringLength] + 2; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (id e) { [self freeMemory: str_c]; |
︙ | ︙ | |||
409 410 411 412 413 414 415 | [self freeMemory: str_c]; } return ret; } - (OFString*)stringValue { | | < | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | [self freeMemory: str_c]; } return ret; } - (OFString*)stringValue { return [self _stringValueWithParent: nil]; } - (OFString*)description { return [self stringValue]; } |
︙ | ︙ |
Modified src/OFXMLElementBuilder.m from [01d91a18bd] to [7a79298589].
︙ | ︙ | |||
80 81 82 83 84 85 86 | attrs_c = [attrs cArray]; attrs_cnt = [attrs count]; add_attr = [elem methodForSelector: @selector(addAttribute:)]; for (i = 0; i < attrs_cnt; i++) { if ([attrs_c[i] namespace] == nil && | | < > | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | attrs_c = [attrs cArray]; attrs_cnt = [attrs count]; add_attr = [elem methodForSelector: @selector(addAttribute:)]; for (i = 0; i < attrs_cnt; i++) { if ([attrs_c[i] namespace] == nil && [[attrs_c[i] name] isEqual: @"xmlns"]) continue; if ([[attrs_c[i] namespace] isEqual: @"http://www.w3.org/2000/xmlns/"]) [elem setPrefix: [attrs_c[i] name] forNamespace: [attrs_c[i] stringValue]]; add_attr(elem, @selector(addAttribute:), attrs_c[i]); } |
︙ | ︙ |