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 load_xml "large.xml" with (l & [Person*]) -> (map l with x -> split x) | _ -> raise "Invalid document";;