]> err.no Git - sope/blob - sope-xml/SaxObjC/SaxXMLFilter.m
fixed a header file
[sope] / sope-xml / SaxObjC / SaxXMLFilter.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3   
4   This file is part of OpenGroupware.org.
5
6   OGo 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
9   later version.
10
11   OGo 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.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "SaxXMLFilter.h"
24 #include "common.h"
25
26 @implementation SaxXMLFilter
27
28 - (id)initWithParent:(id<NSObject,SaxXMLReader>)_parent {
29   if ((self = [self init])) {
30     [self setParent:_parent];
31   }
32   return self;
33 }
34
35 - (void)dealloc {
36   [self->parent release];
37   [super dealloc];
38 }
39
40 - (void)setParent:(id<NSObject,SaxXMLReader>)_parent {
41   if (self->parent == _parent)
42     return;
43   
44   [self->parent setContentHandler:nil];
45   [self->parent setDTDHandler:nil];
46   [self->parent setErrorHandler:nil];
47   [self->parent setEntityResolver:nil];
48
49   ASSIGN(self->parent, _parent);
50   
51   [self->parent setContentHandler:self];
52   [self->parent setDTDHandler:self];
53   [self->parent setErrorHandler:self];
54   [self->parent setEntityResolver:self];
55 }
56
57 - (id<NSObject,SaxXMLReader>)parent {
58   return self->parent;
59 }
60
61 /* features & properties */
62
63 - (void)setFeature:(NSString *)_name to:(BOOL)_value {
64   [self->parent setFeature:_name to:_value];
65 }
66 - (BOOL)feature:(NSString *)_name {
67   return [self->parent feature:_name];
68 }
69
70 - (void)setProperty:(NSString *)_name to:(id)_value {
71   [self->parent setProperty:_name to:_value];
72 }
73 - (id)property:(NSString *)_name {
74   return [self->parent property:_name];
75 }
76
77 /* handlers */
78
79 - (void)setDTDHandler:(id<NSObject,SaxDTDHandler>)_handler {
80   ASSIGN(self->dtdHandler, _handler);
81 }
82 - (id<NSObject,SaxDTDHandler>)dtdHandler {
83   return self->dtdHandler;
84 }
85
86 - (void)setErrorHandler:(id<NSObject,SaxErrorHandler>)_handler {
87   ASSIGN(self->errorHandler, _handler);
88 }
89 - (id<NSObject,SaxErrorHandler>)errorHandler {
90   return self->errorHandler;
91 }
92
93 - (void)setEntityResolver:(id<NSObject,SaxEntityResolver>)_handler {
94   ASSIGN(self->entityResolver, _handler);
95 }
96 - (id<NSObject,SaxEntityResolver>)entityResolver {
97   return self->entityResolver;
98 }
99
100 - (void)setContentHandler:(id<NSObject,SaxContentHandler>)_handler {
101   ASSIGN(self->contentHandler, _handler);
102 }
103 - (id<NSObject,SaxContentHandler>)contentHandler {
104   return self->contentHandler;
105 }
106
107 /* parsing */
108
109 - (void)parseFromSource:(id)_source {
110   [self->parent parseFromSource:_source];
111 }
112 - (void)parseFromSystemId:(NSString *)_sysId {
113   [self->parent parseFromSystemId:_sysId];
114 }
115
116 - (void)parseFromSource:(id)_source systemId:(NSString *)_sysId {
117   [self->parent parseFromSource:_source systemId:_sysId];
118 }
119
120 /* SaxEntityResolver */
121
122 - (id)resolveEntityWithPublicId:(NSString *)_pubId
123   systemId:(NSString *)_sysId
124 {
125   return [self->entityResolver resolveEntityWithPublicId:_pubId systemId:_sysId];
126 }
127
128 /* SaxContentHandler */
129
130 - (void)startDocument {
131   [self->contentHandler startDocument];
132 }
133 - (void)endDocument {
134   [self->contentHandler endDocument];
135 }
136
137 - (void)startPrefixMapping:(NSString *)_prefix uri:(NSString *)_uri {
138   [self->contentHandler startPrefixMapping:_prefix uri:_uri];
139 }
140 - (void)endPrefixMapping:(NSString *)_prefix {
141   [self->contentHandler endPrefixMapping:_prefix];
142 }
143
144 - (void)startElement:(NSString *)_localName
145   namespace:(NSString *)_ns
146   rawName:(NSString *)_rawName
147   attributes:(id<SaxAttributes>)_attributes
148 {
149   [self->contentHandler startElement:_localName namespace:_ns
150                         rawName:_rawName attributes:_attributes];
151 }
152 - (void)endElement:(NSString *)_localName
153   namespace:(NSString *)_ns
154   rawName:(NSString *)_rawName
155 {
156   [self->contentHandler endElement:_localName namespace:_ns rawName:_rawName];
157 }
158
159 - (void)characters:(unichar *)_chars length:(int)_len {
160   [self->contentHandler characters:_chars length:_len];
161 }
162 - (void)ignorableWhitespace:(unichar *)_chars length:(int)_len {
163   [self->contentHandler ignorableWhitespace:_chars length:_len];
164 }
165 - (void)processingInstruction:(NSString *)_pi data:(NSString *)_data {
166   [self->contentHandler processingInstruction:_pi data:_data];
167 }
168 - (void)setDocumentLocator:(id<NSObject,SaxLocator>)_locator {
169   [self->contentHandler setDocumentLocator:_locator];
170 }
171 - (void)skippedEntity:(NSString *)_entityName {
172   [self->contentHandler skippedEntity:_entityName];
173 }
174
175 /* error-handler */
176
177 - (void)warning:(SaxParseException *)_exception {
178   [self->errorHandler warning:_exception];
179 }
180 - (void)error:(SaxParseException *)_exception {
181   [self->errorHandler error:_exception];
182 }
183 - (void)fatalError:(SaxParseException *)_exception {
184   [self->errorHandler fatalError:_exception];
185 }
186
187 /* dtd-handler */
188
189 - (void)notationDeclaration:(NSString *)_name
190   publicId:(NSString *)_pubId
191   systemId:(NSString *)_sysId
192 {
193   [self->dtdHandler notationDeclaration:_name publicId:_pubId systemId:_sysId];
194 }
195
196 - (void)unparsedEntityDeclaration:(NSString *)_name
197   publicId:(NSString *)_pubId
198   systemId:(NSString *)_sysId
199   notationName:(NSString *)_notName
200 {
201   [self->dtdHandler unparsedEntityDeclaration:_name
202                     publicId:_pubId systemId:_sysId
203                     notationName:_notName];
204 }
205
206 @end /* SaxXMLFilter */