Provides public interfaces of SDM parser.
SDMODataServiceDocument* sdmParseODataServiceDocumentXML(NSData* const content_in) SDMODataSchema* sdmParseODataSchemaXML(NSData* const content_in, SDMODataServiceDocument* const serviceDocument) NSMutableArray* sdmParseODataEntriesXML(NSData* const content_in, const SDMODataEntitySchema* const entitySchema, const SDMODataServiceDocument* const serviceDocument) SDMODataError* sdmParseODataErrorXML(NSData* const content_in) NSMutableArray* sdmParseFunctionImportResult(NSData* const content_in, const SDMODataFunctionImport* const functionImport) SDMOpenSearchDescription* sdmParseOpenSearchDescriptionXML(NSData* const content_in) SDMODataEntryXML* sdmBuildODataEntryXML (const SDMODataEntry *const entry, const enum TEN_ENTRY_OPERATIONS operation, const SDMODataServiceDocument *const serviceDocument, const BOOL serializeInlinedEntries) SDMODataFeedXML* sdmBuildODataFeedXML (NSArray *const entries, const enum TEN_ENTRY_OPERATIONS operation, const SDMODataServiceDocument *const serviceDocument, const BOOL serializeInlinedEntries) (NSString *)getEtag
/**
* Parses the service document XML and converts it to an Obj-C service document object.
*/
SDMODataServiceDocument* sdmParseODataServiceDocumentXML(NSData* const content_in) {
SDMODataServiceDocumentParser* svcDocParser = [[[SDMODataServiceDocumentParser alloc] init] autorelease];
[svcDocParser parse: content_in];
return svcDocParser.serviceDocument;
}
/**
* Parses and matches the schema with the service document and its collections. The function returns the same
* schema pointer as it can already be found in the serviceDocument.
*/
SDMODataSchema* sdmParseODataSchemaXML(NSData* const content_in, SDMODataServiceDocument* const serviceDocument) {
if (!serviceDocument)
//@throw [[[SDMParserException alloc] initWithName: @"NoServiceDocument" reason: @"No service document was provided" userInfo: nil] autorelease];
@throw [[[SDMParserException alloc] initWithError: ParserNoServiceDocument detailedError: @"No service document was provided"] autorelease];
SDMODataMetaDocumentParser* metaDocParser = [[[SDMODataMetaDocumentParser alloc] initWithServiceDocument: serviceDocument] autorelease];
[metaDocParser parse: content_in];
return serviceDocument.schema;
}
/**
* Parses a feed or entry XML and returns an array of parsed entry/entries.
* Any "inlined"entries or feed(s) will be parsed when service document is passed to the function. If "inlined" feed(s) or entries
* should not be returned pass nil in the service document parameter.
*/
NSMutableArray* sdmParseODataEntriesXML(NSData* const content_in, const SDMODataEntitySchema* const entitySchema, const SDMODataServiceDocument* const serviceDocument) {
if (!entitySchema)
//@throw [[[SDMParserException alloc] initWithName: @"NoEntitySchema" reason: @"No entity schema was provided" userInfo: nil] autorelease];
@throw [[[SDMParserException alloc] initWithError: ParserNoEntitySchema detailedError: @"No entity schema was provided"] autorelease];
SDMODataDataParser* dataParser = [[[SDMODataDataParser alloc] initWithEntitySchema: entitySchema andServiceDocument: serviceDocument] autorelease];
[dataParser parse: content_in];
return dataParser.entries;
}
/**
* Parses an OData error payload XML
* @see SDMODataError
*/
SDMODataError* sdmParseODataErrorXML(NSData* const content_in) {
SDMODataErrorXMLParser* errorParser = [[[SDMODataErrorXMLParser alloc] init] autorelease];
[errorParser parse: content_in];
return errorParser.odataError;
}
/**
* Parses the result payload XML of a function import.
* @returns Returns an array of entries.
* @remark Even if the result is not a feed or entry XML, the parser creates an entity schema out of the return type definition, so
* application developers can access the returned data in a uniform way. The supported return types are:
* - none
* - EDMSimpleType (for example: ReturnType="Edm.Int32"), the generated "entity" schema will be "element" with type Edm.Int32
* - ComplexType (for example: ReturnType="NetflixCatalog.Model.BoxArt")
* - Collection of an EDMSimpleType (for example: ReturnType="Collection(Edm.String)")
* - Collection of a ComplexType (for example: ReturnType="Collection(NetflixCatalog.Model.BoxArt)")
* - Entry (for example ReturnType="NetflixCatalog.Model.Title" EntitySet="Titles")
* - Feed (for example ReturnType="Collection(NetflixCatalog.Model.Title)" EntitySet="Titles")
*/
NSMutableArray* sdmParseFunctionImportResult(NSData* const content_in, const SDMODataFunctionImport* const functionImport) {
SDMFunctionImportResultParser* fiParser = [[[SDMFunctionImportResultParser alloc] initWithFunctionImport: functionImport] autorelease];
[fiParser parse: content_in];
return fiParser.entries;
}
/**
* Parses an XML that contains Open Search Description
* The parsed data is returned in an SDMOpenSearchDescription typed object.
*/
SDMOpenSearchDescription* sdmParseOpenSearchDescriptionXML(NSData* const content_in) {
SDMOpenSearchDescriptionXMLParser* osdParser = [[[SDMOpenSearchDescriptionXMLParser alloc] init] autorelease];
[osdParser parse: content_in];
return osdParser.openSearchDescription;
}
The SDMParser library communicates error conditions to the client via the dedicated SDMParserException exception class. Whenever a mandatory attribute is missing, the parser throws an exception.
The caller is responsible for error handling; this includes fetching the details included in the exception, logging information meant for debugging purposes, displaying a localized alert message, and providing a resolution or stopping the application flow.