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 "WOHTMLDynamicElement.h"
23 #include "WOElement+private.h"
24 #include <NGObjWeb/WOResourceManager.h>
25 #include <NGObjWeb/WOApplication.h>
26 #include <NGObjWeb/WOxElemBuilder.h>
27 #include <DOM/DOMProtocols.h>
30 @interface WOEntity : WOHTMLDynamicElement
32 // WODynamicElement: extraAttributes
33 // WODynamicElement: otherTagString
40 @implementation WOEntity
42 - (id)initWithElement:(id<DOMElement>)_element
43 templateBuilder:(WOxElemBuilder *)_builder
46 NSMutableDictionary *assocs;
47 id<NSObject,DOMNamedNodeMap> attrs;
50 tname = [_element tagName];
52 /* construct associations */
55 attrs = [_element attributes];
56 if ((count = [attrs length]) > 0)
57 assocs = [_builder associationsForAttributes:attrs];
59 if ([tname isEqualToString:@"nbsp"]) {
62 a = [_builder associationForValue:@"nbsp"];
64 [assocs setObject:a forKey:@"name"];
66 assocs = [NSMutableDictionary dictionaryWithObject:a forKey:@"name"];
69 /* construct child elements */
71 if ([_element hasChildNodes]) {
72 [_builder logWithFormat:@"WARNING: element %@ has child-nodes (ignored)",
76 /* construct self ... */
77 self = [self initWithName:tname
80 [(id)self setExtraAttributes:assocs];
84 - (id)initWithName:(NSString *)_name
85 associations:(NSDictionary *)_config
86 template:(WOElement *)_tmpl
88 if ((self = [super initWithName:_name associations:_config template:_tmpl])) {
89 if ((self->name = OWGetProperty(_config, @"name")) == nil) {
90 NSLog(@"%s: missing 'name' binding for entity element %@ (assocs=%@)...",
91 __PRETTY_FUNCTION__, _name, _config);
99 #if !LIB_FOUNDATION_BOEHM_GC
106 // ******************** responder ********************
108 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
111 if ([[_ctx request] isFromClientComponent])
114 s = [self->name stringValueInComponent:[_ctx component]];
118 WOResponse_AddChar(_response, '&');
119 WOResponse_AddString(_response, s);
120 WOResponse_AddChar(_response, ';');
125 - (NSString *)associationDescription {
126 return [NSString stringWithFormat:@" name=%@", self->name];