ObjFW  Diff

Differences From Artifact [7304a0b96d]:

To Artifact [adc9e6f9aa]:


284
285
286
287
288
289
290


291
292
293
294
295
296
297
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLElement *attributesElement, *namespacesElement;
		OFXMLElement *childrenElement;



		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];








>
>







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLElement *attributesElement, *namespacesElement;
		OFXMLElement *childrenElement;
		OFEnumerator *keyEnumerator, *objectEnumerator;
		id key, object;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

310
311
312
313
314
315
316
317

318

319




































320
321
322
323
324
325
326
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:
		    OF_SERIALIZATION_NS] firstObject];
		childrenElement = [[[element
		    elementForName: @"children"
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:
		    OF_SERIALIZATION_NS] firstObject];

		attributes = [[attributesElement objectByDeserializing] copy];

		namespaces = [[namespacesElement objectByDeserializing] copy];

		children = [[childrenElement objectByDeserializing] copy];





































		if (namespaces == nil)
			namespaces = [[OFMutableDictionary alloc] init];

		[namespaces setObject: @"xml"
			       forKey: @"http://www.w3.org/XML/1998/namespace"];
		[namespaces setObject: @"xmlns"







|
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:
		    OF_SERIALIZATION_NS] firstObject];
		childrenElement = [[[element
		    elementForName: @"children"
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:
		    OF_SERIALIZATION_NS] firstObject];

		attributes = [[attributesElement objectByDeserializing]
		    mutableCopy];
		namespaces = [[namespacesElement objectByDeserializing]
		    mutableCopy];
		children = [[childrenElement objectByDeserializing]
		    mutableCopy];

		/* Sanity checks */
		if ((attributes != nil &&
		    ![attributes isKindOfClass: [OFMutableArray class]]) ||
		    (namespaces != nil &&
		    ![namespaces isKindOfClass: [OFMutableDictionary class]]) ||
		    (children != nil &&
		    ![children isKindOfClass: [OFMutableArray class]]))
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		objectEnumerator = [attributes objectEnumerator];
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLAttribute class]])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: isa
					      selector: _cmd];

		keyEnumerator = [namespaces keyEnumerator];
		objectEnumerator = [namespaces objectEnumerator];
		while ((key = [keyEnumerator nextObject]) != nil &&
		    (object = [objectEnumerator nextObject]) != nil)
			if (![key isKindOfClass: [OFString class]] ||
			    ![object isKindOfClass: [OFString class]])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: isa
					      selector: _cmd];

		objectEnumerator = [children objectEnumerator];
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLNode class]])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: isa
					      selector: _cmd];

		if (namespaces == nil)
			namespaces = [[OFMutableDictionary alloc] init];

		[namespaces setObject: @"xml"
			       forKey: @"http://www.w3.org/XML/1998/namespace"];
		[namespaces setObject: @"xmlns"