Source

hasexp / xmlcomb.ml

open Xml
(* open Spotlib.Spot *)
open Spotlib.Spot.Stream

module Primitive = struct
  type t = Xml.xml

  let leaf = function
    | (PCData _ as e) -> singleton e
    | _ -> null

  let pcdata = leaf

  let branch = function
    | (Element _ as e) -> singleton e
    | _ -> null

  let tag = branch

  let children = function
    | PCData _ -> null
    | Element (_, _, xs) -> of_list xs

  let tag_p p t = match t with
    | Element (tag, _, _) when p tag -> singleton t
    | _ -> null

  let tag_named name = tag_p (fun x -> x = name)
end

include Primitive
include Comb.Make(Primitive)