GPS Exchange Format library/CLI in OCaml
1(** Extension mechanism for custom GPX elements *)
2
3(** Main extension type *)
4type t = {
5 namespace : string option; (** Optional XML namespace *)
6 name : string; (** Element name *)
7 attributes : (string * string) list; (** Element attributes *)
8 content : content; (** Element content *)
9}
10
11(** Content types for extensions *)
12and content =
13 | Text of string (** Simple text content *)
14 | Elements of t list (** Nested elements *)
15 | Mixed of string * t list (** Mixed text and elements *)
16
17(** {2 Extension Constructors} *)
18
19(** Create extension with flexible content *)
20val make : ?namespace:string -> name:string -> attributes:(string * string) list -> content:content -> unit -> t
21
22(** Create an extension with text content *)
23val make_text : name:string -> ?namespace:string -> ?attributes:(string * string) list -> string -> t
24
25(** Create an extension with element content *)
26val make_elements : name:string -> ?namespace:string -> ?attributes:(string * string) list -> t list -> t
27
28(** Create an extension with mixed content *)
29val make_mixed : name:string -> ?namespace:string -> ?attributes:(string * string) list -> string -> t list -> t
30
31(** {2 Extension Operations} *)
32
33(** Get extension name *)
34val name : t -> string
35
36(** Get optional namespace *)
37val namespace : t -> string option
38
39(** Get attributes *)
40val attributes : t -> (string * string) list
41
42(** Get content *)
43val content : t -> content
44
45(** Find attribute value by name *)
46val find_attribute : string -> t -> string option
47
48(** Add or update attribute *)
49val set_attribute : string -> string -> t -> t
50
51(** Compare extensions *)
52val compare : t -> t -> int
53
54(** Test extension equality *)
55val equal : t -> t -> bool
56
57(** Pretty print extension *)
58val pp : Format.formatter -> t -> unit
59
60(** {2 Content Operations} *)
61
62(** Create text content *)
63val text_content : string -> content
64
65(** Create elements content *)
66val elements_content : t list -> content
67
68(** Create mixed content *)
69val mixed_content : string -> t list -> content
70
71(** Check if content is text *)
72val is_text_content : content -> bool
73
74(** Check if content is elements *)
75val is_elements_content : content -> bool
76
77(** Check if content is mixed *)
78val is_mixed_content : content -> bool
79
80(** Extract text content *)
81val text_content_extract : content -> string option
82
83(** Extract element content *)
84val elements_content_extract : content -> t list option
85
86(** Extract mixed content *)
87val mixed_content_extract : content -> (string * t list) option