File:  [LON-CAPA] / doc / loncapafiles / html_parser_check.piml
Revision 1.3: download - view: text, annotated - select for diffs
Thu Jul 14 03:26:56 2005 UTC (18 years, 9 months ago) by albertel
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, bz6209-base, bz6209, HEAD, GCI_3, GCI_2, GCI_1, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
- this not working is an ERROR

    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: html_parser_check.piml,v 1.3 2005/07/14 03:26:56 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: 
   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-&gt;new(api_version =&gt; 3);
   49: $p-&gt;handler(start =&gt;
   50: 	    sub {
   51: 		 my($tag, $attr) = @_;
   52: 		 $text .= "S[$tag";
   53: 		 for my $k (sort keys %$attr) {
   54: 		     my $v =  $attr-&gt;{$k};
   55: 		     $text .= " key $k= value $v";
   56: 		 }
   57: 		 $text .= "]";
   58: 	     }, "tagname,attr");
   59: $p-&gt;handler(text =&gt;
   60: 	     sub {
   61: 		 $text .= 'T{'.shift().'}';
   62: 	     }, "text");
   63: $text='';
   64: $p-&gt;parse('&lt;img a="b" "=\'"\' c=d /&gt;')-&gt;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 &lt;&lt;"END";
   73: **** ERROR: HTML::Parser is not working properly.
   74:               You are using version $version.  For test 1 it returned
   75:               "$first_test_result"
   76: END
   77: }
   78: 
   79: 
   80: ##
   81: ## Second test
   82: ##
   83: $p-&gt;xml_mode(1);
   84: $text='';
   85: $p-&gt;parse('&lt;img a="b" "=\'"\' c=d /&gt;')-&gt;eof;
   86: my $second_test_result = $text;
   87: my $second_expected_result = 
   88:     q{S[img key "= value " key a= value b key c= value d]};
   89: if (! $second_test_result) {
   90:     print "Unable to run second HTML::Parser test\n";
   91: } elsif ($second_test_result ne $second_expected_result) {
   92:     print &lt;&lt;"END";
   93: **** ERROR: HTML::Parser is not working properly.
   94:               You are using version $version.  For test 2 it returned
   95:               "$second_test_result"
   96: END
   97: }
   98: 
   99: </perlscript>
  100: </file>
  101: </files>
  102: </piml>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>