mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-24 01:11:01 +00:00
support creating PI and Comment nodes; implemented attributes method in NSXMLElement
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34520 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e395d2f42a
commit
d43aa730a1
2 changed files with 21 additions and 7 deletions
|
@ -35,6 +35,9 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
@interface NSXMLNode (Private)
|
||||
- (void *) _node;
|
||||
- (void) _setNode: (void *)_anode;
|
||||
+ (NSXMLNode *) _objectForNode: (xmlNodePtr)node;
|
||||
- (void) _addSubNode:(NSXMLNode *)subNode;
|
||||
- (void) _removeSubNode:(NSXMLNode *)subNode;
|
||||
@end
|
||||
|
||||
@implementation NSXMLElement
|
||||
|
@ -166,8 +169,16 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
|
||||
- (NSArray*) attributes
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
return nil; // [internal->attributes allValues];
|
||||
NSMutableArray *attributes = [NSMutableArray array];
|
||||
xmlNodePtr node = MY_NODE;
|
||||
struct _xmlAttr * attributeNode = node->properties;
|
||||
while (attributeNode)
|
||||
{
|
||||
NSXMLNode *attribute = [NSXMLNode _objectForNode:(xmlNodePtr)attributeNode];
|
||||
[attributes addObject:attribute];
|
||||
attributeNode = attributeNode->next;
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
- (NSXMLNode*) attributeForName: (NSString*)name
|
||||
|
|
|
@ -57,7 +57,8 @@ void clearPrivatePointers(xmlNodePtr aNode)
|
|||
|
||||
- (void) _setNode: (void *)_anode
|
||||
{
|
||||
((xmlNodePtr)_anode)->_private = self;
|
||||
if (_anode)
|
||||
((xmlNodePtr)_anode)->_private = self;
|
||||
internal->node = _anode;
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,6 @@ void clearPrivatePointers(xmlNodePtr aNode)
|
|||
if (node)
|
||||
{
|
||||
xmlElementType type = node->type;
|
||||
xmlChar *name = NULL;
|
||||
// NSXMLNodeKind kind = 0;
|
||||
result = node->_private;
|
||||
|
||||
|
@ -78,15 +78,18 @@ void clearPrivatePointers(xmlNodePtr aNode)
|
|||
switch(type)
|
||||
{
|
||||
case(XML_DOCUMENT_NODE):
|
||||
name = (xmlChar *)node->name;
|
||||
result = [[self alloc] initWithKind: NSXMLDocumentKind];
|
||||
break;
|
||||
case(XML_ELEMENT_NODE):
|
||||
name = (xmlChar *)node->name;
|
||||
result = [[self alloc] initWithKind: NSXMLElementKind];
|
||||
break;
|
||||
case(XML_PI_NODE):
|
||||
result = [[self alloc] initWithKind: NSXMLProcessingInstructionKind];
|
||||
break;
|
||||
case(XML_COMMENT_NODE):
|
||||
result = [[self alloc] initWithKind: NSXMLCommentKind];
|
||||
break;
|
||||
case(XML_ATTRIBUTE_NODE):
|
||||
name = (xmlChar *)node->name;
|
||||
result = [[self alloc] initWithKind: NSXMLAttributeKind];
|
||||
[result setStringValue: StringFromXMLStringPtr(node->content)];
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue