Content output fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16326 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-04-02 04:51:54 +00:00
parent 8bbf670347
commit 6ffdcc0e32
2 changed files with 55 additions and 7 deletions

View file

@ -1,4 +1,9 @@
2003-04-01 Richard Frith-Macdonald <rfm@gnu.org>
22003-04-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSXML.m: ([-content]) fix to produce string
content of elements rather than just text nodes.
22003-04-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendarDate.m: ([initWithString:calendarFormat:locale:])
add support for %F millisecond initialisation.

View file

@ -812,18 +812,61 @@ static NSMapTable *nodeNames = 0;
}
/**
* Return node content as a string.
* Return node content as a string. This should return meaningful
* information for text nodes and for entity nodes containing only
* text nodes.<br />
* If entity substitution was not enabled during parsing, an
* element containing text may actually contain both text nodes and
* entity reference nodes, in this case you should not use this
* method to get the content of the element, but should examine
* the child nodes of the element individually and perform any
* entity reference you need to do explicitly.
*/
- (NSString*) content
{
if (lib != NULL && ((xmlNodePtr)lib)->content!=NULL)
{
return UTF8Str(((xmlNodePtr)lib)->content);
}
else
xmlNodePtr ptr = (xmlNodePtr)lib;
if (ptr == NULL)
{
return nil;
}
if (ptr->content != NULL)
{
return UTF8Str(ptr->content);
}
if ((int)ptr->type == XML_TEXT_NODE)
{
return @"";
}
else if ((int)ptr->type == XML_ELEMENT_NODE)
{
ptr = ptr->children;
if (ptr != NULL)
{
if (ptr->next == NULL)
{
if (ptr->content != NULL)
{
return UTF8Str(ptr->content);
}
}
else
{
NSMutableString *m = [NSMutableString new];
while (ptr != NULL)
{
if (ptr->content != NULL)
{
[m appendString: UTF8Str(ptr->content)];
}
ptr = ptr->next;
}
return AUTORELEASE(m);
}
}
}
return nil;
}
- (void) dealloc