CSDLParser
open class CSDLParser : ObjectBase
Parser for Open Data Protocol (OData) service metadata documents (CSDL).
A new parser should be created for each parse call. A parser should not be shared by multiple threads.
-
Extra CSDL child elements for main schema (e.g. external annotations).
Declaration
Swift
final public var includeElements: XmlElementList -
Supplementary edmx:Reference elements. Defaults to an empty list.
See also
includeNamespace,includeReference.Declaration
Swift
final public var includeReferences: XmlElementList -
Pre-parsed schemas. Defaults to an empty list.
See also
includeSchema.Declaration
Swift
final public var includeSchemas: DataSchemaList -
A callback which will be used to resolve any CSDL Reference that is encountered during parsing, in order to fetch the referenced metadata. Must be set before
parseis called, or else any CSDL Reference that is encountered during parsing will result in aCsdlExceptionbeing thrown.Declaration
Swift
final public var csdlFetcher: CSDLFetcher? -
A bitmask of CSDL parser options.
See also
CsdlOption.Declaration
Swift
final public var csdlOptions: Int -
A bitmask of CSDL parser internal options.
See also
CsdlOption.Declaration
Swift
final public var internalOptions: Int -
Should parser errors be logged before they are thrown? Defaults to
true.Declaration
Swift
final public var logErrors: Bool -
Should parser warnings be logged? Defaults to
true.Declaration
Swift
final public var logWarnings: Bool -
Should parsing requests be traced? Defaults to
false.Declaration
Swift
final public var traceRequests: Bool -
Skip server-only elements in the csdl xml to be parsed and added to CsdlDocument. An element is server-only if it contains the
child element. Declaration
Swift
final public var excludeServerOnly: Bool -
Data service name. If data metrics are required, this property should be set before
parseis called, so that allDataMethodandEntitySetin the parsed document will have appropriately named metrics.Declaration
Swift
final public var serviceName: String? -
Default initializer.
Declaration
Swift
override public init() -
Add to
includeReferencesa supplementary CSDL edmx:Reference (with embedded edmx:Include). Call this function beforeparseif the document to be parsed is missing expected edmx:Reference elements for well-known schemas. This function generates an edmx:Reference with a fabricated “Uri” (with value “include/ns.xml”). It can be used together with acsdlFetcherwhich resolves documents either by fabricated location (include/ns.xml) or by namespace (ns).Declaration
Swift
open func includeNamespace(ns: String, alias: String? = nil)Parameters
nsFor the “Namespace” attribute of “edmx:Include”.
aliasFor the “Alias” attribute of “edmx:Include”.
-
Add to
includeReferencesa supplementary CSDL edmx:Reference (with embedded edmx:Include). Call this function beforeparseif the document to be parsed is missing expected edmx:Reference elements for well-known schemas. This function generates an edmx:Reference with a caller-specified “Uri”. It can be used together with acsdlFetcherwhich resolves documents either by caller-specified location (uri) or by namespace (ns).Declaration
Swift
open func includeReference(uri: String, ns: String, alias: String? = nil)Parameters
uriFor the “Uri” attribute of “edmx:Reference”.
nsFor the “Namespace” attribute of “edmx:Include”.
aliasFor the “Alias” attribute of “edmx:Include”.
-
Include the definitions of a pre-parsed schema into the document to be parsed. Call this function before
parseif the document to be parsed has an edmx:Reference element for a well-known schema, and the pre-parsed schema should be used rather than loading the referenced schema over the network.Declaration
Swift
open func includeSchema(_ schema: DataSchema)Parameters
schemaPre-parsed schema.
-
Merge into
includeReferencesandincludeElementsany extra annotation elements that are found intext.Declaration
Swift
open func mergeAnnotationsFrom(text: String, file: String, tags: StringSet = StringSet.empty) throwsParameters
textXML text to be merged.
fileName of file that
textcame from. Can be used in error messages when metadata is parsed.tagsCurrently unused.
-
Merge into
includeReferencesandincludeElementsany extra definition elements that are found intext.Declaration
Swift
open func mergeDefinitionsFrom(text: String, file: String, tags: StringSet = StringSet.empty) throwsParameters
textXML text to be merged.
fileName of file that
textcame from. Can be used in error messages when metadata is parsed.tagsNames of Core.Tag-styled vocabulary terms to be automatically applied to merged annotation elements (e.g. containing “Offline.ClientOnly”).
-
Merge into
includeElementsany extra Schema elements that are found intext.Declaration
Swift
open func mergeSchemasFrom(text: String, file: String) throwsParameters
textXML text to be merged.
fileName of file that
textcame from. Can be used in error messages when metadata is parsed. -
Parse the text of an Open Data Protocol (OData) service metadata (CSDL) document. Supports OData versions 1.0 to 4.0.
Declaration
Swift
open func parse(_ text: String, url: String) throws -> CSDLDocumentParameters
textText of the service metadata document.
urlURL of the service metadata document. Used for resolving relative URLs if any CSDL Reference is encountered during parsing. May also be included in exception messages.
Return Value
Parsed CSDL document.