type Person = FPerson | MPerson;; type FPerson = [ Name Children ];; type MPerson = [ Name Children ];; type Children = [Person*];; type Name = [ PCDATA ];; type Man = [ Sons Daughters ];; type Woman = [ Sons Daughters ];; type Sons = [ Man* ];; type Daughters = [ Woman* ];; let fun split (Person -> Man | Woman) [ n c ] -> let tag = match g with "F" -> `woman | "M" -> `man in match (map c with x -> split x) with [ (s::Man|d::Woman)* ] -> <(tag) name=n>[ s d ] ;; let x = match argv [] with | [src] -> (match (load_xml src :? [Person*]) with l -> dump_xml_utf8 (map l with x -> split x)) | _ -> raise "Invalid command line";;