ns.mli 1.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
open Encodings

exception UnknownPrefix of Utf8.t

type t = int  (* Namespaces (URIs) *)
val mk: Utf8.t -> t
val value: t -> Utf8.t
val empty : t
val compare: t -> t -> int
val hash: t -> int
val equal: t -> t -> bool

type table  (* prefix => namespace *)
val empty_table: table   
  (* Contains only xml -> "http://www.w3.org/XML/1998/namespace" *)

type qname = t * Utf8.t

val add_prefix: Utf8.t -> t -> table -> table

val process_start_tag:
  table -> string -> (string * string) list -> 
    table * qname * (qname * Utf8.t) list

val print_qname: Format.formatter -> qname -> unit 

val map_tag: table -> Utf8.t -> qname
val map_attr: table -> Utf8.t -> qname
val map_prefix: table -> Utf8.t -> t

(* Support for printing XML documents *)

module Printer : sig
  type printer

  val printer: table -> printer
  val register_tag: printer -> qname -> unit
  val register_attr: printer -> qname -> unit

  val prefixes: printer -> (Utf8.t * t) list
  val tag: printer -> qname -> string
  val attr: printer -> qname -> string
end
    

(***)
val register_prefix : Utf8.t -> t -> unit
val prefix : t -> Utf8.t

val dump_prefix_table : Format.formatter -> unit