Annotation of doc/loncapafiles/html_parser_check.piml, revision 1.1
1.1 ! matthew 1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN"
! 2: "http://lpml.sourceforge.net/DTD/piml.dtd">
! 3: <!-- ntpcheck.piml -->
! 4: <!-- Matthew Hall -->
! 5:
! 6: <!-- $Id: ntpcheck.piml,v 1.6 2004/08/26 19:25:15 albertel Exp $ -->
! 7:
! 8: <!--
! 9:
! 10: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
! 11:
! 12: LON-CAPA is free software; you can redistribute it and/or modify
! 13: it under the terms of the GNU General Public License as published by
! 14: the Free Software Foundation; either version 2 of the License, or
! 15: (at your option) any later version.
! 16:
! 17: LON-CAPA is distributed in the hope that it will be useful,
! 18: but WITHOUT ANY WARRANTY; without even the implied warranty of
! 19: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 20: GNU General Public License for more details.
! 21:
! 22: You should have received a copy of the GNU General Public License
! 23: along with LON-CAPA; if not, write to the Free Software
! 24: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! 25:
! 26: /home/httpd/html/adm/gpl.txt
! 27:
! 28: http://www.lon-capa.org/
! 29:
! 30: -->
! 31:
! 32: <piml>
! 33: <targetroot>/</targetroot>
! 34: <files>
! 35: <file>
! 36: <target dist="default">/home/httpd/lonUsers</target>
! 37: <perlscript mode="fg">
! 38: #use the directory
! 39: use strict;
! 40: use HTML::Parser;
! 41:
! 42: my $version = $HTML::Parser::VERSION;
! 43:
! 44: ##
! 45: ## First test
! 46: ##
! 47: my $text='';
! 48: my $p = HTML::Parser->new(api_version => 3);
! 49: $p->handler(start =>
! 50: sub {
! 51: my($tag, $attr) = @_;
! 52: $text .= "S[$tag";
! 53: for my $k (sort keys %$attr) {
! 54: my $v = $attr->{$k};
! 55: $text .= " key $k= value $v";
! 56: }
! 57: $text .= "]";
! 58: }, "tagname,attr");
! 59: $p->handler(text =>
! 60: sub {
! 61: $text .= 'T{'.shift().'}';
! 62: }, "text");
! 63: $text='';
! 64: $p->parse('<img a="b" "=\'"\' c=d />')->eof;
! 65:
! 66: my $first_test_result = $text;
! 67: my $first_expected_result =
! 68: q{S[img key "= value " key /= value / key a= value b key c= value d]};
! 69: if (! $first_test_result) {
! 70: print "Unable to run first HTML::Parser test\n";
! 71: } elsif ($first_test_result ne $first_expected_result) {
! 72: print <<"END";
! 73: **** WARNING: HTML::Parser is not working properly.
! 74: You are using version $version. For test 1 it returned
! 75: "$first_test_result"
! 76: END
! 77: } else {
! 78: print "First HTML::Parser test looks good.\n";
! 79: }
! 80:
! 81:
! 82: ##
! 83: ## Second test
! 84: ##
! 85: $p->xml_mode(1);
! 86: $text='';
! 87: $p->parse('<img a="b" "=\'"\' c=d />')->eof;
! 88: my $second_test_result = $text;
! 89: my $second_expected_result =
! 90: q{S[img key "= value " key a= value b key c= value d]};
! 91: if (! $second_test_result) {
! 92: print "Unable to run second HTML::Parser test\n";
! 93: } elsif ($second_test_result ne $second_expected_result) {
! 94: print <<"END";
! 95: **** WARNING: HTML::Parser is not working properly.
! 96: You are using version $version. For test 2 it returned
! 97: "$second_test_result"
! 98: END
! 99: } else {
! 100: print "Second HTML::Parser test looks good.\n";
! 101: }
! 102:
! 103: </perlscript>
! 104: </file>
! 105: </files>
! 106: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>