Before you start
A loadable implementation library, or a LIL, is the implementation module for a C parser (or node). A LIL is a Linux or UNIX shared object or Windows dynamic link library (DLL), that does not have the file extension .dll but .lil.
The implementation functions that have to be written by the developer are listed in C parser implementation functions. The utility functions that are provided by WebSphere Message Broker to aid this process are listed in C parser utility functions.
WebSphere Message Broker provides the source for a sample user-defined parser called BipSampPluginParser.c. This is a simple pseudo-XML parser that you can use in its current state, or you can modify.
Each LIL that implements a user-defined parser must export a function called bipGetParserFactory as its initialization function. The initialization function defines the name of the factory that the user-defined parser supports and the classes of objects, or shared object, supported by the factory.
The initialization function must also create the factory object and define the names of all parsers supported by the LIL. A factory can support any number of object classes (parsers). When a parser is defined, a list of pointers to the implementation functions for that parser is passed to the broker. If a parser of the same name already exists, the request is rejected.
void LilFactoryExportPrefix * LilFactoryExportSuffix bipGetParserFactory() {
CciFactory* factoryObject; int rc; static CPI_VFT vftable = {CPI_VFT_DEFAULT};
initParserConstants();
vftable.iFpCreateContext = cpiCreateContext; vftable.iFpParseBufferEncoded = cpiParseBufferEncoded; vftable.iFpParseFirstChild = cpiParseFirstChild; vftable.iFpParseLastChild = cpiParseLastChild; vftable.iFpParsePreviousSibling = cpiParsePreviousSibling; vftable.iFpParseNextSibling = cpiParseNextSibling; vftable.iFpWriteBufferEncoded = cpiWriteBufferEncoded; vftable.iFpDeleteContext = cpiDeleteContext; vftable.iFpSetElementValue = cpiSetElementValue; vftable.iFpElementValue = cpiElementValue; vftable.iFpNextParserClassName = cpiNextParserClassName; vftable.iFpSetNextParserClassName = cpiSetNextParserClassName; vftable.iFpNextParserEncoding = cpiNextParserEncoding; vftable.iFpNextParserCodedCharSetId = cpiNextParserCodedCharSetId;
The initialization function must then create a parser factory by invoking cpiCreateParserFactory. The parser classes supported by the factory are defined by calling cpiDefineParserClass. The address of the factory object (returned by cpiCreateParserFactory) must be returned to the broker as the return value from the initialization function.
factoryObject = cpiCreateParserFactory(&rc, constParserFactory);
if (factoryObject) { cpiDefineParserClass(&rc, factoryObject, constPXML, &vftable); } else { /* Error: Unable to create parser factory */ }
return(factoryObject); }
Whenever an instance of a user-defined parser object is created, the context creation implementation function cpiCreateContext is invoked by the message broker. This allows the user-defined parser to allocate instance data associated with the parser.
CciContext* cpiCreateContext( CciParser* parser ){ PARSER_CONTEXT_ST *p;
p = (PARSER_CONTEXT_ST *)malloc(sizeof(PARSER_CONTEXT_ST));
if (p) { memset(p, 0, sizeof(PARSER_CONTEXT_ST)); } else { /* Error: Unable to allocate memory */ }
return((CciContext*)p); }
void cpiDeleteContext( CciParser* parser, CciContext* context ){ PARSER_CONTEXT_ST* pc = (PARSER_CONTEXT_ST *)context ; int rc = 0; return; }
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
as10010_ |