2005-07-30 Helge Hess <helge.hess@opengroupware.org>
- * v.4.5.17
+ * DOMElement.m: evaluate KVC keys starting with a slash '/' as query
+ path expressions (by stripping of the slash!), return an attribute
+ node for keys starting with '@' (v4.5.18)
+
+ * v4.5.17
* DOMDocument.m: evaluate KVC keys starting with a slash '/' as query
path expressions
#include <DOM/DOMAttribute.h>
#include <DOM/DOMDocument.h>
#include <DOM/DOMNodeWalker.h>
+#include "DOMNode+QueryPath.h"
#include "common.h"
+
@interface _DOMElementAttrNamedNodeMap : NSObject < DOMNamedNodeMap >
{
NGDOMElement *element; /* non-retained */
return [self childNodes];
}
+/* key/value coding */
+
+- (id)valueForKey:(NSString *)_key {
+ if ([_key hasPrefix:@"/"])
+ return [self lookupQueryPath:[_key substringFromIndex:1]];
+
+ if ([_key hasPrefix:@"@"]) {
+ return [[self attributes] namedItem:[_key substringFromIndex:1]
+ namespaceURI:@"*"];
+ }
+
+ return [super valueForKey:_key];
+}
+
@end /* NGDOMElement */
+
+
@implementation _DOMElementAttrNamedNodeMap
- (id)initWithElement:(id)_element {
[ms appendString:@" attributes:\n"];
e = [self objectEnumerator];
- while ((attr = [e nextObject])) {
+ while ((attr = [e nextObject]) != nil) {
[ms appendString:[attr description]];
[ms appendString:@"\n"];
}
document./uid => DOMElement or array! matching 'uid'
document./uid.textValue => text-value of 'uid' element
+ element.@value.textValue => text-value of 'value' attribute of element
+ element./subnode.textValue => lookup subnode (strips of the /) using QP
+
Some info on classes ...
========================