package mlgpx

  1. Overview
  2. Docs

Module Gpx.ExtensionSource

Extension mechanism for custom GPX elements

The Extension module provides support for custom XML elements that extend the standard GPX format. Extensions allow applications to embed additional data while maintaining compatibility with standard GPX readers.

Extension mechanism for custom GPX elements

Sourcetype t = {
  1. namespace : string option;
    (*

    Optional XML namespace

    *)
  2. name : string;
    (*

    Element name

    *)
  3. attributes : (string * string) list;
    (*

    Element attributes

    *)
  4. content : content;
    (*

    Element content

    *)
}

Main extension type

Sourceand content =
  1. | Text of string
    (*

    Simple text content

    *)
  2. | Elements of t list
    (*

    Nested elements

    *)
  3. | Mixed of string * t list
    (*

    Mixed text and elements

    *)

Content types for extensions

Extension Constructors

Sourceval make : ?namespace:string -> name:string -> attributes:(string * string) list -> content:content -> unit -> t

Create extension with flexible content

Sourceval make_text : name:string -> ?namespace:string -> ?attributes:(string * string) list -> string -> t

Create an extension with text content

Sourceval make_elements : name:string -> ?namespace:string -> ?attributes:(string * string) list -> t list -> t

Create an extension with element content

Sourceval make_mixed : name:string -> ?namespace:string -> ?attributes:(string * string) list -> string -> t list -> t

Create an extension with mixed content

Extension Operations

Sourceval name : t -> string

Get extension name

Sourceval namespace : t -> string option

Get optional namespace

Sourceval attributes : t -> (string * string) list

Get attributes

Sourceval content : t -> content

Get content

Sourceval find_attribute : string -> t -> string option

Find attribute value by name

Sourceval set_attribute : string -> string -> t -> t

Add or update attribute

Sourceval compare : t -> t -> int

Compare extensions

Sourceval equal : t -> t -> bool

Test extension equality

Sourceval pp : Format.formatter -> t -> unit

Pretty print extension

Content Operations

Sourceval text_content : string -> content

Create text content

Sourceval elements_content : t list -> content

Create elements content

Sourceval mixed_content : string -> t list -> content

Create mixed content

Sourceval is_text_content : content -> bool

Check if content is text

Sourceval is_elements_content : content -> bool

Check if content is elements

Sourceval is_mixed_content : content -> bool

Check if content is mixed

Sourceval text_content_extract : content -> string option

Extract text content

Sourceval elements_content_extract : content -> t list option

Extract element content

Sourceval mixed_content_extract : content -> (string * t list) option

Extract mixed content

OCaml

Innovation. Community. Security.