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