<commit_before>module type GraphMlWriter =
sig
  type t
  type node

  val start: out_channel -> t
  val write_key: t -> string -> string -> string -> string option -> unit
  val start_graph: t -> unit
  val write_metadata: t -> string -> string -> unit
  val write_node: t -> node -> (string * string) list -> unit
  val write_edge: t -> node -> node -> (string * string) list -> unit
  val stop: t -> unit
end

module type StringGraphMlWriter = GraphMlWriter with type node = string

module XmlGraphMlWriter: StringGraphMlWriter =
struct
  type t = unit BatIO.output
  type node = string

  open Goblintutil

  let start out =
    let f = BatIO.output_channel out in
    BatPrintf.fprintf f "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    BatPrintf.fprintf f "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">\n";
    f

  let write_key f fr key typ default_value =
    match default_value with
    | Some value ->
      BatPrintf.fprintf f "  <key id=\"%s\" for=\"%s\" attr.name=\"%s\" attr.type=\"%s\">\n    <default>%s</default>\n  </key>\n" (escape key) (escape fr) (escape key) (escape typ) (escape value)
    | None ->
      BatPrintf.fprintf f "  <key id=\"%s\" for=\"%s\" attr.name=\"%s\" attr.type=\"%s\"/>\n" (escape key) (escape fr) (escape key) (escape typ)

  let start_graph f =<commit_msg>Remove xsi:schemaLocation from witness XML because witnesslinter doesn't like it (issue #147)<commit_after>module type GraphMlWriter =
sig
  type t
  type node

  val start: out_channel -> t
  val write_key: t -> string -> string -> string -> string option -> unit
  val start_graph: t -> unit
  val write_metadata: t -> string -> string -> unit
  val write_node: t -> node -> (string * string) list -> unit
  val write_edge: t -> node -> node -> (string * string) list -> unit
  val stop: t -> unit
end

module type StringGraphMlWriter = GraphMlWriter with type node = string

module XmlGraphMlWriter: StringGraphMlWriter =
struct
  type t = unit BatIO.output
  type node = string

  open Goblintutil

  let start out =
    let f = BatIO.output_channel out in
    BatPrintf.fprintf f "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    (* BatPrintf.fprintf f "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">\n"; *)
    BatPrintf.fprintf f "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
    f

  let write_key f fr key typ default_value =
    match default_value with
    | Some value ->
      BatPrintf.fprintf f "  <key id=\"%s\" for=\"%s\" attr.name=\"%s\" attr.type=\"%s\">\n    <default>%s</default>\n  </key>\n" (escape key) (escape fr) (escape key) (escape typ) (escape value)
    | None ->
      BatPrintf.fprintf f "  <key id=\"%s\" for=\"%s\" attr.name=\"%s\" attr.type=\"%s\"/>\n" (escape key) (escape fr) (escape key) (escape typ)

  let start_graph f =
{'fraction_non_alphanumeric': 0.16245712503897725, 'fraction_numerical': 0.008730901153726224, 'mean_word_length': 3.260292164674635, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 2, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 15}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2846101', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1085, 'n_words': 306}