mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
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:
parent
c77a751c49
commit
375795ad52
2 changed files with 55 additions and 7 deletions
|
@ -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:])
|
* Source/NSCalendarDate.m: ([initWithString:calendarFormat:locale:])
|
||||||
add support for %F millisecond initialisation.
|
add support for %F millisecond initialisation.
|
||||||
|
|
|
@ -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
|
- (NSString*) content
|
||||||
{
|
{
|
||||||
if (lib != NULL && ((xmlNodePtr)lib)->content!=NULL)
|
xmlNodePtr ptr = (xmlNodePtr)lib;
|
||||||
{
|
|
||||||
return UTF8Str(((xmlNodePtr)lib)->content);
|
if (ptr == NULL)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return nil;
|
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
|
- (void) dealloc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue