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 "WOXMLSaxModelHandler.h"
23
#include "WOXMLMappingEntity.h"
24
#include "WOXMLMappingModel.h"
25
#include "WOXMLMappingProperty.h"
28
@implementation WOXMLSaxModelHandler
31
RELEASE(self->currentModel);
32
RELEASE(self->currentProperty);
33
RELEASE(self->currentEntity);
37
- (WOXMLMappingModel *)model {
38
return AUTORELEASE(RETAIN(self->currentModel));
43
- (void)startModel:(id<SaxAttributes>)_attrs {
44
if ((self->currentProperty != nil) || (self->currentEntity != nil)) {
45
NSLog(@"cannot nest 'model' tags inside property or entity tags !");
49
RELEASE(self->currentModel); self->currentModel = nil;
50
self->currentModel = [[WOXMLMappingModel alloc] init];
53
if ((self->currentProperty != nil) || (self->currentEntity != nil))
57
- (void)startEntity:(id<SaxAttributes>)_attrs {
60
if (self->currentProperty) {
61
NSLog(@"cannot nest 'entity' tags inside property tags !");
64
if (self->currentEntity) {
65
NSLog(@"cannot nest 'entity' tags inside entity tags !");
68
if (self->currentModel == nil) {
69
NSLog(@"missing 'model' parent element for 'entity' tag !");
73
self->currentEntity = [[WOXMLMappingEntity alloc] init];
75
if ((s = [_attrs valueForRawName:@"name"]))
76
[self->currentEntity setName:s];
77
if ((s = [_attrs valueForRawName:@"xmlTag"]))
78
[self->currentEntity setXmlTag:s];
79
if ((s = [_attrs valueForRawName:@"unmappedTagsKey"]))
80
[self->currentEntity setUnmappedTagsKey:s];
81
if ((s = [_attrs valueForRawName:@"contentsKey"]))
82
[self->currentEntity setContentsKey:s];
84
if ((s = [_attrs valueForRawName:@"ignoreUnmappedTags"])) {
85
[self->currentEntity setIgnoreUnmappedTags:
86
[[s uppercaseString] isEqualToString:@"YES"]];
90
if ((self->currentProperty != nil) || (self->currentModel == nil))
93
if (self->currentEntity) {
94
if ([self->currentEntity isValid])
95
[self->currentModel addEntity:self->currentEntity];
96
RELEASE(self->currentEntity); self->currentEntity = nil;
100
- (void)startProperty:(id<SaxAttributes>)_attrs {
103
if (self->currentProperty) {
104
NSLog(@"cannot nest 'property' tags inside property tags !");
107
if ((self->currentEntity == nil) || (self->currentModel == nil)) {
108
NSLog(@"missing 'entity' parent element for 'property' tag !");
112
self->currentProperty = [[WOXMLMappingProperty alloc] init];
114
if ((s = [_attrs valueForRawName:@"name"]))
115
[self->currentProperty setName:s];
116
if ((s = [_attrs valueForRawName:@"xmlTag"]))
117
[self->currentProperty setXmlTag:s];
118
if ((s = [_attrs valueForRawName:@"codeBasedOn"]))
119
[self->currentProperty setCodeBasedOn:s];
120
if ((s = [_attrs valueForRawName:@"outputTags"]))
121
[self->currentProperty setOutputTags:s];
123
if ((s = [_attrs valueForRawName:@"attribute"])) {
124
[self->currentProperty setAttribute:
125
[[s uppercaseString] isEqualToString:@"YES"]];
127
if ((s = [_attrs valueForRawName:@"forceList"])) {
128
[self->currentProperty setForceList:
129
[[s uppercaseString] isEqualToString:@"YES"]];
131
if ((s = [_attrs valueForRawName:@"reportEmptyValues"])) {
132
[self->currentProperty setReportEmptyValues:
133
[[s uppercaseString] isEqualToString:@"YES"]];
136
- (void)endProperty {
137
if ((self->currentEntity == nil) || (self->currentModel == nil))
140
if (self->currentProperty) {
141
if ([self->currentProperty isValid])
142
[self->currentEntity addProperty:self->currentProperty];
144
RELEASE(self->currentProperty); self->currentProperty = nil;
150
- (void)startDocument {
151
RELEASE(self->currentModel); self->currentModel = nil;
152
RELEASE(self->currentEntity); self->currentEntity = nil;
153
RELEASE(self->currentProperty); self->currentProperty = nil;
155
- (void)endDocument {
158
- (void)startElement:(NSString *)_localName
159
namespace:(NSString *)_ns
160
rawName:(NSString *)_rawName
161
attributes:(id<SaxAttributes>)_attrs
163
if ([_rawName isEqualToString:@"model"])
164
[self startModel:_attrs];
165
else if ([_rawName isEqualToString:@"entity"])
166
[self startEntity:_attrs];
167
else if ([_rawName isEqualToString:@"property"])
168
[self startProperty:_attrs];
170
- (void)endElement:(NSString *)_localName
171
namespace:(NSString *)_ns
172
rawName:(NSString *)_rawName
174
if ([_rawName isEqualToString:@"model"])
176
else if ([_rawName isEqualToString:@"entity"])
178
else if ([_rawName isEqualToString:@"property"])
182
@end /* WOXMLSaxModelHandler */