2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "DOMBuilderFactory.h"
23 #include <DOM/DOMSaxBuilder.h>
24 #include <SaxObjC/SaxXMLReader.h>
25 #include <SaxObjC/SaxXMLReaderFactory.h>
28 @implementation DOMBuilderFactory
30 static id factory = nil;
32 + (id)standardDOMBuilderFactory {
34 factory = [[self alloc] init];
40 - (id<NSObject,DOMBuilder>)createDOMBuilderWithXmlReader:(id<SaxXMLReader>)_r {
41 DOMSaxBuilder *builder;
46 builder = [[DOMSaxBuilder alloc] initWithXMLReader:_r];
47 return [builder autorelease];
50 /* reader constructors */
52 - (SaxXMLReaderFactory *)readerFactory {
53 return [SaxXMLReaderFactory standardXMLReaderFactory];
56 - (id<NSObject,DOMBuilder>)createDOMBuilder {
57 id<SaxXMLReader> reader;
59 if ((reader = [[self readerFactory] createXMLReader]) == nil) {
60 NSLog(@"%s:%i: could not create default DOM builder "
61 @"because no SAX default reader could be constructed.",
62 __PRETTY_FUNCTION__, __LINE__);
66 return [self createDOMBuilderWithXmlReader:reader];
68 - (id<NSObject,DOMBuilder>)createDOMBuilderWithName:(NSString *)_name {
69 id<SaxXMLReader> reader;
71 if ((reader = [[self readerFactory] createXMLReaderWithName:_name]) == nil) {
72 NSLog(@"%s:%i: could not create DOM builder '%@' "
73 @"because no SAX reader named '%@' could be constructed.",
74 __PRETTY_FUNCTION__, __LINE__,
79 return [self createDOMBuilderWithXmlReader:reader];
81 - (id<NSObject,DOMBuilder>)createDOMBuilderForMimeType:(NSString *)_mtype {
82 id<SaxXMLReader> reader;
84 reader = [[self readerFactory] createXMLReaderForMimeType:_mtype];
86 NSLog(@"%s:%i: could not create DOM builder for MIME type '%@' "
87 @"because no SAX proper reader could be constructed.",
88 __PRETTY_FUNCTION__, __LINE__, _mtype);
92 return [self createDOMBuilderWithXmlReader:reader];
95 - (NSArray *)availableDOMBuilders {
96 return [NSArray arrayWithObject:@"DOMSaxBuilder"];
99 @end /* DOMBuilderFactory */