File:  [LON-CAPA] / doc / loncapafiles / html_parser_check.piml
Revision 1.2: download - view: text, annotated - select for diffs
Mon Dec 6 20:34:57 2004 UTC (19 years, 4 months ago) by matthew
Branches: MAIN
CVS tags: version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_99_1, HEAD
Real Perl can't survive in XML so we have to disguise it.

    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.2 2004/12/06 20:34:57 matthew 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: **** 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: }
   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: **** WARNING: 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>