let string_of_id = function
    Simple_id s -> s
  | Html_id s -> Printf.sprintf "<%s>" s
  | Double_quoted_id s ->
      let len = String.length s in
      let b = Buffer.create len in
      for i = 0 to len - 1 do
        match s.[i] with
          '"' -> Buffer.add_string b "\\\""
        | c -> Buffer.add_char b c
      done;
      Printf.sprintf "\"%s\"" (Buffer.contents b)