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_m (MPerson -> Man) <_ ..>[ <_>n <_>[(mc::<_ gender="M">_ | fc::_)*] ] -> let s = map mc with x -> split_m x in let d = map fc with x -> split_f x in [ s d ] let split_f (FPerson -> Woman) <_ ..>[ <_>n <_>[(mc::<_ gender="M">_ | fc::_)*] ] -> let s = map mc with x -> split_m x in let d = map fc with x -> split_f x in [ s d ] match argv [] with | [ f ] -> (match load_xml f with | (l & [Person*]) -> (map l with x & MPerson -> split_m x | x & FPerson -> split_f x) | _ -> raise "Invalid document") | _ -> raise "Invalid command line"