The Expat API wrapper is an RDR-discoverable interface that provides access to the Expat XML parser library. More...
Files | |
file | expatapi.h |
Header file defining the Expat XML parser interface API. | |
file | expatrdr.h |
Functions to register and deregister the Expat API. | |
Data Structures | |
struct | sw_expat_api_20201221 |
The Expat API version 20201221. More... | |
Macros | |
#define | XML_ParserCreate_MM expat_api->XML_ParserCreate_MM |
Create an XML parser instance specifying memory handling functions and namespace processing. More... | |
#define | XML_ParserFree expat_api->XML_ParserFree |
Free an XML parser instance. More... | |
#define | XML_SetXmlDeclHandler expat_api->XML_SetXmlDeclHandler |
Set the XML declaration handler callback. More... | |
#define | XML_SetNamespaceDeclHandler expat_api->XML_SetNamespaceDeclHandler |
Set the namespace declaration handler callbacks. More... | |
#define | XML_SetDoctypeDeclHandler expat_api->XML_SetDoctypeDeclHandler |
Set the DOCTYPE declaration handler callbacks. More... | |
#define | XML_SetElementHandler expat_api->XML_SetElementHandler |
Set the element handler callbacks. More... | |
#define | XML_SetCharacterDataHandler expat_api->XML_SetCharacterDataHandler |
Set the CDATA handler callback. More... | |
#define | XML_SetProcessingInstructionHandler expat_api->XML_SetProcessingInstructionHandler |
Set the XML processing instruction handler callback. More... | |
#define | XML_SetCommentHandler expat_api->XML_SetCommentHandler |
Set the XML comment handler callback. More... | |
#define | XML_SetCdataSectionHandler expat_api->XML_SetCdataSectionHandler |
Set the CDATA section handler callbacks. More... | |
#define | XML_SetReturnNSTriplet expat_api->XML_SetReturnNSTriplet |
Set the XML comment handler callback. More... | |
#define | XML_SetUserData expat_api->XML_SetUserData |
Set the user data pointer passed to callback functions. More... | |
#define | XML_Parse expat_api->XML_Parse |
Parse a chunk of XML data. More... | |
#define | XML_GetBuffer expat_api->XML_GetBuffer |
Get a buffer to read XML data into. More... | |
#define | XML_ParseBuffer expat_api->XML_ParseBuffer |
Parse a chunk of XML data stored in an internal buffer. More... | |
#define | XML_StopParser expat_api->XML_StopParser |
Stop an XML parser. More... | |
#define | XML_GetErrorCode expat_api->XML_GetErrorCode |
Get the error code from a failed parsing operation. More... | |
#define | XML_GetCurrentLineNumber expat_api->XML_GetCurrentLineNumber |
Get the line number where an error occurred. More... | |
#define | XML_GetCurrentColumnNumber expat_api->XML_GetCurrentColumnNumber |
Get the column number where an error occurred. More... | |
#define | XML_GetCurrentByteIndex expat_api->XML_GetCurrentByteIndex |
Get the byte index where an error occurred. More... | |
#define | XML_ErrorString expat_api->XML_ErrorString |
Return an error string corresponding to an XML error code. More... | |
The Expat API wrapper is an RDR-discoverable interface that provides access to the Expat XML parser library.
These calls are based on the Expat library API, but not all calls in the Expat API are exposed through this API.
An Expat API pointer must be discovered using RDR using class RDR_CLASS_API and type RDR_API_EXPAT and assigned to a suitably-named API pointer variable before the API macros are used. The Expat API is automatically registered when the Harlequin RIP is started. It is deregistered when the Harlequin RIP is shutdown.
The normal sequence of calls to parse XML using this API is:
If you detect an error in a parser callback function, you can call XML_StopParser(parser, XML_FALSE) to abort XML parsing.
If there is an error detected during parsing, XML_Parse() or XML_ParseBuffer() will return XML_STATUS_ERROR
. You can then call XML_GetErrorCode() to get the error code, and XML_ErrorString() to convert this code into a readable string. The line and column number where the error occurred can be found by calling XML_GetCurrentLineNumber() and XML_GetCurrentColumnNumber(). The byte index where the error occurred can be found by calling XML_GetCurrentByteIndex().
#define XML_ErrorString expat_api->XML_ErrorString |
Return an error string corresponding to an XML error code.
[in] | code | An XML error code returned by XML_GetErrorCode(). |
See the Expat API documentation for more details.
#define XML_GetBuffer expat_api->XML_GetBuffer |
Get a buffer to read XML data into.
[in] | len | The number of bytes to store in the buffer. |
NULL
on error.Using XML_GetBuffer() and XML_ParseBuffer() avoids an extra data copy if you are reading data from a file or non-memory source. If the XML data is already in memory, using XML_Parse() is equivalent.
See the Expat API documentation for more details.
#define XML_GetCurrentByteIndex expat_api->XML_GetCurrentByteIndex |
Get the byte index where an error occurred.
[in] | parser | An XML parser handle. |
See the Expat API documentation for more details.
#define XML_GetCurrentColumnNumber expat_api->XML_GetCurrentColumnNumber |
Get the column number where an error occurred.
[in] | parser | An XML parser handle. |
See the Expat API documentation for more details.
#define XML_GetCurrentLineNumber expat_api->XML_GetCurrentLineNumber |
Get the line number where an error occurred.
[in] | parser | An XML parser handle. |
See the Expat API documentation for more details.
#define XML_GetErrorCode expat_api->XML_GetErrorCode |
Get the error code from a failed parsing operation.
[in] | parser | An XML parser handle. |
XML_ERROR_*
enumeration codes. An error string corresponding to this error code can be returned by calling XML_ErrorString().See the Expat API documentation for more details.
#define XML_Parse expat_api->XML_Parse |
Parse a chunk of XML data.
[in] | parser | An XML parser handle. |
[in] | s | A buffer containing part or all of an XML document. |
[in] | len | The number of bytes in buffer s. |
[in] | isFinal | A flag indicating if this is the last buffer of data for the document. |
XML_STATUS_OK | on success. |
XML_STATUS_ERROR | if there was a parse error. |
Calling this function will provoke callbacks to functions registered for the declarations, elements, comments, and character data.
Using XML_GetBuffer() and XML_ParseBuffer() avoids an extra data copy if you are reading data from a file or non-memory source. If the XML data is already in memory, using XML_Parse() is equivalent.
See the Expat API documentation for more details.
#define XML_ParseBuffer expat_api->XML_ParseBuffer |
Parse a chunk of XML data stored in an internal buffer.
[in] | parser | An XML parser handle. |
[in] | len | The number of bytes in buffer s. |
[in] | isFinal | A flag indicating if this is the last buffer of data for the document. |
XML_STATUS_OK | on success. |
XML_STATUS_ERROR | if there was a parse error. |
This function parses data previously loaded into an Expat internal buffer allocated using XML_GetBuffer(). Calling this function will provoke callbacks to functions registered for the declarations, elements, comments, and character data.
Using XML_GetBuffer() and XML_ParseBuffer() avoids an extra data copy if you are reading data from a file or non-memory source. If the XML data is already in memory, using XML_Parse() is equivalent.
See the Expat API documentation for more details.
#define XML_ParserCreate_MM expat_api->XML_ParserCreate_MM |
Create an XML parser instance specifying memory handling functions and namespace processing.
[in] | encoding | The encoding of the XML, or NULL if none specified. |
[in] | memsuite | A structure with allocation, reallocation, and free functions. |
[in] | namespaceSeparator | Namespace expanded element names and attribute names are returned as a concatenation of the namespace URI, namespaceSeparator, and the local part of the name. |
NULL
on failure.See the Expat API documentation for more details.
#define XML_ParserFree expat_api->XML_ParserFree |
Free an XML parser instance.
[in] | parser | An XML parser handle. |
See the Expat API documentation for more details.
#define XML_SetCdataSectionHandler expat_api->XML_SetCdataSectionHandler |
Set the CDATA section handler callbacks.
[in] | parser | An XML parser handle. |
[in] | start | CDATA section start callback function. This function is called with user data only. |
[in] | end | CDATA section end callback function. This function is called with user data only. |
See the Expat API documentation for more details.
#define XML_SetCharacterDataHandler expat_api->XML_SetCharacterDataHandler |
Set the CDATA handler callback.
[in] | parser | An XML parser handle. |
[in] | handler | CDATA callback function. This function is called with user data, a pointer to the character data, and the length of the character data. |
See the Expat API documentation for more details.
#define XML_SetCommentHandler expat_api->XML_SetCommentHandler |
Set the XML comment handler callback.
[in] | parser | An XML parser handle. |
[in] | handler | Comment callback function. This function is called with user data and a pointer to the comment. |
See the Expat API documentation for more details.
#define XML_SetDoctypeDeclHandler expat_api->XML_SetDoctypeDeclHandler |
Set the DOCTYPE declaration handler callbacks.
[in] | parser | An XML parser handle. |
[in] | start | Document type start callback function. This function is called with user data, the DOCTYPE name, a SYSTEM ID, a PUBLIC ID and flag indicating if the document type has an internal subset. |
[in] | end | Document type end callback function. This function is called with user data only. |
See the Expat API documentation for more details.
#define XML_SetElementHandler expat_api->XML_SetElementHandler |
Set the element handler callbacks.
[in] | parser | An XML parser handle. |
[in] | start | Element start callback function. This function is called with user data, the element name, and an array of element attribute name,value pairs terminated by a NULL pointers. |
[in] | end | Element end callback function. This function is called with user data and the element name. |
See the Expat API documentation for more details.
#define XML_SetNamespaceDeclHandler expat_api->XML_SetNamespaceDeclHandler |
Set the namespace declaration handler callbacks.
[in] | parser | An XML parser handle. |
[in] | start | Namespace start callback function. This function is called with user data, the namespace prefix, and the namespace URI. |
[in] | end | Namespace end callback function. This function is called with user data and the namespace prefix. |
See the Expat API documentation for more details.
#define XML_SetProcessingInstructionHandler expat_api->XML_SetProcessingInstructionHandler |
Set the XML processing instruction handler callback.
[in] | parser | An XML parser handle. |
[in] | handler | Processing instruction callback function. This function is called with user data, a target pointer and data pointer. The target is the first word in the processing instruction. The data is the rest of the characters in it after skipping all whitespace after the initial word. |
See the Expat API documentation for more details.
#define XML_SetReturnNSTriplet expat_api->XML_SetReturnNSTriplet |
Set the XML comment handler callback.
[in] | parser | An XML parser handle. |
[in] | do_nst | A flag indicating whether qualified namespace names are returned as three parts (URI, local name, and prefix), or as one. |
See the Expat API documentation for more details.
#define XML_SetUserData expat_api->XML_SetUserData |
Set the user data pointer passed to callback functions.
[in] | parser | An XML parser handle. |
[in] | userData | The user data pointer that is passed to callback functions. |
See the Expat API documentation for more details.
#define XML_SetXmlDeclHandler expat_api->XML_SetXmlDeclHandler |
Set the XML declaration handler callback.
[in] | parser | An XML parser handle. |
[in] | xmldecl | XML callback function. This function is called with user data, the XML version, the XML encoding and an indication of the state of the XML standalone attribute. |
See the Expat API documentation for more details.
#define XML_StopParser expat_api->XML_StopParser |
Stop an XML parser.
[in] | parser | An XML parser handle. |
[in] | resumable | XML_FALSE if aborting the parse, XML_TRUE if the parsing may be resumed later. |
XML_STATUS_OK | on success. |
XML_STATUS_ERROR | if there was an error. |
See the Expat API documentation for more details.