2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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
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.
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
22 #include <NGObjWeb/WOMessage.h>
25 @interface NSObject(DOMXML)
26 - (void)outputDocument:(id)_document to:(id)_target;
27 - (id)buildFromData:(NSData *)_data;
28 - (id)documentElement;
29 - (void)appendChild:(id)_child;
32 @implementation WOMessage(XMLSupport)
34 - (void)_rebuildDOMDataContent {
40 if ((dom = self->domCache) == nil) {
41 [self setContent:nil];
46 [[[NSClassFromString(@"DOMXMLOutputter") alloc] init] autorelease];
48 ms = [NSMutableString stringWithCapacity:2048];
49 [outputter outputDocument:dom to:ms];
51 data = [ms dataUsingEncoding:NSUTF8StringEncoding];
53 [self setContent:data];
56 - (void)setContentDOMDocument:(id)_dom {
57 ASSIGN(self->domCache, _dom);
58 [self _rebuildDOMDataContent];
61 - (void)appendContentDOMDocumentFragment:(id)_domfrag {
67 if ((dom = [self contentAsDOMDocument])) {
68 [[dom documentElement] appendChild:_domfrag];
69 [self setContentDOMDocument:dom];
72 [self setContentDOMDocument:_domfrag];
76 - (id)contentAsDOMDocument {
80 if ((dom = self->domCache) != nil)
83 if ((data = [self content]) != nil) {
86 builder = [[[NSClassFromString(@"DOMSaxBuilder") alloc] init] autorelease];
87 dom = [[builder buildFromData:data] retain];
90 /* cache DOM structure */
92 ASSIGN(self->domCache, dom);