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.

  • 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 parse is called, or else any CSDL Reference that is encountered during parsing will result in a CsdlException being thrown.

    Declaration

    Swift

    final public var csdlFetcher: CSDLFetcher?
  • A bitmask of CSDL parser options.

    See also

    CsdlOption.

    Declaration

    Swift

    final public var csdlOptions: Int
  • Should parser errors be logged before they are thrown?

    Declaration

    Swift

    final public var logErrors: Bool
  • Should parser warnings be logged?

    Declaration

    Swift

    final public var logWarnings: Bool
  • Should parsing requests be traced?

    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 parse is called, so that all DataMethod and EntitySet in the parsed document will have appropriately named metrics.

    Declaration

    Swift

    final public var serviceName: String?
  • Default initializer.

    Declaration

    Swift

    override public init()
  • Add to includeReferences a supplementary CSDL edmx:Reference (with embedded edmx:Include). Call this function before parse if 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 a csdlFetcher which resolves documents either by fabricated location (include/ns.xml) or by namespace (ns).

    See also

    csdlOptions, includeReference.

    Declaration

    Swift

    open func includeNamespace(ns: String, alias: String? = nil)

    Parameters

    ns

    For the “Namespace” attribute of “edmx:Include”.

    alias

    For the “Alias” attribute of “edmx:Include”.

  • Add to includeReferences a supplementary CSDL edmx:Reference (with embedded edmx:Include). Call this function before parse if 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 a csdlFetcher which resolves documents either by caller-specified location (uri) or by namespace (ns).

    See also

    csdlOptions, includeNamespace.

    Declaration

    Swift

    open func includeReference(uri: String, ns: String, alias: String? = nil)

    Parameters

    uri

    For the “Uri” attribute of “edmx:Reference”.

    ns

    For the “Namespace” attribute of “edmx:Include”.

    alias

    For the “Alias” attribute of “edmx:Include”.

  • Include the definitions of a pre-parsed schema into the document to be parsed. Call this function before parse if 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

    schema

    Pre-parsed schema.

  • 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 -> CSDLDocument

    Parameters

    text

    Text of the service metadata document.

    url

    URL 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.