ObjFW  Check-in [62d6cdadb6]

Overview
Comment:Add -[bindPrefix:forNamespace] and -[bindDefaultNamespace:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 62d6cdadb6cf2581cec2f8ba91147fdc135cea697c231e28c1facfd6ddbc9d38
User & Date: js on 2010-07-08 23:39:56
Other Links: manifest | tags
Context
2010-07-09
20:45
Add more accessors to OFXMLElement. check-in: 714aad6fba user: js tags: trunk
2010-07-08
23:39
Add -[bindPrefix:forNamespace] and -[bindDefaultNamespace:]. check-in: 62d6cdadb6 user: js tags: trunk
19:28
Add special handling for xmlns in OFXMLElement. check-in: 8a71128e91 user: js tags: trunk
Changes

Modified src/OFXMLElement.h from [e29f433914] to [11a7413503].

202
203
204
205
206
207
208









209
210
211
212
213
214
215







216
217
218
219
220
221
222
 *
 * \param prefix The prefix for the namespace
 * \param ns The namespace for which the prefix is set
 */
- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)ns;










/**
 * Sets the default namespace for the element.
 *
 * \param ns The default namespace for the element
 */
- (void)setDefaultNamespace: (OFString*)ns;








/**
 * Adds a child to the OFXMLElement.
 *
 * \param child Another OFXMLElement which is added as a child
 */
- (void)addChild: (OFXMLElement*)child;
@end







>
>
>
>
>
>
>
>
>







>
>
>
>
>
>
>







202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
 *
 * \param prefix The prefix for the namespace
 * \param ns The namespace for which the prefix is set
 */
- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)ns;

/**
 * Binds a prefix for a namespace.
 *
 * \param prefix The prefix for the namespace
 * \param ns The namespace for which the prefix is bound
 */
- (void)bindPrefix: (OFString*)prefix
      forNamespace: (OFString*)ns;

/**
 * Sets the default namespace for the element.
 *
 * \param ns The default namespace for the element
 */
- (void)setDefaultNamespace: (OFString*)ns;

/**
 * Binds the default namespace for the element.
 *
 * \param ns The default namespace for the element
 */
- (void)bindDefaultNamespace: (OFString*)ns;

/**
 * Adds a child to the OFXMLElement.
 *
 * \param child Another OFXMLElement which is added as a child
 */
- (void)addChild: (OFXMLElement*)child;
@end

Modified src/OFXMLElement.m from [d9b9a2bb4c] to [a95f7f973f].

407
408
409
410
411
412
413










414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433







434
435
436
437
438
439
440
						       selector: _cmd];
	if (ns == nil)
		ns = @"";

	[namespaces setObject: prefix
		       forKey: ns];
}











- (OFString*)defaultNamespace
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	return [[defaultNamespace retain] autorelease];
}

- (void)setDefaultNamespace: (OFString*)ns
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	OFString *old = defaultNamespace;
	defaultNamespace = [ns copy];
	[old release];
}








- (void)addChild: (OFXMLElement*)child
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];








>
>
>
>
>
>
>
>
>
>




















>
>
>
>
>
>
>







407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
						       selector: _cmd];
	if (ns == nil)
		ns = @"";

	[namespaces setObject: prefix
		       forKey: ns];
}

- (void)bindPrefix: (OFString*)prefix
      forNamespace: (OFString*)ns
{
	[self setPrefix: prefix
	   forNamespace: ns];
	[self addAttributeWithName: prefix
			 namespace: @"http://www.w3.org/2000/xmlns/"
		       stringValue: ns];
}

- (OFString*)defaultNamespace
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	return [[defaultNamespace retain] autorelease];
}

- (void)setDefaultNamespace: (OFString*)ns
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	OFString *old = defaultNamespace;
	defaultNamespace = [ns copy];
	[old release];
}

- (void)bindDefaultNamespace: (OFString*)ns
{
	[self setDefaultNamespace: ns];
	[self addAttributeWithName: @"xmlns"
		       stringValue: ns];
}

- (void)addChild: (OFXMLElement*)child
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];