From b4701267211de547fd512fdbb91147f1a8c95088 Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 1 Nov 2000 17:14:55 +0000 Subject: [PATCH] Tdied xml stuff git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7984 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 ++ Documentation/gsdoc/GSSAXHandler.html | 38 +++++-- Documentation/gsdoc/GSXMLParser.gsdoc | 35 ++++++ Documentation/gsdoc/GSXMLParser.html | 153 +++++++++++++++----------- Headers/gnustep/base/GSXML.h | 2 + Source/GSXML.m | 10 ++ 6 files changed, 173 insertions(+), 72 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0cd296c8a..f060028e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-11-01 Richard Frith-Macdonald + + * Source/GSXML.m: External entity loader revisions completed. + * Documentation/gsdoc/GSXML.gsdoc: changes to api + * Documentation/gsdoc/GSXMLParser.gsdoc: ditto + * Documentation/gsdoc/GSSAXHandler.gsdoc: ditto + 2000-11-01 Manuel Guesdon * Headers/Foundation/GSXML.h: added GSXMLNode propertiesAsDictionaryWithKeyTransformationSel: diff --git a/Documentation/gsdoc/GSSAXHandler.html b/Documentation/gsdoc/GSSAXHandler.html index 54534df58..8ba80cbef 100644 --- a/Documentation/gsdoc/GSSAXHandler.html +++ b/Documentation/gsdoc/GSSAXHandler.html @@ -255,35 +255,53 @@ Called when found a warning.

hasInternalSubset:

- (int) hasInternalSubset:;
-

-Callback on internal subset declaration. +

+ + Does this document have an internal subset?

+
    +
  • Return 1 for yes +
  • Return 0 for no +
  • Return -1 for don't know (let parser decide) +
+

hasExternalSubset:

- (int) hasExternalSubset:;
-

-Does this document have an external subset. +

+ + Does this document have an external subset.

+
    +
  • Return 1 for yes +
  • Return 0 for no +
  • Return -1 for don't know (let parser decide) +
+

internalSubset:externalID:systemID:

-- (void) internalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
+- (BOOL) internalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
-

-Callback on internal subset declaration. +

+ + Callback on internal subset declaration. + Return YES if handled, NO if you want the parser to handle it.


externalSubset:externalID:systemID:

-- (void) externalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
+- (BOOL) externalSubset: (NSString*)name externalID: (NSString*)externalID systemID: (NSString*)systemID;
-

-Callback on external subset declaration. +

+ + Callback on external subset declaration. + Return YES if handled, NO if you want the parser to handle it.

diff --git a/Documentation/gsdoc/GSXMLParser.gsdoc b/Documentation/gsdoc/GSXMLParser.gsdoc index 040dd06c0..0921318ba 100644 --- a/Documentation/gsdoc/GSXMLParser.gsdoc +++ b/Documentation/gsdoc/GSXMLParser.gsdoc @@ -36,6 +36,41 @@

+ + loadEntity: + publicID + at: + locationURL + +

+ 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. +

+
+
+ parser diff --git a/Documentation/gsdoc/GSXMLParser.html b/Documentation/gsdoc/GSXMLParser.html index b62d5681b..c898ff08c 100644 --- a/Documentation/gsdoc/GSXMLParser.html +++ b/Documentation/gsdoc/GSXMLParser.html @@ -13,8 +13,8 @@
Richard Frith-Macdonald
-

Version: 0.1

-

Date: 15 September, 2000

+

Version: 0.2

+

Date: 1 November, 2000

GSXMLParser

GSXMLParser

Declared in: GSXML.h

@@ -46,32 +46,71 @@

Methods


Class Methods

-

parser

+

loadEntity:at:

++ (NSString*) loadEntity: (NSString*)publicID at: (NSString*)locationURL;
+ +

+ + 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. +

+ + +
+

parser

+ (GSXMLParser*) parser;

@@ -82,7 +121,7 @@


-

parserWithContentsOfFile:

+

parserWithContentsOfFile:

+ (GSXMLParser*) parserWithContentsOfFile: (NSString*)path;

@@ -91,7 +130,7 @@ initWithSAXHandler:withContentsOfFile:

- example + example
 
   GSXMLParser       *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 + example
 
   NSAutoreleasePool *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 + example
 
   GSXMLParser       *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 + example
 
   GSXMLParser       *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) {