Extension ODFvalidator

DESCRIPTION

Extension that supports OpenDocument validation

DEPENDS

FUNCTIONS

validate()

my $obj=Ext::ODFvalidator->validate('file:/');
$obj->{errors};
$obj->{warnings};
$obj->{solutions};

CODE NOT IMPLEMENTED YET

# other_checks($file, $xmlfile)
#               Performs other checks other than schema validation. For
#               example, it warns if the document uses non-ODF namespaces.
sub other_checks {
        my ($file, $subfile) = @_;
        my $content = '';
        {
                local $/;
                $content = `unzip -p $file $subfile`;
        }
        # Looks like OOo doesn't include new-line chars either.
        #my $last_char = substr($content,length($content)-1,1);
        #if ($last_char ne "\n") {
        #       warning("$subfile does not end in a new-line character.");
        #}
        my %saw = ($content =~ m/xmlns:(.*?)="([^\"]+)"/gms);
        foreach my $ns (keys %saw) {
                # remove OpenDocument name spaces
                my $uri = $saw{$ns};
                if (exists $uris{$uri}) {
                        delete $saw{$ns};
                }
        }
        # look at non-OpenDocument name spaces
        foreach my $ns (keys %saw) {
                my $uri = $saw{$ns};
                my @uses = ($content =~ m/[<|\s]$ns:/gms);
                my $use = $#uses;
                if ($use > 0) {
                        warning("$subfile: non-ODF xmlns $ns ($uri) used $use time(s)");
                }
        }
}

AUTHORS

Implemented to Cyclone3 and modified by Roman Fordinal (roman.fordinal@comsultia.com)

Original odfvalidator.in script by Alex Hudson (alex@stratagia.co.uk) for OpenDocument Fellowship

COPYRIGHT

Copyright 2006 Alex Hudson, 2007 Roman Fordinal

This is free software. You may redistribute it under the terms GNU General Public License Version 2 or at your option any later version.


If published informations are not helpfull, something is missing or wrong, please report. Thanx for contribution.
This content is generated from file 'http://svn.cyclone3.org/trunk/frame/_addons/Ext/ODFvalidator/_init.pm'

AddThis Social Bookmark Button RSS

User Comments