[Previous] [Up] [Next]

GSXMLParser

Authors

Michael Pakhantsov
Richard Frith-Macdonald

Version: 0.1

Date: 15 September, 2000

GSXMLParser

GSXMLParser

Declared in: GSXML.h

Inherits from: NSObject


XML Parser.

Instance Variables

Methods


Class Methods

parser:

+ (GSXMLParser*) parser: (id)source;

Creation of a new Parser by calling initWithSAXHandler:source:

Source must be NSString or NSData.

example

  GSXMLParser       *p = [GSXMLParser parser:@"macos.xml"];

  if ([p parse])
    {
      [[p doc] dump];
    }
  else
    {
      printf("error parse file\n");
    }

            

parserWithSAXHandler:source:

+ (GSXMlParser*) parserWithSAXHandler: (GSSAXHandler*)handler source: (id)source;

Creation of a new Parser by calling initWithSAXHandler:source:

example

  NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
  GSSAXHandler *h = [GSDebugSAXHandler handler];
  GSXMLParser       *p = [GSXMLParser parserWithSAXHandler: h
						    source: @"macos.xml"];

  if ([p parse])
    {
       printf("ok\n");
    }


  [arp release];
            

xmlEncodingStringForStringEncoding:

+ (NSString*) xmlEncodingStringForStringEncoding: (NSStringEncoding)encoding;
Return the name of the string encoding (for XML) to use for the specified OpenStep encoding.

Instances Methods

initWithSAXHandler:source:

This is the designated initialiser
- (id) initWithSAXHandler: (GSSAXHandler*)handler source: (id)source;

Initialisation of a new Parser with SAX handler (if not nil).

The source object is intended to be any reasonable value, but for initial implementation may be an NSData object containing raw XML text, or the name of a file to parse.

Future options are intended to include NSURL objects, and nil objects (for incremental (data push) operation.


lib

- (void*) lib;

Return pointer to xmlParserCtxt structure.


doc

- (GSXMLDocument*) doc;

Return GSXMLDocument object.


parse

- (BOOL) parse;

Parse source. Return YES if parsed, otherwise NO.

example

  GSXMLParser       *p = [GSXMLParser parser:@"macos.xml"];

  if ([p parse])
    {
      [[p doc] dump];
    }
  else
    {
      printf("error parse file\n");
    }

            

substituteEntites:

- (BOOL) substituteEntites: (BOOL)yesno;

Set and return the previous value for default entity support. Initially the parser always keep entity references instead of substituting entity values in the output.


keepBlanks:

- (BOOL) keepBlanks: (BOOL)yesno;

Set and return the previous value for default blanks text nodes support. ignorableWhitespace() are only generated when running the parser in validating mode and when the current element doesn't allow CDATA or mixed content.


getWarnings:

- (BOOL) getWarnings: (BOOL)yesno;

doValidityChecking:

- (BOOL) doValidityChecking: (BOOL)yesno;

Sets whether the document needs to be validated.


errNo

- (int) errNo;

Return error code.


setExternalEntityLoader

- (void) setExternalEntityLoader (void*)function;

Set a external entity loader.