mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fix the setRootElement: method
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34610 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
49b12261cd
commit
b34c744c20
1 changed files with 7 additions and 9 deletions
|
@ -167,14 +167,16 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
const char *str = [string UTF8String];
|
||||
char *url = NULL;
|
||||
char *encoding = NULL; // "UTF8";
|
||||
int options = 0;
|
||||
int options = XML_PARSE_NOERROR;
|
||||
if (!(mask & NSXMLNodePreserveWhitespace))
|
||||
options |= XML_PARSE_NOBLANKS;
|
||||
|
||||
//xmlKeepBlanksDefault(0);
|
||||
GS_CREATE_INTERNAL(NSXMLDocument); // create internal ivars...
|
||||
internal->node = xmlReadDoc((xmlChar *)str, url, encoding, options);
|
||||
if(internal->node == NULL)
|
||||
{
|
||||
[self release];
|
||||
self = nil;
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Cannot instantiate NSXMLDocument with invalid data"];
|
||||
}
|
||||
|
@ -223,8 +225,6 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
|
||||
- (void) setRootElement: (NSXMLNode*)root
|
||||
{
|
||||
// #warning properly dispose of old root element.
|
||||
xmlNodePtr newrootnode;
|
||||
id oldElement = [self rootElement];
|
||||
|
||||
if(root == nil)
|
||||
|
@ -233,12 +233,10 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
}
|
||||
|
||||
xmlDocSetRootElement(MY_DOC,[root _node]);
|
||||
newrootnode = MY_DOC->children;
|
||||
newrootnode->_private = root; // hmmm, this probably isn't where this belongs, but try it...
|
||||
|
||||
// Get rid of old element...
|
||||
// xmlFree([oldElement _node]);
|
||||
oldElement = nil; // is this correct??
|
||||
// Do our subNode housekeeping...
|
||||
[self _removeSubNode:oldElement];
|
||||
[self _addSubNode:root];
|
||||
}
|
||||
|
||||
- (void) setStandalone: (BOOL)standalone
|
||||
|
|
Loading…
Reference in a new issue