XML/TX version 0.01 =================== XML::TX - Perl extension for validation of XML based on types SYNOPSIS use XML::TX; my $types={trans => text("pt"), pos1 => sub{text($v{'xml:lang'} || "pt") }, pos => enumFromFile("POS"), orth => text("en"), url => "urlActive", url2 => "url", }; markit($filename,$types); ## marke invlaid fields fixit($filename,$types); ## tries to fix invalid fields enum("day",[1..31]); ## 1 <= day <= 31 enumFromFile("tpos","POS"); ## valid tpos are stored in "POS" file fromRegExp("elem",'regExp') ## valid elem must match regExp isvalid( 39,"day") ## returns false addType( urlActive => ## urlActive is valid if we can get it { markit => sub{ $c = markAsErr($c) unless (LWP::Simple::head($c)); toxml()}, } ); markAsErr($string) ## put error marker before string setErrTag(">>>>") ## define error marker (default = "##") text("en") ## type of a English NL field text("pt") ## type of a Portuguese NL field ABSTRACT C is Perl extension for validation of XML documents, based on types. This module helps in the validation of XML files in two steps: defining how to validate (and fix) each type of information; associating a type with each element. There are some predefined types: url Each type has a function for marking invalid values (markit) and a function for fixing an invalid element (fixit). In most cases it is dificult to fix invalid values. If no fixit function is defined, fixit function will be just markit. DESCRIPTION Functions for validation =head2 Function C markit($filename,$types); ## marke invalid fields =head2 Function C fixit($filename,$types); ## tries to fix invalid fields Functions related with marking invalid values markAsErr($string) ## put error marker before string setErrTag(">>>>") ## define error marker (default = "##") Functions for building types =head2 Function C enum("day",[1..31]); ## 1 <= day <= 31 =head2 Function C enumFromFile("tpos","POS"); ## valid tpos are stored in "POS" file =head2 Function C fromRegExp("elem",'regExp') ## valid elem must match regExp =head2 Function C addType( urlActive => ## urlActive is valid if we can get it { markit => sub{ $c = markAsErr($c) unless (LWP::Simple::head($c)); toxml()}, } ); =head2 Function C text("en") ## type of a English NL field text("pt") ## type of a Portuguese NL field INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: XML::DT COPYRIGHT AND LICENCE Copyright (C) 2005 Jose Joao Almeida This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.