aboutsummaryrefslogtreecommitdiffstats
path: root/lib/relation.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2024-11-26 04:24:42 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2024-11-26 04:24:42 -0300
commit872fc56a414f8c2a4818463be9e104195a0b6242 (patch)
tree07d1591e043031fe21211400d53f4dd7c4b47bd7 /lib/relation.ml
parentf487fbee29dcebf62400be20fd509ba1794e952f (diff)
downloadSakura-872fc56a414f8c2a4818463be9e104195a0b6242.tar.gz
Sakura-872fc56a414f8c2a4818463be9e104195a0b6242.zip
send XML through sockets
Diffstat (limited to 'lib/relation.ml')
-rw-r--r--lib/relation.ml19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/relation.ml b/lib/relation.ml
index 1854875..5a896d4 100644
--- a/lib/relation.ml
+++ b/lib/relation.ml
@@ -1,14 +1,16 @@
-open Sexplib0
-open Sexplib0.Sexp_conv
+
module Protocol = struct
- type tuple = string list [@@deriving sexp]
+ open Protocol_conv_xml
+ open Sexplib0.Sexp_conv
+ type tuple =
+ string list [@@deriving sexp, protocol ~driver:(module Xml_light)]
type relation =
{ attribute_name: string;
attribute_type: string;
tuples: tuple }
- [@@deriving sexp]
- type t = relation list [@@deriving sexp]
+ [@@deriving sexp, protocol ~driver:(module Xml_light)]
+ type t = relation list [@@deriving sexp, protocol ~driver:(module Xml_light)]
end
let write_and_retrieve() =
@@ -40,6 +42,9 @@ let write_and_retrieve() =
let+ (_, Command.Read last_name) = Command.commit_and_perform (List.tl stream) locations command_read2 in
(* List.iter (fun a -> print_endline a) (List.map Bytes.to_string first_name); *)
(* List.iter (fun a -> print_endline a) (List.map Bytes.to_string last_name); *)
- Ok (Sexp.to_string (Protocol.sexp_of_t [{attribute_name = "user/first-name"; attribute_type = "string"; tuples = List.map Bytes.to_string first_name};
- {attribute_name = "user/last-name"; attribute_type = "string"; tuples = List.map Bytes.to_string last_name}]))
+ let relation_result: Protocol.relation list =
+ [{attribute_name = "user/first-name"; attribute_type = "string"; tuples = List.map Bytes.to_string first_name};
+ {attribute_name = "user/last-name"; attribute_type = "string"; tuples = List.map Bytes.to_string last_name}] in
+ Ok (Xml.to_string (Protocol.to_xml_light relation_result))
+ (* (Sexp.to_string (Protocol.sexp_of_t )) *)
[@@warning "-8"] (* Suppress pattern match incomplete warnings *)