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 (MPerson -> Man ; FPerson -> Woman) [ n [(mc::MPerson | fc::FPerson)*] ] -> let tag = match g with "F" -> `woman | "M" -> `man in let s = map mc with x -> split x in let d = map fc with x -> split x in <(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";;