]> err.no Git - sope/blob - sope-ical/versitSaxDriver/VSSaxDriver.m
fixed gcc 4.0 warnings
[sope] / sope-ical / versitSaxDriver / VSSaxDriver.m
1 /*
2  Copyright (C) 2003-2004 Max Berger
3  Copyright (C) 2004 OpenGroupware.org
4
5  This file is part of versitSaxDriver, written for the OpenGroupware.org 
6  project (OGo).
7  
8  SOPE is free software; you can redistribute it and/or modify it under
9  the terms of the GNU Lesser General Public License as published by the
10  Free Software Foundation; either version 2, or (at your option) any
11  later version.
12  
13  SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16  License for more details.
17  
18  You should have received a copy of the GNU Lesser General Public
19  License along with SOPE; see the file COPYING.  If not, write to the
20  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22 */
23
24 #include "VSSaxDriver.h"
25 #include "VSStringFormatter.h"
26 #include "common.h"
27
28 @implementation VSSaxDriver
29
30 static BOOL debugOn = NO;
31
32 static NSCharacterSet *dotCharSet = nil;
33 static NSCharacterSet *equalSignCharSet = nil;
34 static NSCharacterSet *commaCharSet = nil;
35 static NSCharacterSet *colonAndSemicolonCharSet = nil;
36 static NSCharacterSet *colonSemicolonAndDquoteCharSet = nil;
37 static NSCharacterSet *whitespaceCharSet = nil;
38
39 static VSStringFormatter *stringFormatter = nil;
40
41 + (void)initialize {
42   static BOOL didInit = NO;
43   NSUserDefaults *ud;
44
45   if(didInit)
46     return;
47   didInit = YES;
48
49   ud      = [NSUserDefaults standardUserDefaults];
50   debugOn = [ud boolForKey:@"VSSaxDriverDebugEnabled"];
51
52   dotCharSet =
53     [[NSCharacterSet characterSetWithCharactersInString:@"."] retain];
54   equalSignCharSet =
55     [[NSCharacterSet characterSetWithCharactersInString:@"="] retain];
56   commaCharSet =
57     [[NSCharacterSet characterSetWithCharactersInString:@","] retain];
58   colonAndSemicolonCharSet =
59     [[NSCharacterSet characterSetWithCharactersInString:@":;"] retain];
60   colonSemicolonAndDquoteCharSet =
61     [[NSCharacterSet characterSetWithCharactersInString:@":;\""] retain];
62   whitespaceCharSet =
63     [[NSCharacterSet whitespaceCharacterSet] retain];
64
65   stringFormatter = [VSStringFormatter sharedFormatter];
66 }
67
68
69 - (id)init {
70   if ((self = [super init])) {
71     self->prefixURI         = @"";
72     self->cardStack         = [[NSMutableArray alloc]      init];
73     self->elementList       = [[NSMutableArray alloc]      init];
74     self->attributeMapping  = [[NSMutableDictionary alloc] init];
75     self->subItemMapping    = [[NSMutableDictionary alloc] init];
76   }
77   return self;
78 }
79
80 - (void)dealloc {
81   [self->contentHandler    release];
82   [self->prefixURI         release];
83   [self->cardStack         release];
84   [self->elementList       release];
85   [self->attributeElements release];
86   [self->elementMapping    release];
87   [self->attributeMapping  release];
88   [self->subItemMapping    release];
89   [super dealloc];
90 }
91
92 /* accessors */
93
94 - (void)setFeature:(NSString *)_name to:(BOOL)_value {
95 }
96 - (BOOL)feature:(NSString *)_name {
97   return NO;
98 }
99
100 - (void)setProperty:(NSString *)_name to:(id)_value {
101 }
102 - (id)property:(NSString *)_name {
103   return nil;
104 }
105
106 /* handlers */
107
108 - (void)setContentHandler:(id<NSObject,SaxContentHandler>)_handler {
109   ASSIGN(self->contentHandler,_handler);
110 }
111
112 - (void)setDTDHandler:(id<NSObject,SaxDTDHandler>)_handler {
113   // FIXME
114 }
115
116 - (void)setErrorHandler:(id<NSObject,SaxErrorHandler>)_handler {
117   // FIXME
118 }
119 - (void)setEntityResolver:(id<NSObject,SaxEntityResolver>)_handler {
120   // FIXME
121 }
122
123 - (id<NSObject,SaxContentHandler>)contentHandler {
124   return self->contentHandler;
125 }
126
127 - (id<NSObject,SaxDTDHandler>)dtdHandler {
128   // FIXME
129   return NULL;
130 }
131
132 - (id<NSObject,SaxErrorHandler>)errorHandler {
133   // FIXME
134   return NULL;
135 }
136 - (id<NSObject,SaxEntityResolver>)entityResolver {
137   // FIXME
138   return NULL;
139 }
140
141 - (void)setPrefixURI:(NSString *)_uri {
142   ASSIGNCOPY(self->prefixURI, _uri);
143 }
144 - (NSString *)prefixURI {
145   return self->prefixURI;
146 }
147
148 - (void)setAttributeElements:(NSSet *)_elements {
149   ASSIGNCOPY(self->attributeElements, _elements);
150 }
151 - (NSSet *)attributeElements {
152   return self->attributeElements;
153 }
154
155 - (void)setElementMapping:(NSDictionary *)_mapping {
156   ASSIGNCOPY(self->elementMapping, _mapping);
157 }
158 - (NSDictionary *)elementMapping {
159   return self->elementMapping;
160 }
161
162 - (void)setAttributeMapping:(NSDictionary *)_mapping {
163   [self setAttributeMapping:_mapping forElement:@""];
164 }
165
166 - (void)setAttributeMapping:(NSDictionary *)_mapping 
167   forElement:(NSString *)_element 
168 {
169   if (!_element)
170     _element = @"";
171   [attributeMapping setObject:_mapping forKey:_element];
172 }
173
174 - (void)setSubItemMapping:(NSArray *)_mapping 
175   forElement:(NSString *)_element 
176 {
177   [subItemMapping setObject:_mapping forKey:_element];  
178 }
179
180
181
182 /* parsing */
183
184 - (NSString *)_mapTagName:(NSString *)_tagName {
185   NSString *ret;
186   NSRange  r;
187
188   if ((ret = [self->elementMapping objectForKey:_tagName]) == nil) {
189     //NSLog(@"Unknown Key: %@ in %@",_tagName,self->elementMapping);
190     ret = _tagName;
191
192     /* This is to allow parsing of vCards produced by Apple
193        Addressbook. AFAIK the .dot notation is a non-standard
194        extension */
195     r = [_tagName rangeOfCharacterFromSet:dotCharSet];
196     if (r.length > 0) {
197       ret = [self _mapTagName:[_tagName substringFromIndex:(r.location + 1)]];
198     }
199   }
200   return ret;
201 }
202
203 - (void)_addAttribute:(NSString *)_attribute
204   value:(NSString *)_value 
205   toAttrs:(SaxAttributes *)_attrs
206 {
207   [_attrs addAttribute:_attribute
208           uri:self->prefixURI 
209           rawName:_attribute
210           type:@"CDATA"
211           value:_value];
212 }
213
214 - (void)_addAttribute:(NSString *)_attribute value:(NSString *)_value {
215   NSArray *element = [cardStack lastObject];
216   SaxAttributes *attrs = [element objectAtIndex:2];
217   [self _addAttribute:_attribute value:_value toAttrs:attrs];
218 }
219
220 - (NSString *)_mapAttrName:(NSString *)_attrName forTag:(NSString *)_tagName {
221   NSString *mappedName;
222   
223   mappedName = [(NSDictionary *)[self->attributeMapping objectForKey:_tagName]
224                                         objectForKey:_attrName];
225   if (mappedName == nil) {
226     mappedName = [(NSDictionary *)[self->attributeMapping objectForKey:
227                                           [self _mapTagName:_tagName]]
228                                           objectForKey:_attrName];
229   }
230   if (mappedName == nil) {
231     mappedName = [(NSDictionary *)[self->attributeMapping objectForKey:@""]
232                                           objectForKey:_attrName];
233   }
234   if (mappedName == nil)
235     mappedName = _attrName;
236   
237   return mappedName;
238 }
239
240 - (void)_parseAttr:(NSString *)_attr 
241   forTag:(NSString *)_tagName
242   intoAttr:(NSString **)attr_
243   intoValue:(NSString **)value_
244 {
245   NSRange  r;
246   NSString *attrName, *attrValue, *mappedName;
247   
248   r = [_attr rangeOfCharacterFromSet:equalSignCharSet];
249   if (r.length > 0) {
250     unsigned left, right;
251
252     attrName  = [[_attr substringToIndex:r.location] uppercaseString];
253     left = NSMaxRange(r);
254     right = [_attr length] - 1;
255     if(left < right) {
256       if(([_attr characterAtIndex:left]  == '"') &&
257          ([_attr characterAtIndex:right] == '"'))
258       {
259         left += 1;
260         r = NSMakeRange(left, right - left);
261         attrValue = [_attr substringWithRange:r];
262       }
263       else {
264         attrValue = [_attr substringFromIndex:left];
265       }
266     }
267     else if(left == right) {
268       attrValue = [_attr substringFromIndex:left];
269     }
270     else {
271       attrValue = @"";
272     }
273   }
274   else {
275     attrName  = @"TYPE";
276     attrValue = _attr;
277   }
278   
279 #if 0
280   // ZNeK: what's this for?
281   r = [attrValue rangeOfCharacterFromSet:commaCharSet];
282   while (r.length > 0) {
283     [attrValue replaceCharactersInRange:r withString:@" "];
284     r = [attrValue rangeOfCharacterFromSet:commaCharSet];
285   }
286 #endif
287
288   mappedName = [self _mapAttrName:attrName forTag:_tagName];
289   *attr_ = mappedName;
290   *value_ = [stringFormatter stringByUnescapingRFC2445Text:attrValue];
291 }
292
293 - (id<NSObject,SaxAttributes>)_mapAttrs:(NSArray *)_attrs 
294   forTag:(NSString *)_tagName 
295 {
296   SaxAttributes       *retAttrs;
297   NSEnumerator        *attrEnum;
298   NSString            *curAttr, *mappedAttr, *mappedValue, *oldValue;
299   NSMutableDictionary *attributes;
300
301   if (!_attrs || [_attrs count] == 0)
302     return nil;
303
304   attributes = [[NSMutableDictionary alloc] init];
305   retAttrs = [[[SaxAttributes alloc] init] autorelease];
306   attrEnum = [_attrs objectEnumerator];
307   while ((curAttr = [attrEnum nextObject])) {
308     [self _parseAttr:curAttr
309           forTag:_tagName
310           intoAttr:&mappedAttr
311           intoValue:&mappedValue];
312     if ((oldValue = [attributes objectForKey:mappedAttr])) {
313       NSString *val;
314       /* ZNeK: duh! */
315       val = [NSString stringWithFormat:@"%@ %@",oldValue, mappedValue];
316       [attributes setObject:val forKey:mappedAttr];
317     }
318     else  
319       [attributes setObject:mappedValue forKey:mappedAttr];
320   }
321
322   attrEnum = [attributes keyEnumerator];
323   while ((curAttr = [attrEnum nextObject])) {
324     [self _addAttribute:curAttr
325           value:[attributes objectForKey:curAttr]
326           toAttrs:retAttrs];
327   }
328   
329   [attributes release];
330   
331   return retAttrs;
332 }
333
334 - (NSArray *)_beginTag:(NSString *)_tagName 
335   withAttrs:(id<NSObject,SaxAttributes>)_attrs 
336 {
337   NSArray *tag = [NSArray arrayWithObjects:@"BEGIN",_tagName,_attrs,NULL];
338   [self->elementList addObject:tag];
339   return tag;
340 }
341
342 - (void)_endTag:(NSString *)_tagName {
343   [self->elementList addObject:
344          [NSArray arrayWithObjects:@"END",_tagName,NULL]];
345 }
346
347 - (void)_addSubItems:(NSArray *)_items withData:(NSString *)_content {
348   NSEnumerator *itemEnum, *contentEnum;
349   NSString *subTag;
350   NSString *subContent;
351   
352   itemEnum    = [_items objectEnumerator];
353   contentEnum = [[_content componentsSeparatedByString:@";"] objectEnumerator];
354   
355   while ((subTag=[itemEnum nextObject])) {
356     subContent = [contentEnum nextObject];
357     
358     [self _beginTag:subTag withAttrs:nil];
359     if ([subContent length]>0) 
360       [self->elementList addObject:
361         [NSArray arrayWithObjects:@"DATA", subContent, nil]];  
362     [self _endTag:subTag];
363   }
364 }
365
366 - (void)_dataTag:(NSString *)_tagName 
367   withAttrs:(id<NSObject,SaxAttributes>)_attrs 
368   andContent:(NSString *)_content 
369 {
370   NSArray *subItems;
371
372   _content = [stringFormatter stringByUnescapingRFC2445Text:_content];
373   if ([self->attributeElements containsObject:_tagName]) {
374     [self _addAttribute:_tagName value:_content];
375   } 
376   else {
377     [self _beginTag:_tagName withAttrs:_attrs];
378     if ([_content length] > 0) {
379       if ((subItems = [self->subItemMapping objectForKey:_tagName])) {
380         [self _addSubItems:subItems withData:_content];
381       }
382       else {
383         [self->elementList addObject:
384           [NSArray arrayWithObjects:@"DATA", _content, nil]];  
385       }
386     }
387     [self _endTag:_tagName];
388   }
389 }
390
391 - (void)_eventsForElements {
392   NSEnumerator *enu;
393   NSArray  *obj;
394   NSString *type;
395   NSString *name;
396   unichar  *chardata;
397   id<NSObject,SaxAttributes> attrs;
398   
399   enu = [elementList objectEnumerator];
400   while ((obj = [enu nextObject])) {
401     type = [obj objectAtIndex:0];
402     name = [obj objectAtIndex:1];
403     
404     if ([obj count] > 2) 
405       attrs = [obj objectAtIndex:2];
406     else
407       attrs = nil;
408
409     if ([type isEqualToString:@"BEGIN"]) {
410       [self->contentHandler startElement:name
411                             namespace:self->prefixURI
412                             rawName:name
413                             attributes:attrs];
414     } 
415     else if ([type isEqualToString:@"END"]) {
416       [self->contentHandler endElement:name
417                             namespace:self->prefixURI
418                             rawName:name];
419     }
420     else {
421       unsigned len = [name length];
422       chardata = malloc(len * sizeof(unichar));
423       [name getCharacters:chardata range:NSMakeRange(0, len)];
424       [self->contentHandler characters:chardata length:len];
425       if (chardata)
426         free(chardata);
427     }
428   }
429   [elementList removeAllObjects];
430 }
431
432 - (void)_parseLine:(NSString *)_line {
433   NSString       *tagName, *tagValue;
434   NSMutableArray *tagAttributes;
435   NSRange        r, todoRange;
436   unsigned       length;
437
438   length = [_line length];
439   todoRange = NSMakeRange(0, length);
440   r = [_line rangeOfCharacterFromSet:colonAndSemicolonCharSet
441              options:0
442              range:todoRange];
443   /* is line well-formed? */
444   if(r.length == 0) {
445     if(debugOn) {
446       NSLog(@"%s got an improper content line! ->\n%@",
447             __PRETTY_FUNCTION__,
448             _line);
449     }
450     return;
451   }
452
453   tagName = [[_line substringToIndex:r.location] uppercaseString];
454   tagAttributes = [[NSMutableArray alloc] init];
455
456   /* possible shortcut: if we spotted a ':', we don't have to do "expensive"
457      argument scanning/processing.
458   */
459   if([_line characterAtIndex:r.location] != ':') {
460     BOOL isAtEnd = NO, isInDquote = NO;
461     unsigned start = NSMaxRange(r);
462
463     todoRange = NSMakeRange(start, length - start);
464     while(!isAtEnd) {
465       BOOL skip = YES;
466
467       /* scan for parameters */
468       r = [_line rangeOfCharacterFromSet:colonSemicolonAndDquoteCharSet
469                  options:0
470                  range:todoRange];
471       /* is line well-formed? */
472       if(r.length == 0 || r.location == 0) {
473         if(debugOn) {
474           NSLog(@"%s got an improper content line! ->\n%@",
475                 __PRETTY_FUNCTION__,
476                 _line);
477         }
478         [tagAttributes release];
479         return;
480       }
481       /* first check if delimiter candidate is escaped */
482       if([_line characterAtIndex:(r.location - 1)] != '\\') {
483         unichar delimiter;
484         NSRange copyRange;
485
486         delimiter = [_line characterAtIndex:r.location];
487         if(delimiter == '\"') {
488           /* not a real delimiter - toggle isInDquote for proper escaping */
489           isInDquote = !isInDquote;
490         }
491         else {
492           if(!isInDquote) {
493             /* is a delimiter, which one? */
494             skip = NO;
495             if(delimiter == ':') {
496               isAtEnd = YES;
497             }
498             copyRange = NSMakeRange(start, r.location - start);
499             [tagAttributes addObject:[_line substringWithRange:copyRange]];
500             if(!isAtEnd) {
501               /* adjust start, todoRange */
502               start     = NSMaxRange(r);
503               todoRange = NSMakeRange(start, length - start);
504             }
505           }
506         }
507       }
508       if(skip) {
509         /* adjust todoRange */
510         unsigned offset = NSMaxRange(r);
511         todoRange = NSMakeRange(offset, length - offset);
512       }
513     }
514   }
515   tagValue = [_line substringFromIndex:NSMaxRange(r)];
516
517   if ([tagName isEqualToString:@"BEGIN"]) {
518     id tag;
519     
520     tag = [self _beginTag:[self _mapTagName:tagValue] 
521                 withAttrs:[[[SaxAttributes alloc] init] autorelease]];
522     [self->cardStack addObject:tag];
523   } 
524   else if ([tagName isEqualToString:@"END"]) {
525     NSString *mtName;
526     
527     mtName = [self _mapTagName:tagValue];
528     if([self->cardStack count] > 0) {
529       NSString *expectedName;
530
531       expectedName = [[self->cardStack lastObject] objectAtIndex:1];
532       if(![expectedName isEqualToString:mtName]) {
533         if(debugOn) {
534           NSLog(@"%s found end tag '%@' which doesn't match expected name "
535                 @"'%@'! Tag '%@' hasn't been closed properly. Given iCal "
536                 @"document contains errors!",
537                 __PRETTY_FUNCTION__,
538                 mtName,
539                 expectedName,
540                 expectedName);
541         }
542         /* probably futile attempt to parse anyways */
543         if(debugOn) {
544           NSLog(@"%s trying to fix previous error by inserting bogus end "
545                 @"tag.",
546                 __PRETTY_FUNCTION__);
547         }
548         [self _endTag:expectedName];
549         [self->cardStack removeLastObject];
550       }
551     }
552     else {
553       if(debugOn) {
554         NSLog(@"%s found end tag '%@' without any open tags left?!",
555               __PRETTY_FUNCTION__,
556               mtName);
557       }
558     }
559     [self _endTag:mtName];
560     [self->cardStack removeLastObject];
561     if ([self->cardStack count] == 0)
562       [self _eventsForElements];
563   }
564   else {
565     [self _dataTag:[self _mapTagName:tagName]
566          withAttrs:[self _mapAttrs:tagAttributes forTag:tagName] 
567         andContent:tagValue];
568   }
569   [tagAttributes release];
570 }
571
572 - (void)_parseString:(NSString *)_rawString {
573   unsigned pos, length;
574   NSMutableString *line;
575   NSRange r;
576
577   [self->contentHandler startDocument];
578   [self->contentHandler startPrefixMapping:@"" uri:self->prefixURI];
579   
580   length = [_rawString length];
581   /* RFC2445:
582      contentline        = name *(";" param ) ":" value CRLF
583      ; When parsing a content line, folded lines MUST first
584      ; be unfolded
585   */
586   r = NSMakeRange(0, 0);
587   /* probably too optimistic */ 
588   line = [[NSMutableString alloc] initWithCapacity:75 + 2];
589
590   for(pos = 0; pos < length; pos++) {
591     unichar c = [_rawString characterAtIndex:pos];
592     
593     if(c == '\r') {
594       if(((length - 1) - pos) >= 1) {
595         if([_rawString characterAtIndex:pos + 1] == '\n') {
596           BOOL isAtEndOfLine = YES;
597           /* test for folding first */
598           if(((length - 1) - pos) >= 2) {
599             unichar ws = [_rawString characterAtIndex:pos + 2];
600             isAtEndOfLine = [whitespaceCharSet characterIsMember:ws] ? NO
601                                                                      : YES;
602             if(!isAtEndOfLine) {
603               /* assemble part of line up to pos */
604               if(r.length > 0) {
605                 [line appendString:[_rawString substringWithRange:r]];
606               }
607               /* unfold */
608               pos += 2;
609               r = NSMakeRange(pos + 1, 0); /* begin new range */
610             }
611           }
612           if(isAtEndOfLine) {
613             /* assemble part of line up to pos */
614             if(r.length > 0) {
615               [line appendString:[_rawString substringWithRange:r]];
616             }
617             [self _parseLine:line];
618             /* reset line */
619             [line deleteCharactersInRange:NSMakeRange(0, [line length])];
620             pos += 1;
621             r = NSMakeRange(pos + 1, 0); /* begin new range */
622           }
623         }
624       }
625       else {
626         /* garbled last line! */
627         if(debugOn) {
628           NSLog(@"%s Last line is truncated, trying to parse anyways!",
629                 __PRETTY_FUNCTION__);
630         }
631       }
632     }
633     else if(c == '\n') { /* broken, non-standard */
634       BOOL isAtEndOfLine = YES;
635       /* test for folding first */
636       if(((length - 1) - pos) >= 1) {
637         unichar ws = [_rawString characterAtIndex:pos + 1];
638         isAtEndOfLine = [whitespaceCharSet characterIsMember:ws] ? NO
639                                                                  : YES;
640         if(!isAtEndOfLine) {
641           /* assemble part of line up to pos */
642           if(r.length > 0) {
643             [line appendString:[_rawString substringWithRange:r]];
644           }
645           /* unfold */
646           pos += 1;
647           r = NSMakeRange(pos + 1, 0); /* begin new range */
648         }
649       }
650       if(isAtEndOfLine) {
651         /* assemble part of line up to pos */
652         if(r.length > 0) {
653           [line appendString:[_rawString substringWithRange:r]];
654         }
655         [self _parseLine:line];
656         /* reset line */
657         [line deleteCharactersInRange:NSMakeRange(0, [line length])];
658         r = NSMakeRange(pos + 1, 0); /* begin new range */
659       }
660     }
661     else {
662       r.length += 1;
663     }
664   }
665   if(r.length > 0) {
666     if(debugOn) {
667       NSLog(@"%s Last line of iCal string is not properly terminated!",
668             __PRETTY_FUNCTION__);
669     }
670     [line appendString:[_rawString substringWithRange:r]];
671     [self _parseLine:line];
672   }
673
674   if([self->cardStack count] != 0) {
675     if(debugOn) {
676       NSLog(@"%s found elements on cardStack. This indicates an improper "
677             @"iCal structure! Not all required events will have been "
678             @"generated, leading to unpredictable results!",
679             __PRETTY_FUNCTION__);
680     }
681   }
682
683   [line release];
684   [self->contentHandler endPrefixMapping:@""];
685   [self->contentHandler endDocument];
686 }
687
688 - (void)parseFromSource:(id)_source {
689   if (debugOn)
690     NSLog(@"%s: parse: %@", __PRETTY_FUNCTION__, _source);
691   
692   if ([_source isKindOfClass:[NSURL class]]) {
693     if (debugOn) 
694       NSLog(@"%s: trying to load URL...",__PRETTY_FUNCTION__);
695     _source = [_source resourceDataUsingCache:NO];
696   }
697   
698   if ([_source isKindOfClass:[NSData class]]) {
699     // FIXME: Data is not always utf-8.....
700     if (debugOn) 
701       NSLog(@"%s: trying to decode data...",__PRETTY_FUNCTION__);
702     _source = [[[NSString alloc]
703                  initWithData:_source encoding:NSUTF8StringEncoding]
704                  autorelease];
705   }
706   
707   if ([_source isKindOfClass:[NSString class]]) {
708     if (debugOn) 
709       NSLog(@"%s: trying to parse string...",__PRETTY_FUNCTION__);
710     [self _parseString:_source];
711   } 
712   else {
713     if (debugOn) 
714       NSLog(@"%s: unrecognizable source: %@", __PRETTY_FUNCTION__,_source);
715     // FIXME: Return Error
716   }
717 }
718
719 - (void)parseFromSource:(id)_source systemId:(NSString *)_sysId {
720   [self parseFromSource:_source];
721 }
722
723 - (void)parseFromSystemId:(NSString *)_sysId {
724   NSURL *url;
725   
726   if ((url = [NSURL URLWithString:_sysId]))
727     [self parseFromSource:url systemId:_sysId];
728 }
729
730 /* debugging */
731
732 - (BOOL)isDebuggingEnabled {
733   return debugOn;
734 }
735
736 @end /* VersitSaxDriver */