2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
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
23 #include <NGObjDOM/ODRGenericTag.h>
26 @implementation ODRGenericTag
28 - (void)_appendAttributesOfNode:(id)_domNode
29 toResponse:(WOResponse *)_response
30 inContext:(WOContext *)_ctx
34 NSString *nsuri, *prefix;
36 prefix = [_domNode prefix];
37 nsuri = [_domNode namespaceURI];
39 if ([nsuri length] > 0) {
45 if ((parentNode = [_domNode parentNode])) {
46 if ([parentNode nodeType] == DOM_ELEMENT_NODE) {
47 if ([[parentNode namespaceURI] isEqualToString:nsuri]) {
50 pp = [parentNode prefix];
52 if ((pp == nil) && (prefix == nil))
54 else if ([pp isEqualToString:prefix])
61 [_response appendContentString:@" xmlns"];
62 if ([prefix length] > 0) {
63 [_response appendContentString:@":"];
64 [_response appendContentString:prefix];
66 [_response appendContentString:@"='"];
67 [_response appendContentString:nsuri];
68 [_response appendContentString:@"'"];
72 if ((attrs = [(id)[_domNode attributes] objectEnumerator]) == nil)
75 while ((attr = [attrs nextObject])) {
76 NSString *attrURI = nil;
77 NSString *attrName = nil;
79 attrURI = [attr namespaceURI];
80 if ([attrURI length] > 0) {
81 if ([attrURI isEqualToString:nsuri]) {
82 if ([prefix length] > 0)
83 attrName = [NSString stringWithFormat:@"%@:%@", prefix, [attr name]];
85 attrName = [attr name];
88 /* different namespace */
89 NSLog(@"WARNING(%s): tag '%@'(ns=%@) different namespace %@ ..",
91 [_domNode tagName], [_domNode namespaceURI], attrURI);
95 attrName = [attr name];
97 [_response appendContentString:@" "];
98 [_response appendContentString:attrName];
99 [_response appendContentString:@"='"];
100 [_response appendContentHTMLAttributeValue:[attr value]];
101 [_response appendContentString:@"'"];
105 - (void)appendNode:(id)_domNode
106 toResponse:(WOResponse *)_response
107 inContext:(WOContext *)_context
109 if ([_domNode nodeType] != DOM_ELEMENT_NODE) {
110 [super appendNode:_domNode toResponse:_response inContext:_context];
114 [_response appendContentString:@"<"];
115 if ([[_domNode prefix] length] > 0) {
116 [_response appendContentString:[_domNode prefix]];
117 [_response appendContentString:@":"];
119 [_response appendContentString:[_domNode tagName]];
121 [self _appendAttributesOfNode:_domNode
125 if (![_domNode hasChildNodes]) {
126 [_response appendContentString:@" />"];
129 [_response appendContentString:@">"];
132 [self appendChildNodes:[_domNode childNodes]
136 [_response appendContentString:@"</"];
137 if ([[_domNode prefix] length] > 0) {
138 [_response appendContentString:[_domNode prefix]];
139 [_response appendContentString:@":"];
141 [_response appendContentString:[_domNode tagName]];
142 [_response appendContentString:@">"];
146 @end /* ODRGenericTag */