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 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 ] match argv [] with | [ f ] -> (match (load_xml f :? [ Person* ]) with | <_>l -> print_xml ((map l with x -> split x))) | _ -> raise "Invalid command line"