2009-02-09 16:16:11 +00:00
|
|
|
/* Implementation for NSXMLDTDNode for GNUStep
|
|
|
|
Copyright (C) 2008 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
Created: September 2008
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 3 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2019-12-09 23:36:00 +00:00
|
|
|
Lesser General Public License for more details.
|
2009-02-09 16:16:11 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2019-12-09 23:36:00 +00:00
|
|
|
Boston, MA 02110 USA.
|
2009-02-09 16:16:11 +00:00
|
|
|
*/
|
|
|
|
|
2010-02-19 08:12:46 +00:00
|
|
|
#import "common.h"
|
|
|
|
|
2012-03-21 08:00:33 +00:00
|
|
|
#if defined(HAVE_LIBXML)
|
|
|
|
|
2012-03-12 13:27:32 +00:00
|
|
|
#define GSInternal NSXMLDTDNodeInternal
|
|
|
|
|
2012-01-05 20:40:12 +00:00
|
|
|
#import "NSXMLPrivate.h"
|
|
|
|
#import "GSInternal.h"
|
2012-01-04 12:41:45 +00:00
|
|
|
GS_PRIVATE_INTERNAL(NSXMLDTDNode)
|
|
|
|
|
2009-02-09 16:16:11 +00:00
|
|
|
@implementation NSXMLDTDNode
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2012-01-04 12:41:45 +00:00
|
|
|
if (GS_EXISTS_INTERNAL)
|
|
|
|
{
|
|
|
|
}
|
2009-02-09 16:16:11 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSXMLDTDNodeKind) DTDKind
|
|
|
|
{
|
2012-01-04 12:41:45 +00:00
|
|
|
return internal->DTDKind;
|
|
|
|
}
|
|
|
|
|
2012-03-04 21:40:39 +00:00
|
|
|
- (void) _createInternal
|
|
|
|
{
|
|
|
|
GS_CREATE_INTERNAL(NSXMLDTDNode);
|
|
|
|
}
|
|
|
|
|
2012-04-06 22:27:55 +00:00
|
|
|
- (id) initWithKind: (NSXMLNodeKind)theKind options: (NSUInteger)theOptions
|
2012-01-04 12:41:45 +00:00
|
|
|
{
|
2012-04-06 22:27:55 +00:00
|
|
|
if (NSXMLEntityDeclarationKind == theKind
|
|
|
|
|| NSXMLElementDeclarationKind == theKind
|
|
|
|
|| NSXMLNotationDeclarationKind == theKind)
|
2012-03-04 21:40:39 +00:00
|
|
|
{
|
2012-04-06 22:27:55 +00:00
|
|
|
return [super initWithKind: theKind options: theOptions];
|
2012-03-04 21:40:39 +00:00
|
|
|
}
|
|
|
|
else
|
2012-01-04 12:41:45 +00:00
|
|
|
{
|
2012-03-04 21:40:39 +00:00
|
|
|
[self release];
|
2012-04-06 22:27:55 +00:00
|
|
|
// This cast is here to keep clang quite that expects an init* method to
|
|
|
|
// return an object of the same class, which is not true here.
|
|
|
|
return (NSXMLDTDNode*)[[NSXMLNode alloc] initWithKind: theKind
|
|
|
|
options: theOptions];
|
2012-01-04 12:41:45 +00:00
|
|
|
}
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithXMLString: (NSString*)string
|
|
|
|
{
|
2012-03-18 12:20:29 +00:00
|
|
|
NSXMLDTDNode *result = nil;
|
|
|
|
NSError *error;
|
|
|
|
NSXMLDocument *tempDoc =
|
|
|
|
[[NSXMLDocument alloc] initWithXMLString: string
|
|
|
|
options: 0
|
|
|
|
error: &error];
|
|
|
|
if (tempDoc != nil)
|
|
|
|
{
|
2012-04-06 22:27:55 +00:00
|
|
|
result = (NSXMLDTDNode*)RETAIN([tempDoc childAtIndex: 0]);
|
2012-03-18 12:20:29 +00:00
|
|
|
[result detach]; // detach from document.
|
|
|
|
}
|
|
|
|
[tempDoc release];
|
|
|
|
[self release];
|
2012-02-22 10:55:12 +00:00
|
|
|
|
2012-03-18 12:20:29 +00:00
|
|
|
return result;
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isExternal
|
|
|
|
{
|
2012-02-20 03:40:15 +00:00
|
|
|
if ([self systemID])
|
2009-02-09 16:16:11 +00:00
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) notationName
|
|
|
|
{
|
2018-03-20 17:44:16 +00:00
|
|
|
return StringFromXMLStringPtr(internal->node.entity->name);
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) publicID
|
|
|
|
{
|
2018-03-20 17:44:16 +00:00
|
|
|
return StringFromXMLStringPtr(internal->node.entity->ExternalID);
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 10:45:30 +00:00
|
|
|
- (void) setDTDKind: (NSXMLDTDNodeKind)nodeKind
|
2009-02-09 16:16:11 +00:00
|
|
|
{
|
2012-04-07 10:45:30 +00:00
|
|
|
internal->DTDKind = nodeKind;
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setNotationName: (NSString*)notationName
|
|
|
|
{
|
2018-03-20 17:44:16 +00:00
|
|
|
internal->node.entity->name = XMLSTRING(notationName);
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setPublicID: (NSString*)publicID
|
|
|
|
{
|
2018-03-20 17:44:16 +00:00
|
|
|
internal->node.entity->ExternalID = XMLSTRING(publicID);
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSystemID: (NSString*)systemID
|
|
|
|
{
|
2018-03-20 17:44:16 +00:00
|
|
|
internal->node.entity->ExternalID = XMLSTRING(systemID);
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) systemID
|
|
|
|
{
|
2018-03-20 17:44:16 +00:00
|
|
|
return StringFromXMLStringPtr(internal->node.entity->SystemID);
|
2009-02-09 16:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2012-03-21 08:00:33 +00:00
|
|
|
#endif /* HAVE_LIBXML */
|