2000-09-15 19:56:39 +00:00
|
|
|
<?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>
|
2000-09-20 06:45:02 +00:00
|
|
|
<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>
|
2000-09-15 19:56:39 +00:00
|
|
|
</desc>
|
|
|
|
|
|
|
|
|
|
|
|
<method type="GSXMLParser*" factory="yes">
|
|
|
|
<sel>parser:</sel>
|
|
|
|
<arg type="id">source</arg>
|
|
|
|
<desc>
|
2000-09-19 20:47:56 +00:00
|
|
|
<p>Creation of a new Parser by calling initWithSAXHandler:source:
|
2000-09-15 19:56:39 +00:00
|
|
|
</p>
|
|
|
|
<p>
|
2000-09-20 06:45:02 +00:00
|
|
|
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).
|
2000-09-15 19:56:39 +00:00
|
|
|
</p>
|
|
|
|
<example>
|
2000-09-20 06:45:02 +00:00
|
|
|
GSXMLParser *p = [GSXMLParser parser: @"macos.xml"];
|
2000-09-15 19:56:39 +00:00
|
|
|
|
|
|
|
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>
|
2000-09-20 06:45:02 +00:00
|
|
|
<p>
|
|
|
|
Creation of a new Parser by calling initWithSAXHandler:source:
|
2000-09-15 19:56:39 +00:00
|
|
|
</p>
|
2000-09-20 06:45:02 +00:00
|
|
|
<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>
|
2000-09-15 19:56:39 +00:00
|
|
|
<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>
|
|
|
|
|
2000-09-19 20:47:56 +00:00
|
|
|
<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>
|
|
|
|
|
2000-09-15 19:56:39 +00:00
|
|
|
<method type="id" init="yes">
|
|
|
|
<sel>initWithSAXHandler:</sel>
|
|
|
|
<arg type="GSSAXHandler*">handler</arg>
|
|
|
|
<sel>source:</sel>
|
|
|
|
<arg type="id">source</arg>
|
|
|
|
<desc>
|
2000-09-19 20:47:56 +00:00
|
|
|
<p>
|
|
|
|
Initialisation of a new Parser with SAX handler (if not nil).
|
2000-09-15 19:56:39 +00:00
|
|
|
</p>
|
2000-09-19 20:47:56 +00:00
|
|
|
<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>
|
2000-09-20 06:45:02 +00:00
|
|
|
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.
|
2000-09-19 20:47:56 +00:00
|
|
|
</p>
|
2000-09-15 19:56:39 +00:00
|
|
|
</desc>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method type="void*">
|
|
|
|
<sel>lib</sel>
|
|
|
|
<desc>
|
2000-09-20 06:45:02 +00:00
|
|
|
<p>Return pointer to xmlParserCtxt structure.
|
2000-09-15 19:56:39 +00:00
|
|
|
</p>
|
|
|
|
</desc>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method type="GSXMLDocument*">
|
|
|
|
<sel>doc</sel>
|
|
|
|
<desc>
|
2000-09-20 06:45:02 +00:00
|
|
|
<p>Return GSXMLDocument object.
|
2000-09-15 19:56:39 +00:00
|
|
|
</p>
|
|
|
|
</desc>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method type="BOOL">
|
|
|
|
<sel>parse</sel>
|
|
|
|
<desc>
|
2000-09-20 06:45:02 +00:00
|
|
|
<p>
|
|
|
|
Parse source. Return YES if parsed, otherwise NO.
|
|
|
|
This method should be called once to parse the entiore document.
|
2000-09-15 19:56:39 +00:00
|
|
|
</p>
|
|
|
|
<example>
|
|
|
|
GSXMLParser *p = [GSXMLParser parser:@"macos.xml"];
|
|
|
|
|
|
|
|
if ([p parse])
|
|
|
|
{
|
|
|
|
[[p doc] dump];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("error parse file\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
</example>
|
|
|
|
</desc>
|
|
|
|
</method>
|
|
|
|
|
2000-09-20 06:45:02 +00:00
|
|
|
<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>
|
|
|
|
|
2000-09-15 19:56:39 +00:00
|
|
|
<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>
|
|
|
|
|