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 "DOMAttribute.h"
23 #include "DOMDocument.h"
26 @implementation NGDOMAttribute
28 - (id)initWithName:(NSString *)_name namespaceURI:(NSString *)_uri {
29 if ((self = [super init])) {
30 self->name = [_name copy];
31 self->namespaceURI = [_uri copy];
36 - (id)initWithName:(NSString *)_name {
37 return [self initWithName:_name namespaceURI:nil];
41 [self->prefix release];
43 [self->namespaceURI release];
47 /* element tracking */
49 - (void)_domNodeRegisterParentNode:(id)_element {
50 self->element = _element;
52 - (void)_domNodeForgetParentNode:(id)_element {
53 if (_element == self->element)
59 - (IDOMElement)ownerElement {
62 - (IDOMDocument)ownerDocument {
63 return [[self ownerElement] ownerDocument];
67 return self->isSpecified;
74 - (NSString *)namespaceURI {
75 return self->namespaceURI;
78 - (void)setPrefix:(NSString *)_prefix {
79 id old = self->prefix;
80 self->prefix = [_prefix copy];
83 - (NSString *)prefix {
87 - (void)setValue:(NSString *)_value {
90 self->isSpecified = YES;
92 /* remove all existing children */
93 while ((child = [self lastChild]))
94 [self removeChild:child];
96 child = [[self ownerDocument] createTextNode:_value];
97 NSAssert1(child, @"couldn't create text-node child for value '%@' !", _value);
99 [self appendChild:child];
102 - (NSString *)_stringValueOfChildNode:(id)_node {
103 return [_node nodeValue];
105 - (NSString *)value {
109 if (![self hasChildNodes])
112 children = [self childNodes];
113 if ((count = [children count]) == 0)
117 return [self _stringValueOfChildNode:[children objectAtIndex:0]];
123 s = [NSMutableString stringWithCapacity:256];
124 for (i = 0; i < count; i++) {
126 [self _stringValueOfChildNode:[children objectAtIndex:i]]];
128 return [[s copy] autorelease];
134 - (BOOL)_isValidChildNode:(id)_node {
135 switch ([_node nodeType]) {
137 case DOM_ENTITY_REFERENCE_NODE:
145 - (DOMNodeType)nodeType {
146 return DOM_ATTRIBUTE_NODE;
149 - (id<NSObject,DOMNamedNodeMap>)attributes {
153 - (id<NSObject,DOMNode>)parentNode {
156 - (id<NSObject,DOMNode>)nextSibling {
159 - (id<NSObject,DOMNode>)previousSibling {
165 - (NSString *)description {
166 return [NSString stringWithFormat:@"<0x%08X[%@]: {%@}%@%s '%@'>",
167 self, NSStringFromClass([self class]),
170 [self specified] ? " specified" : "",
176 - (NSString *)stringValue {
180 return [[self stringValue] intValue];
182 - (double)doubleValue {
183 return [[self stringValue] doubleValue];
188 - (NSException *)setQueryPathValue:(id)_value {
189 [self setValue:[_value stringValue]];
192 - (id)queryPathValue {
196 @end /* NGDOMAttribute */