iVarious minor mods

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7556 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-09-20 06:45:02 +00:00
parent de28cb4db3
commit ac43d3d1ca
7 changed files with 291 additions and 135 deletions

View file

@ -1,9 +1,20 @@
2000-09-20 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/gnustep/base/GSXML.h: Added ([-parser:]) and removed
redundant 'length' info from callbacks.
* Source/GSXML.m: Added ([-parser:]), tidied ([-parser]), fixed
scope of functions, and removed redundant 'length' info from callbacks.
* Documenttion/gsdoc/GSXMLParser.gsdoc: document ([-parser:])
* Documentation/gsdoc/GSSAXHandler.gsdoc: update for removal of
redundant 'length' info on some callbacks.
2000-09-19 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/gnustep/base/GSXML.h:
* Source/GSXML.m: Revert to earlier version to remove
formatting/coding-standards errors and complexity adding
api additions. Continued integration of Michael Pakhantsovs code.
formatting/coding-standards errors, broken GSSAXHandler class,
and complexity adding api additions.
Continued integration of Michael Pakhantsovs code.
Added Manuels +xmlEncodingStringForStringEncoding with tidying.
Added Manuels -typeDescription with rewrite for performance.
* Documenttion/gsdoc/GSXMLParser.gsdoc:

View file

@ -20,11 +20,20 @@
<declared>GSXML.h</declared>
<desc>
<p>XML SAX Handler.</p>
<p>SAX is a callback-based interface to the XML parser.</p>
<p>
You can debug the SAX behaviour by using the GSDebugSAXHandler
class. Here is the sequence of callbacks that would be
reported when parsing the example XML document shown earlier.
GSSAXHandler is a callback-based interface to the XML parser
that operates in a similar (though not identical) manner to
SAX.
</p>
<p>
Each GSSAXHandler object is associated with a GSXMLParser
object. As parsing progresses, the mathods of the GSSAXHandler
are invoked by the parser, so the handler is able to deal
with the elements and entities being parsed.
</p>
<p>
The callback methods in the GSSAXHandler class do nothing - it
is intended that you subclass GSSAXHandler and override them.
</p>
</desc>
@ -87,17 +96,16 @@
<sel>attributes:</sel>
<arg type="NSMutableDictionary*">elementAttributes</arg>
<desc>
<p>Called when an opening tag has been processed.
<p>Called when an opening tag has been processed.
</p>
</desc>
</method>
<method type="void">
<sel>endElement</sel>
<arg type="NSString*">elementName</arg>
<desc>
<p>Called when the end of an element has been detected.
<p>Called when the end of an element has been detected.
</p>
</desc>
</method>
@ -108,7 +116,7 @@
<sel>value:</sel>
<arg type="NSString*">value</arg>
<desc>
<p>Handle an attribute that has been read by the parser.
<p>Handle an attribute that has been read by the parser.
</p>
</desc>
</method>
@ -116,10 +124,8 @@
<method type="void">
<sel>characters:</sel>
<arg type="NSString*">name</arg>
<sel>length:</sel>
<arg type="int">len</arg>
<desc>
<p>Receiving some chars from the parser.
<p>Receiving some chars from the parser.
</p>
</desc>
</method>
@ -127,8 +133,6 @@
<method type="void">
<sel>ignoreWhitespace:</sel>
<arg type="NSString*">ch</arg>
<sel>length:</sel>
<arg type="int">length</arg>
<desc>
<p>Receiving some ignorable whitespaces from the parser.
</p>
@ -141,7 +145,7 @@
<sel>value:</sel>
<arg type="NSString*">PIData</arg>
<desc>
<p>A processing instruction has been parsed.
<p>A processing instruction has been parsed.
</p>
</desc>
</method>
@ -150,7 +154,7 @@
<sel>comment:</sel>
<arg type="NSString*">value</arg>
<desc>
<p>A comment has been parsed.
<p>A comment has been parsed.
</p>
</desc>
</method>
@ -158,8 +162,6 @@
<method type="void">
<sel>cdataBlock:</sel>
<arg type="NSString*">value</arg>
<sel>length:</sel>
<arg type="int">length</arg>
<desc>
<p>Called when a pcdata block has been parsed.
</p>

View file

@ -17,20 +17,31 @@
<h2><a name="cont-0">GSSAXHandler</a></h2>
<h2><a name="GSSAXHandler">GSSAXHandler</a></h2>
<p><b>Declared in:</b> GSXML.h</p>
<p><b>Inherits from:</b> <A HREF="NSObject.html#NSObject">NSObject</A></p>
<p><b>Inherits from:</b> NSObject</p>
<hr>
<p>
XML SAX Handler.</p>
<p>
SAX is a callback-based interface to the XML parser.</p>
GSSAXHandler is a callback-based interface to the XML parser
that operates in a similar (though not identical) manner to
SAX.
</p>
<p>
You can debug the SAX behaviour by using the GSDebugSAXHandler
class. Here is the sequence of callbacks that would be
reported when parsing the example XML document shown earlier.
Each GSSAXHandler object is associated with a GSXMLParser
object. As parsing progresses, the mathods of the GSSAXHandler
are invoked by the parser, so the handler is able to deal
with the elements and entities being parsed.
</p>
<p>
The callback methods in the GSSAXHandler class do nothing - it
is intended that you subclass GSSAXHandler and override them.
</p>
@ -42,8 +53,8 @@ SAX is a callback-based interface to the XML parser.</p>
<li><a href="GSSAXHandler.html#method-0">+handler</a>
<li><a href="GSSAXHandler.html#method-8">-attribute:value:</a>
<li><a href="GSSAXHandler.html#method-27">-attributeDecl:name:type:typeDefValue:defaultValue:</a>
<li><a href="GSSAXHandler.html#method-13">-cdataBlock:length:</a>
<li><a href="GSSAXHandler.html#method-9">-characters:length:</a>
<li><a href="GSSAXHandler.html#method-13">-cdataBlock:</a>
<li><a href="GSSAXHandler.html#method-9">-characters:</a>
<li><a href="GSSAXHandler.html#method-12">-comment:</a>
<li><a href="GSSAXHandler.html#method-28">-elementDecl:type:</a>
<li><a href="GSSAXHandler.html#method-4">-endDocument</a>
@ -56,7 +67,7 @@ SAX is a callback-based interface to the XML parser.</p>
<li><a href="GSSAXHandler.html#method-14">-globalNamespace:href:prefix:</a>
<li><a href="GSSAXHandler.html#method-19">-hasExternalSubset:</a>
<li><a href="GSSAXHandler.html#method-18">-hasInternalSubset:</a>
<li><a href="GSSAXHandler.html#method-10">-ignoreWhitespace:length:</a>
<li><a href="GSSAXHandler.html#method-10">-ignoreWhitespace:</a>
<li><a href="GSSAXHandler.html#method-20">-internalSubset:externalID:systemID:</a>
<li><a href="GSSAXHandler.html#method-5">-isStandalone</a>
<li><a href="GSSAXHandler.html#method-1">-lib</a>
@ -93,7 +104,7 @@ Create a new SAX handler.
<hr>
<h3><a name="method-2">parser</a></h3>
- (<A HREF="GSXMLParser.html#GSXMLParser">GSXMLParser</A>*) <b>parser</b>;<br>
- (GSXMLParser*) <b>parser</b>;<br>
<p>
@ -133,43 +144,43 @@ Called if the document is standalone.
<hr>
<h3><a name="method-6">startElement:attributes:</a></h3>
- (void) <b>startElement:</b> (<A HREF="NSString.html#NSString">NSString</A>*)elementName <b>attributes:</b> (<A HREF="NSMutableDictionary.html#NSMutableDictionary">NSMutableDictionary</A>*)elementAttributes;<br>
- (void) <b>startElement:</b> (NSString*)elementName <b>attributes:</b> (NSMutableDictionary*)elementAttributes;<br>
<p>
<p>
Called when an opening tag has been processed.
</p>
<hr>
<h3><a name="method-7">endElement</a></h3>
- (void) <b>endElement</b> (<A HREF="NSString.html#NSString">NSString</A>*)elementName;<br>
- (void) <b>endElement</b> (NSString*)elementName;<br>
<p>
<p>
Called when the end of an element has been detected.
</p>
<hr>
<h3><a name="method-8">attribute:value:</a></h3>
- (void) <b>attribute:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>value:</b> (<A HREF="NSString.html#NSString">NSString</A>*)value;<br>
- (void) <b>attribute:</b> (NSString*)name <b>value:</b> (NSString*)value;<br>
<p>
<p>
Handle an attribute that has been read by the parser.
</p>
<hr>
<h3><a name="method-9">characters:length:</a></h3>
- (void) <b>characters:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>length:</b> (int)len;<br>
<h3><a name="method-9">characters:</a></h3>
- (void) <b>characters:</b> (NSString*)name;<br>
<p>
<p>
Receiving some chars from the parser.
</p>
<hr>
<h3><a name="method-10">ignoreWhitespace:length:</a></h3>
- (void) <b>ignoreWhitespace:</b> (<A HREF="NSString.html#NSString">NSString</A>*)ch <b>length:</b> (int)length;<br>
<h3><a name="method-10">ignoreWhitespace:</a></h3>
- (void) <b>ignoreWhitespace:</b> (NSString*)ch;<br>
<p>
Receiving some ignorable whitespaces from the parser.
@ -178,25 +189,25 @@ Receiving some ignorable whitespaces from the parser.
<hr>
<h3><a name="method-11">processInstruction:value:</a></h3>
- (void) <b>processInstruction:</b> (<A HREF="NSString.html#NSString">NSString</A>*)targetName <b>value:</b> (<A HREF="NSString.html#NSString">NSString</A>*)PIData;<br>
- (void) <b>processInstruction:</b> (NSString*)targetName <b>value:</b> (NSString*)PIData;<br>
<p>
<p>
A processing instruction has been parsed.
</p>
<hr>
<h3><a name="method-12">comment:</a></h3>
- (void) <b>comment:</b> (<A HREF="NSString.html#NSString">NSString</A>*)value;<br>
- (void) <b>comment:</b> (NSString*)value;<br>
<p>
<p>
A comment has been parsed.
</p>
<hr>
<h3><a name="method-13">cdataBlock:length:</a></h3>
- (void) <b>cdataBlock:</b> (<A HREF="NSString.html#NSString">NSString</A>*)value <b>length:</b> (int)length;<br>
<h3><a name="method-13">cdataBlock:</a></h3>
- (void) <b>cdataBlock:</b> (NSString*)value;<br>
<p>
Called when a pcdata block has been parsed.
@ -205,7 +216,7 @@ Called when a pcdata block has been parsed.
<hr>
<h3><a name="method-14">globalNamespace:href:prefix:</a></h3>
- (void) <b>globalNamespace:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>href:</b> (<A HREF="NSString.html#NSString">NSString</A>*)href <b>prefix:</b> (<A HREF="NSString.html#NSString">NSString</A>*)prefix;<br>
- (void) <b>globalNamespace:</b> (NSString*)name <b>href:</b> (NSString*)href <b>prefix:</b> (NSString*)prefix;<br>
<p>
An old global namespace has been parsed.
@ -214,7 +225,7 @@ An old global namespace has been parsed.
<hr>
<h3><a name="method-15">error:</a></h3>
- (void) <b>error:</b> (<A HREF="NSString.html#NSString">NSString</A>*)message;<br>
- (void) <b>error:</b> (NSString*)message;<br>
<p>
Called when found a error.
@ -223,7 +234,7 @@ Called when found a error.
<hr>
<h3><a name="method-16">fatalError:</a></h3>
- (void) <b>fatalError:</b> (<A HREF="NSString.html#NSString">NSString</A>*)message;<br>
- (void) <b>fatalError:</b> (NSString*)message;<br>
<p>
Called when found a fatal error.
@ -232,7 +243,7 @@ Called when found a fatal error.
<hr>
<h3><a name="method-17">warning:</a></h3>
- (void) <b>warning:</b> (<A HREF="NSString.html#NSString">NSString</A>*)message;<br>
- (void) <b>warning:</b> (NSString*)message;<br>
<p>
Called when found a warning.
@ -259,7 +270,7 @@ Does this document have an external subset.
<hr>
<h3><a name="method-20">internalSubset:externalID:systemID:</a></h3>
- (void) <b>internalSubset:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>externalID:</b> (<A HREF="NSString.html#NSString">NSString</A>*)externalID <b>systemID:</b> (<A HREF="NSString.html#NSString">NSString</A>*)systemID;<br>
- (void) <b>internalSubset:</b> (NSString*)name <b>externalID:</b> (NSString*)externalID <b>systemID:</b> (NSString*)systemID;<br>
<p>
Callback on internal subset declaration.
@ -268,7 +279,7 @@ Callback on internal subset declaration.
<hr>
<h3><a name="method-21">resolveEntity:systemID:</a></h3>
- (void*) <b>resolveEntity:</b> (<A HREF="NSString.html#NSString">NSString</A>*)publicID <b>systemID:</b> (<A HREF="NSString.html#NSString">NSString</A>*)systemID;<br>
- (void*) <b>resolveEntity:</b> (NSString*)publicID <b>systemID:</b> (NSString*)systemID;<br>
<p>
The entity loader, to control the loading of external entities,
@ -278,7 +289,7 @@ The entity loader, to control the loading of external entities,
<hr>
<h3><a name="method-22">getEntity:</a></h3>
- (void*) <b>getEntity:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name;<br>
- (void*) <b>getEntity:</b> (NSString*)name;<br>
<p>
Get an entity by name.
@ -287,7 +298,7 @@ Get an entity by name.
<hr>
<h3><a name="method-23">getParameterEntity:</a></h3>
- (void*) <b>getParameterEntity:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name;<br>
- (void*) <b>getParameterEntity:</b> (NSString*)name;<br>
<p>
Get a parameter entity by name.
@ -296,7 +307,7 @@ Get a parameter entity by name.
<hr>
<h3><a name="method-24">namespaceDecl:href:prefix:</a></h3>
- (void) <b>namespaceDecl:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>href:</b> (<A HREF="NSString.html#NSString">NSString</A>*)href <b>prefix:</b> (<A HREF="NSString.html#NSString">NSString</A>*)prefix;<br>
- (void) <b>namespaceDecl:</b> (NSString*)name <b>href:</b> (NSString*)href <b>prefix:</b> (NSString*)prefix;<br>
<p>
A namespace has been parsed.
@ -305,7 +316,7 @@ A namespace has been parsed.
<hr>
<h3><a name="method-25">notationDecl:systemId:</a></h3>
- (void) <b>notationDecl:</b> (<A HREF="NSString.html#NSString">NSString</A>*)publicId <b>systemId:</b> (<A HREF="NSString.html#NSString">NSString</A>*)systemId;<br>
- (void) <b>notationDecl:</b> (NSString*)publicId <b>systemId:</b> (NSString*)systemId;<br>
<p>
What to do when a notation declaration has been parsed.
@ -314,7 +325,7 @@ What to do when a notation declaration has been parsed.
<hr>
<h3><a name="method-26">entityDecl:type:publicId:systemId:content:</a></h3>
- (void) <b>entityDecl:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>type:</b> (int)type <b>publicId:</b> (<A HREF="NSString.html#NSString">NSString</A>*)publicId <b>systemId:</b> (<A HREF="NSString.html#NSString">NSString</A>*)systemId <b>content:</b> (<A HREF="NSString.html#NSString">NSString</A>*)content;<br>
- (void) <b>entityDecl:</b> (NSString*)name <b>type:</b> (int)type <b>publicId:</b> (NSString*)publicId <b>systemId:</b> (NSString*)systemId <b>content:</b> (NSString*)content;<br>
<p>
An entity definition has been parsed.
@ -323,7 +334,7 @@ An entity definition has been parsed.
<hr>
<h3><a name="method-27">attributeDecl:name:type:typeDefValue:defaultValue:</a></h3>
- (void) <b>attributeDecl:</b> (<A HREF="NSString.html#NSString">NSString</A>*)nameElement <b>name:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>type:</b> (int)type <b>typeDefValue:</b> (int)defType <b>defaultValue:</b> (<A HREF="NSString.html#NSString">NSString</A>*)value;<br>
- (void) <b>attributeDecl:</b> (NSString*)nameElement <b>name:</b> (NSString*)name <b>type:</b> (int)type <b>typeDefValue:</b> (int)defType <b>defaultValue:</b> (NSString*)value;<br>
<p>
An attribute definition has been parsed.
@ -332,7 +343,7 @@ An attribute definition has been parsed.
<hr>
<h3><a name="method-28">elementDecl:type:</a></h3>
- (void) <b>elementDecl:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>type:</b> (int)type;<br>
- (void) <b>elementDecl:</b> (NSString*)name <b>type:</b> (int)type;<br>
<p>
An element definition has been parsed.
@ -341,7 +352,7 @@ An element definition has been parsed.
<hr>
<h3><a name="method-29">unparsedEntityDecl:public:system:notationName:</a></h3>
- (void) <b>unparsedEntityDecl:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name <b>public:</b> (<A HREF="NSString.html#NSString">NSString</A>*)publicId <b>system:</b> (<A HREF="NSString.html#NSString">NSString</A>*)systemId <b>notationName:</b> (<A HREF="NSString.html#NSString">NSString</A>*)notation;<br>
- (void) <b>unparsedEntityDecl:</b> (NSString*)name <b>public:</b> (NSString*)publicId <b>system:</b> (NSString*)systemId <b>notationName:</b> (NSString*)notation;<br>
<p>
What to do when an unparsed entity declaration is parsed.
@ -350,7 +361,7 @@ What to do when an unparsed entity declaration is parsed.
<hr>
<h3><a name="method-30">reference:</a></h3>
- (void) <b>reference:</b> (<A HREF="NSString.html#NSString">NSString</A>*)name;<br>
- (void) <b>reference:</b> (NSString*)name;<br>
<p>
Called when an entity reference is detected.

View file

@ -19,8 +19,12 @@
<class name="GSXMLParser" super="NSObject">
<declared>GSXML.h</declared>
<desc>
<p>XML Parser.
</p>
<p>
The XML parser object is the pivotal part of parsing an XML
document - it will either build a tree representing the
document, or will cooperate with a GSSAXHandler object to
provide parsing without the overhead of building a tree.
</p>
</desc>
@ -31,10 +35,13 @@
<p>Creation of a new Parser by calling initWithSAXHandler:source:
</p>
<p>
Source must be <code>NSString</code> or <code>NSData</code>.
Source must be <code>NSString</code> (file name),
<code>NSData</code> (raw document contnets),
<code>NSURL</code> (not yet implemented),
or <code>nil</code> (for incremental parsing).
</p>
<example>
GSXMLParser *p = [GSXMLParser parser:@"macos.xml"];
GSXMLParser *p = [GSXMLParser parser: @"macos.xml"];
if ([p parse])
{
@ -56,8 +63,20 @@
<sel>source:</sel>
<arg type="id">source</arg>
<desc>
<p>Creation of a new Parser by calling initWithSAXHandler:source:
<p>
Creation of a new Parser by calling initWithSAXHandler:source:
</p>
<p>
Source must be <code>NSString</code> (file name),
<code>NSData</code> (raw document contnets),
<code>NSURL</code> (not yet implemented),
or <code>nil</code> (for incremental parsing).
</p>
<p>
If the handler object supplied is nil, the parser will build
a tree representing the parsed file rather than attempting
to get the handler to deal with the parsed elements and entities.
</p>
<example>
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
GSSAXHandler *h = [GSDebugSAXHandler handler];
@ -99,8 +118,17 @@
containing raw XML text, or the name of a file to parse.
</p>
<p>
Future options are intended to include NSURL objects, and
nil objects (for incremental (data push) operation.
In the future, it is intended that this method will also
support NSYRL objects.
</p>
<p>
If the source object is <code>nil</code> then the parser will
be initialised for incremental parsing.
</p>
<p>
If the handler object supplied is nil, the parser will build
a tree representing the parsed file rather than attempting
to get the handler to deal with the parsed elements and entities.
</p>
</desc>
</method>
@ -108,7 +136,7 @@
<method type="void*">
<sel>lib</sel>
<desc>
<p>Return pointer to xmlParserCtxt structure.
<p>Return pointer to xmlParserCtxt structure.
</p>
</desc>
</method>
@ -116,16 +144,17 @@
<method type="GSXMLDocument*">
<sel>doc</sel>
<desc>
<p>Return GSXMLDocument object.
<p>Return GSXMLDocument object.
</p>
</desc>
</method>
<method type="BOOL">
<sel>parse</sel>
<desc>
<p>Parse source. Return YES if parsed, otherwise NO.
<p>
Parse source. Return YES if parsed, otherwise NO.
This method should be called once to parse the entiore document.
</p>
<example>
GSXMLParser *p = [GSXMLParser parser:@"macos.xml"];
@ -143,6 +172,37 @@
</desc>
</method>
<method type="BOOL">
<sel>parse:</sel>
<arg type="NSData*">data</arg>
<desc>
<p>
Pass data to the parser for incremental parsing. This method
should be called many times, with each call passing another
block of data from the same document. After the whole of the
document has been parsed, the method should be called with
an empty or nil data object to indicate end of parsing.
Once this has been done, the method may be used again to
parse a new document.
</p>
<example>
GSXMLParser *p = [GSXMLParser parserWithSAXHandler: nil source: nil];
while ((data = getMoreData()) != nil)
{
if ([p parse: data] == NO)
{
NSLog(@"parse error");
}
}
// Do something with document parsed
[p parse: nil]; // Ready to parse another document.
</example>
</desc>
</method>
<method type="BOOL">
<sel>substituteEntites:</sel>
<arg type="BOOL">yesno</arg>

View file

@ -18,12 +18,16 @@
<h2><a name="cont-0">GSXMLParser</a></h2>
<h2><a name="GSXMLParser">GSXMLParser</a></h2>
<p><b>Declared in:</b> GSXML.h</p>
<p><b>Inherits from:</b> <A HREF="NSObject.html#NSObject">NSObject</A></p>
<p><b>Inherits from:</b> NSObject</p>
<hr>
<p>
XML Parser.
</p>
<p>
The XML parser object is the pivotal part of parsing an XML
document - it will either build a tree representing the
document, or will cooperate with a GSSAXHandler object to
provide parsing without the overhead of building a tree.
</p>
<h2>Instance Variables</h2>
@ -34,16 +38,17 @@ XML Parser.
<li><a href="GSXMLParser.html#method-0">+parser:</a>
<li><a href="GSXMLParser.html#method-2">+parserWithSAXHandler:source:</a>
<li><a href="GSXMLParser.html#method-4">+xmlEncodingStringForStringEncoding:</a>
<li><a href="GSXMLParser.html#method-13">-doValidityChecking:</a>
<li><a href="GSXMLParser.html#method-15">-doValidityChecking:</a>
<li><a href="GSXMLParser.html#method-7">-doc</a>
<li><a href="GSXMLParser.html#method-14">-errNo</a>
<li><a href="GSXMLParser.html#method-12">-getWarnings:</a>
<li><a href="GSXMLParser.html#method-16">-errNo</a>
<li><a href="GSXMLParser.html#method-14">-getWarnings:</a>
<li><a href="GSXMLParser.html#method-5">-initWithSAXHandler:source:</a>
<li><a href="GSXMLParser.html#method-11">-keepBlanks:</a>
<li><a href="GSXMLParser.html#method-13">-keepBlanks:</a>
<li><a href="GSXMLParser.html#method-6">-lib</a>
<li><a href="GSXMLParser.html#method-8">-parse</a>
<li><a href="GSXMLParser.html#method-15">-setExternalEntityLoader</a>
<li><a href="GSXMLParser.html#method-10">-substituteEntites:</a>
<li><a href="GSXMLParser.html#method-10">-parse:</a>
<li><a href="GSXMLParser.html#method-17">-setExternalEntityLoader</a>
<li><a href="GSXMLParser.html#method-12">-substituteEntites:</a>
</ul>
<hr><h2>Class Methods</h2>
<h3><a name="method-0">parser:</a></h3>
@ -55,13 +60,16 @@ Creation of a new Parser by calling initWithSAXHandler:source:
<p>
Source must be <code>NSString</code> or <code>NSData</code>.
Source must be <code>NSString</code> (file name),
<code>NSData</code> (raw document contnets),
<code>NSURL</code> (not yet implemented),
or <code>nil</code> (for incremental parsing).
</p>
<a name="label-1">example</a>
<pre>
GSXMLParser *p = [GSXMLParser parser:@"macos.xml"];
GSXMLParser *p = [GSXMLParser parser: @"macos.xml"];
if ([p parse])
{
@ -79,12 +87,28 @@ Creation of a new Parser by calling initWithSAXHandler:source:
<hr>
<h3><a name="method-2">parserWithSAXHandler:source:</a></h3>
+ (GSXMlParser*) <b>parserWithSAXHandler:</b> (<A HREF="GSSAXHandler.html#GSSAXHandler">GSSAXHandler</A>*)handler <b>source:</b> (id)source;<br>
+ (GSXMlParser*) <b>parserWithSAXHandler:</b> (GSSAXHandler*)handler <b>source:</b> (id)source;<br>
<p>
Creation of a new Parser by calling initWithSAXHandler:source:
Creation of a new Parser by calling initWithSAXHandler:source:
</p>
<p>
Source must be <code>NSString</code> (file name),
<code>NSData</code> (raw document contnets),
<code>NSURL</code> (not yet implemented),
or <code>nil</code> (for incremental parsing).
</p>
<p>
If the handler object supplied is nil, the parser will build
a tree representing the parsed file rather than attempting
to get the handler to deal with the parsed elements and entities.
</p>
<a name="label-3">example</a>
<pre>
@ -106,7 +130,7 @@ Creation of a new Parser by calling initWithSAXHandler:source:
<hr>
<h3><a name="method-4">xmlEncodingStringForStringEncoding:</a></h3>
+ (<A HREF="NSString.html#NSString">NSString</A>*) <b>xmlEncodingStringForStringEncoding:</b> (NSStringEncoding)encoding;<br>
+ (NSString*) <b>xmlEncodingStringForStringEncoding:</b> (NSStringEncoding)encoding;<br>
Return the name of the string encoding (for XML) to use for the
specified OpenStep encoding.
@ -115,7 +139,7 @@ Creation of a new Parser by calling initWithSAXHandler:source:
<hr><h2>Instances Methods</h2>
<h3><a name="method-5">initWithSAXHandler:source:</a></h3>
<b>This is the designated initialiser</b><br>
- (id) <b>initWithSAXHandler:</b> (<A HREF="GSSAXHandler.html#GSSAXHandler">GSSAXHandler</A>*)handler <b>source:</b> (id)source;<br>
- (id) <b>initWithSAXHandler:</b> (GSSAXHandler*)handler <b>source:</b> (id)source;<br>
<p>
@ -131,8 +155,21 @@ Creation of a new Parser by calling initWithSAXHandler:source:
<p>
Future options are intended to include NSURL objects, and
nil objects (for incremental (data push) operation.
In the future, it is intended that this method will also
support NSYRL objects.
</p>
<p>
If the source object is <code>nil</code> then the parser will
be initialised for incremental parsing.
</p>
<p>
If the handler object supplied is nil, the parser will build
a tree representing the parsed file rather than attempting
to get the handler to deal with the parsed elements and entities.
</p>
@ -140,27 +177,28 @@ Creation of a new Parser by calling initWithSAXHandler:source:
<h3><a name="method-6">lib</a></h3>
- (void*) <b>lib</b>;<br>
<p>
<p>
Return pointer to xmlParserCtxt structure.
</p>
<hr>
<h3><a name="method-7">doc</a></h3>
- (<A HREF="GSXMLDocument.html#GSXMLDocument">GSXMLDocument</A>*) <b>doc</b>;<br>
- (GSXMLDocument*) <b>doc</b>;<br>
<p>
<p>
Return GSXMLDocument object.
</p>
<hr>
<h3><a name="method-8">parse</a></h3>
- (BOOL) <b>parse</b>;<br>
<p>
Parse source. Return YES if parsed, otherwise NO.
<p>
Parse source. Return YES if parsed, otherwise NO.
This method should be called once to parse the entiore document.
</p>
<a name="label-9">example</a>
@ -182,7 +220,42 @@ Parse source. Return YES if parsed, otherwise NO.
<hr>
<h3><a name="method-10">substituteEntites:</a></h3>
<h3><a name="method-10">parse:</a></h3>
- (BOOL) <b>parse:</b> (NSData*)data;<br>
<p>
Pass data to the parser for incremental parsing. This method
should be called many times, with each call passing another
block of data from the same document. After the whole of the
document has been parsed, the method should be called with
an empty or nil data object to indicate end of parsing.
Once this has been done, the method may be used again to
parse a new document.
</p>
<a name="label-11">example</a>
<pre>
GSXMLParser *p = [GSXMLParser parserWithSAXHandler: nil source: nil];
while ((data = getMoreData()) != nil)
{
if ([p parse: data] == NO)
{
NSLog(@"parse error");
}
}
// Do something with document parsed
[p parse: nil]; // Ready to parse another document.
</pre>
<hr>
<h3><a name="method-12">substituteEntites:</a></h3>
- (BOOL) <b>substituteEntites:</b> (BOOL)yesno;<br>
<p>
@ -193,7 +266,7 @@ Set and return the previous value for default entity support.
<hr>
<h3><a name="method-11">keepBlanks:</a></h3>
<h3><a name="method-13">keepBlanks:</a></h3>
- (BOOL) <b>keepBlanks:</b> (BOOL)yesno;<br>
<p>
@ -204,12 +277,12 @@ Set and return the previous value for default blanks text nodes support.
<hr>
<h3><a name="method-12">getWarnings:</a></h3>
<h3><a name="method-14">getWarnings:</a></h3>
- (BOOL) <b>getWarnings:</b> (BOOL)yesno;<br>
<hr>
<h3><a name="method-13">doValidityChecking:</a></h3>
<h3><a name="method-15">doValidityChecking:</a></h3>
- (BOOL) <b>doValidityChecking:</b> (BOOL)yesno;<br>
<p>
@ -218,7 +291,7 @@ Sets whether the document needs to be validated.
<hr>
<h3><a name="method-14">errNo</a></h3>
<h3><a name="method-16">errNo</a></h3>
- (int) <b>errNo</b>;<br>
<p>
@ -227,7 +300,7 @@ Return error code.
<hr>
<h3><a name="method-15">setExternalEntityLoader</a></h3>
<h3><a name="method-17">setExternalEntityLoader</a></h3>
- (void) <b>setExternalEntityLoader</b> (void*)function;<br>
<p>

View file

@ -186,6 +186,7 @@ typedef xmlNsType GSXMLNamespaceType;
- (GSXMLDocument*) doc;
- (BOOL) parse;
- (BOOL) parse: (NSData*)data;
- (BOOL) doValidityChecking: (BOOL)yesno;
- (int) errNo;
@ -219,16 +220,12 @@ typedef xmlNsType GSXMLNamespaceType;
- (void) endElement: (NSString*)elementName;
- (void) attribute: (NSString*)name
value: (NSString*)value;
- (void) characters: (NSString*)name
length: (int)len;
- (void) ignoreWhitespace: (NSString*)ch
length: (int)len;
- (void) characters: (NSString*)name;
- (void) ignoreWhitespace: (NSString*)ch;
- (void) processInstruction: (NSString*)targetName
data: (NSString*)PIdata;
- (void) comment: (NSString*) value;
- (void) cdataBlock: (NSString*)value
length: (int)len;
- (void) cdataBlock: (NSString*)value;
- (int) hasInternalSubset;
- (void) internalSubset: (NSString*)name

View file

@ -1113,39 +1113,42 @@ static NSString *endMarker = @"At end of incremental parse";
setupCache();
}
/*
* The parser passes a pointer to the GSSAXHandler object as context.
*/
#define HANDLER (GSSAXHandler*)(ctx)
void
static void
startDocumentFunction(void *ctx)
{
[HANDLER startDocument];
}
void
static void
endDocumentFunction(void *ctx)
{
[HANDLER endDocument];
}
int
static int
isStandaloneFunction(void *ctx)
{
return [HANDLER isStandalone];
}
int
static int
hasInternalSubsetFunction(void *ctx)
{
return [HANDLER hasInternalSubset];
}
int
static int
hasExternalSubsetFunction(void *ctx)
{
return [HANDLER hasExternalSubset];
}
void
static void
internalSubsetFunction(void *ctx, const char *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
@ -1154,27 +1157,26 @@ internalSubsetFunction(void *ctx, const char *name,
systemID: (*csImp)(NSString_class, csSel, SystemID)];
}
xmlParserInputPtr
static xmlParserInputPtr
resolveEntityFunction(void *ctx, const char *publicId, const char *systemId)
{
return [HANDLER resolveEntity: (*csImp)(NSString_class, csSel, publicId)
systemID: (*csImp)(NSString_class, csSel, systemId)];
}
xmlEntityPtr
static xmlEntityPtr
getEntityFunction(void *ctx, const char *name)
{
return [HANDLER getEntity: (*csImp)(NSString_class, csSel, name)];
}
xmlEntityPtr
static xmlEntityPtr
getParameterEntityFunction(void *ctx, const char *name)
{
return [HANDLER getParameterEntity: (*csImp)(NSString_class, csSel, name)];
}
void
static void
entityDeclFunction(void *ctx, const char *name, int type,
const char *publicId, const char *systemId, char *content)
{
@ -1185,7 +1187,7 @@ entityDeclFunction(void *ctx, const char *name, int type,
content: (*csImp)(NSString_class, csSel, content)];
}
void
static void
attributeDeclFunction(void *ctx, const char *elem, const char *name,
int type, int def, const char *defaultValue, xmlEnumerationPtr tree)
{
@ -1196,7 +1198,7 @@ attributeDeclFunction(void *ctx, const char *elem, const char *name,
defaultValue: (*csImp)(NSString_class, csSel, defaultValue)];
}
void
static void
elementDeclFunction(void *ctx, const char *name, int type,
xmlElementContentPtr content)
{
@ -1205,7 +1207,7 @@ elementDeclFunction(void *ctx, const char *name, int type,
}
void
static void
notationDeclFunction(void *ctx, const char *name,
const char *publicId, const char *systemId)
{
@ -1214,7 +1216,7 @@ notationDeclFunction(void *ctx, const char *name,
system: (*csImp)(NSString_class, csSel, systemId)];
}
void
static void
unparsedEntityDeclFunction(void *ctx, const char *name,
const char *publicId, const char *systemId, const char *notationName)
{
@ -1224,8 +1226,7 @@ unparsedEntityDeclFunction(void *ctx, const char *name,
notationName: (*csImp)(NSString_class, csSel, notationName)];
}
void
static void
startElementFunction(void *ctx, const char *name, const char **atts)
{
int i;
@ -1245,49 +1246,50 @@ startElementFunction(void *ctx, const char *name, const char **atts)
attributes: dict];
}
void endElementFunction(void *ctx, const char *name)
static void
endElementFunction(void *ctx, const char *name)
{
[HANDLER endElement: (*csImp)(NSString_class, csSel, name)];
}
void
static void
charactersFunction(void *ctx, const char *ch, int len)
{
[HANDLER characters: (*cslImp)(NSString_class, cslSel, ch, len)];
}
void
static void
referenceFunction(void *ctx, const char *name)
{
[HANDLER reference: (*csImp)(NSString_class, csSel, name)];
}
void
static void
ignorableWhitespaceFunction(void *ctx, const char *ch, int len)
{
[HANDLER ignoreWhitespace: (*cslImp)(NSString_class, cslSel, ch, len)];
}
void
static void
processInstructionFunction(void *ctx, const char *target, const char *data)
{
[HANDLER processInstruction: (*csImp)(NSString_class, csSel, target)
data: (*csImp)(NSString_class, csSel, data)];
}
void
static void
cdataBlockFunction(void *ctx, const char *value, int len)
{
[HANDLER cdataBlock: (*cslImp)(NSString_class, cslSel, value, len)];
}
void
static void
commentFunction(void *ctx, const char *value)
{
[HANDLER comment: (*csImp)(NSString_class, csSel, value)];
}
void
static void
warningFunction(void *ctx, const char *msg, ...)
{
char allMsg[2048];
@ -1300,7 +1302,7 @@ warningFunction(void *ctx, const char *msg, ...)
[HANDLER warning: (*csImp)(NSString_class, csSel, allMsg)];
}
void
static void
errorFunction(void *ctx, const char *msg, ...)
{
char allMsg[2048];
@ -1312,7 +1314,7 @@ errorFunction(void *ctx, const char *msg, ...)
[HANDLER error: (*csImp)(NSString_class, csSel, allMsg)];
}
void
static void
fatalErrorFunction(void *ctx, const char *msg, ...)
{
char allMsg[2048];