-
Notifications
You must be signed in to change notification settings - Fork 3
/
GWSXMLRPCCoder.m
executable file
·910 lines (823 loc) · 24.5 KB
/
GWSXMLRPCCoder.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
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
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
/**
Copyright (C) 2008 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <[email protected]>
Date: January 2008
This file is part of the WebServices Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Date: 2007-09-24 14:19:12 +0100 (Mon, 24 Sep 2007) $ $Revision: 25500 $
*/
#import <Foundation/Foundation.h>
#import "GWSPrivate.h"
@interface GWSXMLRPCCoder (Private)
- (void) _appendObject: (id)o;
- (void) _checkElement: (GWSElement*)elem;
@end
@implementation GWSXMLRPCCoder
static NSCharacterSet *ws;
static id boolN;
static id boolY;
+ (void) initialize
{
ws = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
boolN = [[NSNumber numberWithBool: NO] retain];
boolY = [[NSNumber numberWithBool: YES] retain];
}
- (NSData*) buildFaultWithCode: (GWSRPCFaultCode)code andText: (NSString*)text
{
NSDictionary *params;
params = [NSDictionary dictionaryWithObjectsAndKeys:
text, @"faultString",
[NSNumber numberWithInt: code], @"faultCode",
nil];
return [self buildFaultWithParameters: params order: nil];
}
- (NSData*) buildRequest: (NSString*)method
parameters: (NSDictionary*)parameters
order: (NSArray*)order
{
GWSElement *container;
NSMutableString *ms;
[self reset];
container = [GWSElement new];
ms = [self mutableString];
[ms setString: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"];
if ([self fault])
{
[ms appendString: @"<methodResponse>"];
[self indent];
[self nl];
[ms appendString: @"<fault>"];
[self indent];
[self nl];
[ms appendString: @"<value>"];
[self _appendObject: parameters];
[self unindent];
[self nl];
[ms appendString: @"</value>"];
[self unindent];
[self nl];
[ms appendString: @"</fault>"];
[self unindent];
[self nl];
[ms appendString: @"</methodResponse>"];
}
else
{
unsigned c;
unsigned i;
id o;
o = [parameters objectForKey: GWSOrderKey];
if (nil != o)
{
if (order != nil && [order isEqual: o] == NO)
{
NSLog(@"Parameter order specified both in the 'order' argument and using GWSOrderKey. Using the value from GWSOrderkey.");
}
order = o;
}
o = [parameters objectForKey: GWSParametersKey];
if (nil != o)
{
parameters = o;
}
if ([order count] == 0)
{
order = [parameters allKeys];
}
c = [order count];
if ([method length] == 0)
{
[container release];
return nil;
}
else
{
static NSCharacterSet *illegal = nil;
NSRange r;
if (illegal == nil)
{
NSMutableCharacterSet *tmp = [NSMutableCharacterSet new];
[tmp addCharactersInRange: NSMakeRange('0', 10)];
[tmp addCharactersInRange: NSMakeRange('a', 26)];
[tmp addCharactersInRange: NSMakeRange('A', 26)];
[tmp addCharactersInString: @"_.:/"];
[tmp invert];
illegal = [tmp copy];
[tmp release];
}
r = [method rangeOfCharacterFromSet: illegal];
if (r.length > 0)
{
[container release];
return nil; // Bad method name.
}
}
[ms appendString: @"<methodCall>"];
[self indent];
[self nl];
[ms appendString: @"<methodName>"];
[ms appendString: [self escapeXMLFrom: method]];
[ms appendString: @"</methodName>"];
[self nl];
if (c > 0)
{
[ms appendString: @"<params>"];
[self indent];
for (i = 0; i < c; i++)
{
NSString *k = [order objectAtIndex: i];
id v = [parameters objectForKey: k];
GWSElement *e;
if (v != nil)
{
[self nl];
[ms appendString: @"<param>"];
[self indent];
[self nl];
[ms appendString: @"<value>"];
[self indent];
[[self delegate] encodeWithCoder: self
item: v
named: k
in: container];
if ((e = [container firstChild]) == nil)
{
[self _appendObject: v];
}
else
{
[e encodeWith: self];
[e remove];
}
[self unindent];
[self nl];
[ms appendString: @"</value>"];
[self unindent];
[self nl];
[ms appendString: @"</param>"];
}
}
[self unindent];
[self nl];
[ms appendString: @"</params>"];
[self unindent];
[self nl];
}
[ms appendString: @"</methodCall>"];
}
[container remove];
[container release];
return [ms dataUsingEncoding: NSUTF8StringEncoding];
}
- (NSData*) buildResponse: (NSString*)method
parameters: (NSDictionary*)parameters
order: (NSArray*)order;
{
GWSElement *container;
NSMutableString *ms;
[self reset];
container = [GWSElement new];
ms = [self mutableString];
[ms setString: @""];
[ms appendString: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"];
[ms appendString: @"<methodResponse>"];
[self indent];
[self nl];
/* Support building a fault as a response as well as doing it as a request.
*/
if ([self fault])
{
[ms appendString: @"<fault>"];
[self indent];
[self nl];
[ms appendString: @"<value>"];
[self _appendObject: parameters];
[self unindent];
[self nl];
[ms appendString: @"</value>"];
[self unindent];
[self nl];
[ms appendString: @"</fault>"];
}
else
{
unsigned c;
unsigned i;
id o;
o = [parameters objectForKey: GWSOrderKey];
if (o != nil)
{
if (order != nil)
{
NSLog(@"Parameter order specified both in the 'order' argument and using GWSOrderKey");
}
order = o;
}
o = [parameters objectForKey: GWSParametersKey];
if (nil != o)
{
parameters = o;
}
if ([order count] == 0)
{
order = [parameters allKeys];
}
c = [order count];
[ms appendString: @"<params>"];
[self indent];
for (i = 0; i < c; i++)
{
NSString *k = [order objectAtIndex: i];
id v = [parameters objectForKey: k];
if (v != nil)
{
GWSElement *e;
[self nl];
[ms appendString: @"<param>"];
[self indent];
[self nl];
[ms appendString: @"<value>"];
[self indent];
[[self delegate] encodeWithCoder: self
item: v
named: @"Result"
in: container];
if ((e = [container firstChild]) == nil)
{
[self _appendObject: v];
}
else
{
[e encodeWith: self];
[e remove];
}
[self unindent];
[ms appendString: @"</value>"];
[self unindent];
[self nl];
[ms appendString: @"</param>"];
}
}
[self unindent];
[self nl];
[ms appendString: @"</params>"];
}
[self unindent];
[self nl];
[ms appendString: @"</methodResponse>"];
[container remove];
[container release];
return [ms dataUsingEncoding: NSUTF8StringEncoding];
}
- (NSString*) encodeDateTimeFrom: (NSDate*)source
{
NSString *s;
s = [source descriptionWithCalendarFormat: @"%Y%m%dT%H:%M:%S"
timeZone: [self timeZone]
locale: nil];
return s;
}
- (id) _newParsedValue: (GWSElement*)elem
{
unsigned c = [elem countChildren];
NSString *name = [elem name];
NSString *s;
if ([name isEqualToString: @"value"] == NO)
{
[NSException raise: NSGenericException
format: @"expected 'value' but got '%@'", name];
}
if (_strictParsing) [self _checkElement: elem];
if (c == 0)
{
s = [[elem content] copy];
return s;
}
if (c != 1)
{
[NSException raise: NSGenericException
format: @"value bad element count"];
}
elem = [elem firstChild];
name = [elem name];
if (_strictParsing) [self _checkElement: elem];
if ([name isEqualToString: @"string"])
{
if (_strictParsing && nil != [elem firstChild])
{
[NSException raise: NSGenericException
format: @"xml element inside %@", name];
}
s = [[elem content] copy];
return s;
}
if ([name isEqualToString: @"i4"]
|| [name isEqualToString: @"int"])
{
if (_strictParsing && nil != [elem firstChild])
{
[NSException raise: NSGenericException
format: @"xml element inside %@", name];
}
s = [elem content];
if ([s length] == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"missing %@ value", name];
}
return [[NSNumber alloc] initWithInt: [s intValue]];
}
if ([name isEqualToString: @"boolean"])
{
char c;
if (_strictParsing && nil != [elem firstChild])
{
[NSException raise: NSGenericException
format: @"xml element inside %@", name];
}
s = [elem content];
if ([s length] == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"missing %@ value", name];
}
c = [s intValue];
if (0 == c)
{
return boolN;
}
return boolY;
}
if ([name isEqualToString: @"double"])
{
if (_strictParsing && nil != [elem firstChild])
{
[NSException raise: NSGenericException
format: @"xml element inside %@", name];
}
s = [elem content];
if ([s length] == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"missing %@ value", name];
}
return [[NSNumber alloc] initWithDouble: [s doubleValue]];
}
if ([name isEqualToString: @"base64"])
{
if (_strictParsing && nil != [elem firstChild])
{
[NSException raise: NSGenericException
format: @"xml element inside %@", name];
}
s = [elem content];
if ([s length] == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"missing %@ value", name];
}
return [[self decodeBase64From: s] retain];
}
if ([name isEqualToString: @"dateTime.iso8601"])
{
const char *u;
int year;
int month;
int day;
int hour;
int minute;
int second;
if (_strictParsing && nil != [elem firstChild])
{
[NSException raise: NSGenericException
format: @"xml element inside %@", name];
}
s = [elem content];
if ([s length] == 0)
{
[NSException raise: NSInvalidArgumentException
format: @"missing %@ value", name];
}
u = [s UTF8String];
if (sscanf(u, "%04d%02d%02dT%02d:%02d:%02d",
&year, &month, &day, &hour, &minute, &second) != 6)
{
[NSException raise: NSInvalidArgumentException
format: @"bad date/time format '%@'", s];
}
return [[NSCalendarDate alloc] initWithYear: year
month: month
day: day
hour: hour
minute: minute
second: second
timeZone: [self timeZone]];
}
if ([name isEqualToString: @"struct"])
{
NSMutableDictionary *m;
if (_strictParsing && [[[elem content] stringByTrimmingSpaces] length])
{
[NSException raise: NSGenericException
format: @"character content inside %@", name];
}
c = [elem countChildren];
m = [NSMutableDictionary dictionaryWithCapacity: c];
elem = [elem firstChild];
while (elem != nil)
{
GWSElement *e;
id o;
if ([[elem name] isEqualToString: @"member"] == NO)
{
[NSException raise: NSGenericException
format: @"struct with bad elment '%@'", [elem name]];
}
if ([elem countChildren] != 2)
{
[NSException raise: NSGenericException
format: @"member with wrong number of elements"];
}
if (_strictParsing) [self _checkElement: elem];
e = [elem firstChild];
if ([[e name] isEqualToString: @"name"] == NO)
{
[NSException raise: NSGenericException
format: @"member first element is '%@'", [e name]];
}
name = [e content];
if ([name length] == 0)
{
[NSException raise: NSGenericException
format: @"member name is empty"];
}
if (_strictParsing) [self _checkElement: e];
e = [e sibling];
o = [self _newParsedValue: e];
[m setObject: o forKey: name];
[o release];
elem = [elem sibling];
}
return [m retain];
}
if ([name isEqualToString: @"array"])
{
NSMutableArray *m;
if (_strictParsing && [[[elem content] stringByTrimmingSpaces] length])
{
[NSException raise: NSGenericException
format: @"character content inside %@", name];
}
c = [elem countChildren];
if (c != 1)
{
[NSException raise: NSGenericException
format: @"array with bad number of elements"];
}
elem = [elem firstChild];
if ([[elem name] isEqualToString: @"data"] == NO)
{
[NSException raise: NSGenericException
format: @"array without 'data' element"];
}
if (_strictParsing) [self _checkElement: elem];
c = [elem countChildren];
m = [NSMutableArray arrayWithCapacity: c];
elem = [elem firstChild];
while (elem != nil)
{
id o = [self _newParsedValue: elem];
[m addObject: o];
[o release];
elem = [elem sibling];
}
return [m retain];
}
[NSException raise: NSGenericException
format: @"Unknown element '%@'", name];
return nil;
}
- (NSMutableDictionary*) parseMessage: (NSData*)data
{
NSAutoreleasePool *pool;
NSMutableDictionary *result;
NSMutableDictionary *params;
NSMutableArray *order;
GWSElement *tree;
GWSElement *elem;
NSString *name;
result = [NSMutableDictionary dictionaryWithCapacity: 3];
[self reset];
pool = [NSAutoreleasePool new];
NS_DURING
{
tree = [self parseXML: data];
if (_strictParsing) [self _checkElement: tree];
name = [tree name];
if ([name isEqualToString: @"methodCall"] == YES)
{
if ([tree countChildren] > 2)
{
[NSException raise: NSGenericException
format: @"too many elements in methodCall"];
}
elem = [tree firstChild];
if ([[elem name] isEqualToString: @"methodName"] == NO)
{
[NSException raise: NSGenericException
format: @"methodName missing in methodCall"];
}
if (_strictParsing) [self _checkElement: elem];
[result setObject: [elem content] forKey: GWSMethodKey];
elem = [elem sibling];
if (elem != nil)
{
unsigned c = [elem countChildren];
unsigned i;
NSArray *a = [elem children];
if ([[elem name] isEqualToString: @"params"] == NO)
{
[NSException raise: NSGenericException
format: @"found %@ when expecting params in methodCall",
[elem name]];
}
if (_strictParsing) [self _checkElement: elem];
params = [NSMutableDictionary dictionaryWithCapacity: c];
order = [NSMutableArray arrayWithCapacity: c];
for (i = 0; i < c; i++)
{
id o;
elem = [a objectAtIndex: i];
if ([elem countChildren] != 1)
{
[NSException raise: NSGenericException
format: @"bad element count in param %u", i];
}
if ([[elem name] isEqualToString: @"param"] == NO)
{
[NSException raise: NSGenericException
format: @"bad element at param %u", i];
}
if (_strictParsing) [self _checkElement: elem];
name = [NSString stringWithFormat: @"Arg%u", i];
o = [[self delegate] decodeWithCoder: self
item: [elem firstChild]
named: name];
if (o == nil)
{
o = [self _newParsedValue: [elem firstChild]];
[params setObject: o forKey: name];
[o release];
}
else
{
[params setObject: o forKey: name];
}
[order addObject: name];
}
[result setObject: params forKey: GWSParametersKey];
[result setObject: order forKey: GWSOrderKey];
}
}
else if ([name isEqualToString: @"methodResponse"] == YES)
{
if ([tree countChildren] > 1)
{
[NSException raise: NSGenericException
format: @"too many elements in methodResponse"];
}
elem = [tree firstChild];
name = [elem name];
if ([name isEqualToString: @"params"] == YES)
{
id o;
if (_strictParsing) [self _checkElement: elem];
if ([elem countChildren] != 1)
{
[NSException raise: NSGenericException
format: @"bad element count in params"];
}
elem = [elem firstChild];
name = [elem name];
if ([name isEqualToString: @"param"] == NO)
{
[NSException raise: NSGenericException
format: @"bad element in params"];
}
if ([elem countChildren] != 1)
{
[NSException raise: NSGenericException
format: @"bad element count in param"];
}
if (_strictParsing) [self _checkElement: elem];
o = [[self delegate] decodeWithCoder: self
item: [elem firstChild]
named: @"Result"];
params = [NSMutableDictionary dictionaryWithCapacity: 1];
if (o == nil)
{
o = [self _newParsedValue: [elem firstChild]];
[params setObject: o forKey: @"Result"];
[o release];
}
else
{
[params setObject: o forKey: @"Result"];
}
[result setObject: params forKey: GWSParametersKey];
order = [NSMutableArray arrayWithCapacity: 1];
[order addObject: @"Result"];
[result setObject: order forKey: GWSOrderKey];
}
else if ([name isEqualToString: @"fault"] == YES)
{
id o;
if (_strictParsing) [self _checkElement: elem];
o = [self _newParsedValue: [elem firstChild]];
[result setObject: o forKey: GWSFaultKey];
[o release];
}
else if (elem != nil)
{
[NSException raise: NSGenericException
format: @"bad element in methodResponse"];
}
}
else
{
[NSException raise: NSGenericException
format: @"Not an XML-RPC document"];
}
}
NS_HANDLER
{
[result setObject: [localException reason] forKey: GWSErrorKey];
}
NS_ENDHANDLER
[self reset];
[pool release];
return result;
}
- (void) setStrictParsing: (BOOL)isStrict
{
_strictParsing = (isStrict ? YES : NO);
}
- (BOOL) strictParsing
{
return _strictParsing;
}
@end
@implementation GWSXMLRPCCoder (Private)
- (void) _appendObject: (id)o
{
NSMutableString *ms = [self mutableString];
if (o == nil)
{
return;
}
else if (YES == [o isKindOfClass: [NSString class]])
{
if (YES == [self compact])
{
[ms appendString: [self escapeXMLFrom: o]];
}
else
{
[ms appendString: @"<string>"];
[ms appendString: [self escapeXMLFrom: o]];
[ms appendString: @"</string>"];
}
}
else if (o == boolN)
{
[ms appendString: @"<boolean>0</boolean>"];
}
else if (o == boolY)
{
[ms appendString: @"<boolean>1</boolean>"];
}
else if (YES == [o isKindOfClass: [NSNumber class]])
{
const char *t = [o objCType];
if (strchr("cCsSiIlLqQ", *t) != 0)
{
long i = [(NSNumber*)o longValue];
[ms appendFormat: @"<i4>%ld</i4>", i];
}
else
{
[ms appendFormat: @"<double>%f</double>", [(NSNumber*)o doubleValue]];
}
}
else if (YES == [o isKindOfClass: [NSData class]])
{
[self nl];
[ms appendString: @"<base64>"];
[ms appendString: [self encodeBase64From: o]];
[self nl];
[ms appendString: @"</base64>"];
}
else if (YES == [o isKindOfClass: [NSDate class]])
{
[ms appendString: @"<dateTime.iso8601>"];
[ms appendString: [self encodeDateTimeFrom: o]];
[ms appendString: @"</dateTime.iso8601>"];
}
else if (YES == [o isKindOfClass: [NSArray class]])
{
unsigned i;
unsigned c = [o count];
[self nl];
[ms appendString: @"<array>"];
[self indent];
[self nl];
[ms appendString: @"<data>"];
[self indent];
for (i = 0; i < c; i++)
{
[self nl];
[ms appendString: @"<value>"];
[self indent];
[self _appendObject: [o objectAtIndex: i]];
[self unindent];
[self nl];
[ms appendString: @"</value>"];
}
[self unindent];
[self nl];
[ms appendString: @"</data>"];
[self unindent];
[self nl];
[ms appendString: @"</array>"];
}
else if (YES == [o isKindOfClass: [NSDictionary class]])
{
NSEnumerator *kEnum;
NSString *key;
kEnum = [[o objectForKey: GWSOrderKey] objectEnumerator];
if (kEnum == nil)
{
kEnum = [o keyEnumerator];
}
[self nl];
[ms appendString: @"<struct>"];
[self indent];
while ((key = [kEnum nextObject]))
{
[self nl];
[ms appendString: @"<member>"];
[self indent];
[self nl];
[ms appendString: @"<name>"];
[ms appendString: [self escapeXMLFrom: [key description]]];
[ms appendString: @"</name>"];
[self nl];
[ms appendString: @"<value>"];
[self indent];
[self _appendObject: [o objectForKey: key]];
[self unindent];
[ms appendString: @"</value>"];
[self unindent];
[self nl];
[ms appendString: @"</member>"];
}
[self unindent];
[self nl];
[ms appendString: @"</struct>"];
}
else
{
[self _appendObject: [o description]];
}
}
- (void) _checkElement: (GWSElement*)elem
{
if (YES == _strictParsing)
{
NSString *p = [elem prefix];
NSDictionary *a = [elem attributes];
if ([p length] > 0)
{
[NSException raise: NSGenericException
format: @"unexpected prefix for '%@': %@",
[[elem path] componentsJoinedByString: @"/"], p];
}
else if ([a count] > 0)
{
[NSException raise: NSGenericException
format: @"unexpected attributes for '%@': %@",
[[elem path] componentsJoinedByString: @"/"], a];
}
}
}
@end