From b4701267211de547fd512fdbb91147f1a8c95088 Mon Sep 17 00:00:00 2001
From: richard
-Callback on internal subset declaration.
+
+
+ Does this document have an internal subset?
-Does this document have an external subset.
+
+
+ Does this document have an external subset.
-Callback on internal subset declaration.
+
+
+ Callback on internal subset declaration.
+ Return YES if handled, NO if you want the parser to handle it.
-Callback on external subset declaration.
+
+
+ Callback on external subset declaration.
+ Return YES if handled, NO if you want the parser to handle it.
hasInternalSubset:
- (int) hasInternalSubset:;
-
+
+
hasExternalSubset:
- (int) hasExternalSubset:;
-
+
+
internalSubset:externalID:systemID:
-- (void) internalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
+- (BOOL) internalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
-
externalSubset:externalID:systemID:
-- (void) externalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
+- (BOOL) externalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
-
+ This method controls the loading of external entities into + the system. If it returns an empty string, the entity is not + loaded. If it returns a filename, the entity is loaded from + that file. If it returns nil, the default entity loading + mechanism is used. +
++ The default entity loading mechanism is to construct a file + name from the locationURL, by replacing all path separators + with underscores, then attempt to locate that file in the DTDs + resource directory of the main bundle, and all the standard + system locations. +
++ As a special case, the default loader examines the publicID + and if it is a GNUstep DTD, the loader constructs a special + name from the ID (by replacing dots with underscores and + spaces with hyphens) and looks for a file with that name + and a '.dtd' extension in the GNUstep bundles. +
++ NB. This method will only be called if there is no SAX + handler in use, or if the corresponding method in the + SAX handler returns nil. +
+Version: 0.1
-Date: 15 September, 2000
+Version: 0.2
+Date: 1 November, 2000
Declared in: GSXML.h
@@ -46,32 +46,71 @@+ + This method controls the loading of external entities into + the system. If it returns an empty string, the entity is not + loaded. If it returns a filename, the entity is loaded from + that file. If it returns nil, the default entity loading + mechanism is used. +
+ ++ + The default entity loading mechanism is to construct a file + name from the locationURL, by replacing all path separators + with underscores, then attempt to locate that file in the DTDs + resource directory of the main bundle, and all the standard + system locations. +
+ ++ + As a special case, the default loader examines the publicID + and if it is a GNUstep DTD, the loader constructs a special + name from the ID (by replacing dots with underscores and + spaces with hyphens) and looks for a file with that name + and a '.dtd' extension in the GNUstep bundles. +
+ ++ + NB. This method will only be called if there is no SAX + handler in use, or if the corresponding method in the + SAX handler returns nil. +
+ + +@@ -82,7 +121,7 @@
@@ -91,7 +130,7 @@ initWithSAXHandler:withContentsOfFile:
- example + exampleGSXMLParser *p = [GSXMLParser parserWithContentsOfFile: @"macos.xml"]; @@ -110,7 +149,7 @@
-parserWithContentsOfURL:
+parserWithContentsOfURL:
+ (GSXMLParser*) parserWithContentsOfURL: (NSURL*)url;
@@ -121,7 +160,7 @@
-parserWithData:
+parserWithData:
+ (GSXMLParser*) parserWithData: (NSData*)data;
@@ -131,7 +170,7 @@ Creation of a new Parser by calling
-parserWithSAXHandler:
+parserWithSAXHandler:
+ (GSXMlParser*) parserWithSAXHandler: (GSSAXHandler*)handler;
@@ -148,7 +187,7 @@ Creation of a new Parser by calling
-parserWithSAXHandler:withContentsOfFile:
+parserWithSAXHandler:withContentsOfFile:
+ (GSXMlParser*) parserWithSAXHandler: (GSSAXHandler*)handler withContentsOfFile: (NSString*)path;
@@ -157,7 +196,7 @@ Creation of a new Parser by calling initWithSAXHandler:withContentsOfFile:
- example + exampleNSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; @@ -177,7 +216,7 @@ Creation of a new Parser by calling
-parserWithSAXHandler:withContentsOfURL:
+parserWithSAXHandler:withContentsOfURL:
+ (GSXMlParser*) parserWithSAXHandler: (GSSAXHandler*)handler withContentsOfURL: (NSURL*)url;
@@ -188,7 +227,7 @@ Creation of a new Parser by calling
-parserWithSAXHandler:withData:
+parserWithSAXHandler:withData:
+ (GSXMlParser*) parserWithSAXHandler: (GSSAXHandler*)handler withData: (NSData*)data;
@@ -199,7 +238,7 @@ Creation of a new Parser by calling
-xmlEncodingStringForStringEncoding:
+xmlEncodingStringForStringEncoding:
+ (NSString*) xmlEncodingStringForStringEncoding: (NSStringEncoding)encoding;
Return the name of the string encoding (for XML) to use for the @@ -207,7 +246,7 @@ Creation of a new Parser by calling
Instances Methods
-initWithSAXHandler:
+initWithSAXHandler:
This is the designated initialiser
- (id) initWithSAXHandler: (GSSAXHandler*)handler;
@@ -232,7 +271,7 @@ Creation of a new Parser by calling
-initWithSAXHandler:withContentsOfFile:
+initWithSAXHandler:withContentsOfFile:
- (id) initWithSAXHandler: (GSSAXHandler*)handler withContentsOfFile: (NSString*)path;
@@ -250,7 +289,7 @@ Creation of a new Parser by calling
-initWithSAXHandler:withContentsOfURL:
+initWithSAXHandler:withContentsOfURL:
- (id) initWithSAXHandler: (GSSAXHandler*)handler withContentsOfURL: (NSURL*)url;
@@ -268,7 +307,7 @@ Creation of a new Parser by calling
-initWithSAXHandler:withData:
+initWithSAXHandler:withData:
- (id) initWithSAXHandler: (GSSAXHandler*)handler withData: (NSData*)data;
@@ -286,7 +325,7 @@ Creation of a new Parser by calling
-lib
+lib
- (void*) lib;
@@ -295,7 +334,7 @@ Return pointer to xmlParserCtxt structure.
-doc
+doc
- (GSXMLDocument*) doc;
@@ -305,7 +344,7 @@ Return pointer to xmlParserCtxt structure.
-parse
+parse
- (BOOL) parse;
@@ -314,7 +353,7 @@ Return pointer to xmlParserCtxt structure. This method should be called once to parse the entire document.
- example + exampleGSXMLParser *p = [GSXMLParser parserWithContentsOfFile:@"macos.xml"]; @@ -333,7 +372,7 @@ Return pointer to xmlParserCtxt structure.
-parse:
+parse:
- (BOOL) parse: (NSData*)data;
@@ -347,7 +386,7 @@ Return pointer to xmlParserCtxt structure. document was valid or not.
- example + exampleGSXMLParser *p = [GSXMLParser parserWithSAXHandler: nil source: nil]; @@ -368,7 +407,7 @@ Return pointer to xmlParserCtxt structure.
-substituteEntites:
+substituteEntites:
- (BOOL) substituteEntites: (BOOL)yesno;
@@ -380,7 +419,7 @@ Return pointer to xmlParserCtxt structure.
-keepBlanks:
+keepBlanks:
- (BOOL) keepBlanks: (BOOL)yesno;
@@ -393,12 +432,12 @@ Return pointer to xmlParserCtxt structure.
-getWarnings:
+getWarnings:
- (BOOL) getWarnings: (BOOL)yesno;
-doValidityChecking:
+doValidityChecking:
- (BOOL) doValidityChecking: (BOOL)yesno;
@@ -408,22 +447,12 @@ Return pointer to xmlParserCtxt structure.
-errNo
+errNo
- (int) errNo;
- Return error code. -
- - -
-setExternalEntityLoader
-- (void) setExternalEntityLoader (void*)function;
- -- - Set a external entity loader. + Return error code for last parse operation.
diff --git a/Headers/gnustep/base/GSXML.h b/Headers/gnustep/base/GSXML.h index ceb20ebbd..3030c729f 100644 --- a/Headers/gnustep/base/GSXML.h +++ b/Headers/gnustep/base/GSXML.h @@ -175,6 +175,8 @@ typedef xmlNsType GSXMLNamespaceType; void *lib; /* parser context */ GSSAXHandler *saxHandler; } ++ (NSString*) loadEntity: (NSString*)publicId + at: (NSString*)locationURL; + (GSXMLParser*) parser; + (GSXMLParser*) parserWithContentsOfFile: (NSString*)path; + (GSXMLParser*) parserWithContentsOfURL: (NSURL*)url; diff --git a/Source/GSXML.m b/Source/GSXML.m index 5bbb15470..145b01689 100644 --- a/Source/GSXML.m +++ b/Source/GSXML.m @@ -849,6 +849,12 @@ static NSString *endMarker = @"At end of incremental parse"; xmlSetExternalEntityLoader((xmlExternalEntityLoader)loadEntityFunction); } ++ (NSString*) loadEntity: (NSString*)publicId + at: (NSString*)location +{ + return nil; +} + + (GSXMLParser*) parser { return AUTORELEASE([[self alloc] initWithSAXHandler: nil]); @@ -1297,6 +1303,10 @@ loadEntityFunction(const char *url, const char *eid, xmlParserCtxtPtr *ctx) * Now ask the SAXHandler callback for the name of a local file */ file = [HANDLER loadEntity: entityId at: location]; + if (file == nil) + { + file = [GSXMLParser loadEntity: entityId at: location]; + } if (file == nil) {