libs-base/Documentation/gsdoc/GSXMLParser.gsdoc

265 lines
7.7 KiB
Text
Raw Normal View History

<?xml version="1.0"?>
<!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 0.6.6//EN" "http://www.gnustep.org/gsdoc-0_6_6.xml">
<gsdoc base="GSXMLParser" prev="GSXMLAttribute" up="GSXML" next="GSSAXHandler">
<head>
<title>GSXMLParser</title>
<author name="Michael Pakhantsov">
<email address="mishel@berest.dp.ua"/>
</author>
<author name="Richard Frith-Macdonald">
<email address="rfm@gnu.org"/>
</author>
<version>0.1</version>
<date>15 September, 2000</date>
</head>
<body>
<chapter>
<heading>GSXMLParser</heading>
<class name="GSXMLParser" super="NSObject">
<declared>GSXML.h</declared>
<desc>
<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>
<method type="GSXMLParser*" factory="yes">
<sel>parser:</sel>
<arg type="id">source</arg>
<desc>
<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>
<example>
GSXMLParser *p = [GSXMLParser parser: @"macos.xml"];
if ([p parse])
{
[[p doc] dump];
}
else
{
printf("error parse file\n");
}
</example>
</desc>
</method>
<method type="GSXMlParser*" factory="yes">
<sel>parserWithSAXHandler:</sel>
<arg type="GSSAXHandler*">handler</arg>
<sel>source:</sel>
<arg type="id">source</arg>
<desc>
<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];
GSXMLParser *p = [GSXMLParser parserWithSAXHandler: h
source: @"macos.xml"];
if ([p parse])
{
printf("ok\n");
}
[arp release];
</example>
</desc>
</method>
<method type="NSString*" factory="yes">
<sel>xmlEncodingStringForStringEncoding:</sel>
<arg type="NSStringEncoding">encoding</arg>
<desc>
Return the name of the string encoding (for XML) to use for the
specified OpenStep encoding.
</desc>
</method>
<method type="id" init="yes">
<sel>initWithSAXHandler:</sel>
<arg type="GSSAXHandler*">handler</arg>
<sel>source:</sel>
<arg type="id">source</arg>
<desc>
<p>
Initialisation of a new Parser with SAX handler (if not nil).
</p>
<p>
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.
</p>
<p>
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>
<method type="void*">
<sel>lib</sel>
<desc>
<p>Return pointer to xmlParserCtxt structure.
</p>
</desc>
</method>
<method type="GSXMLDocument*">
<sel>doc</sel>
<desc>
<p>Return GSXMLDocument object.
</p>
</desc>
</method>
<method type="BOOL">
<sel>parse</sel>
<desc>
<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"];
if ([p parse])
{
[[p doc] dump];
}
else
{
printf("error parse file\n");
}
</example>
</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>
<desc>
<p>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.
</p>
</desc>
</method>
<method type="BOOL">
<sel>keepBlanks:</sel>
<arg type="BOOL">yesno</arg>
<desc>
<p>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.
</p>
</desc>
</method>
<method type="BOOL">
<sel>getWarnings:</sel>
<arg type="BOOL">yesno</arg>
<desc>
</desc>
</method>
<method type="BOOL">
<sel>doValidityChecking:</sel>
<arg type="BOOL">yesno</arg>
<desc>
<p>Sets whether the document needs to be validated.
</p>
</desc>
</method>
<method type="int">
<sel>errNo</sel>
<desc>
<p>Return error code.
</p>
</desc>
</method>
<method type="void">
<sel>setExternalEntityLoader</sel>
<arg type="void*">function</arg>
<desc>
<p>Set a external entity loader.
</p>
</desc>
</method>
</class>
</chapter>
</body>
</gsdoc>