sub get_dtd_errors { my $elt = shift; use XML::LibXML; my $parser = XML::LibXML->new(); $parser->validation(1); # switches DTD validation on my $tag = $elt->tag; my $element = &get_xml_prolog($tag) . $elt->sprint; if ( $element =~ m/]*? e:id="(.*?)"/ ) { $element_id = $1; } # warn "Processing:\n\t$element"; ### remove non-DTD tagging $element =~ s/ (e:.*?|xmlns|xmlns:e|xml:space)=".*?"//g; # remove EE attributes $element =~ s/ (refentry|refid|rel|style)=".*?"//g; # remove xref attributes $element =~ s/ (lid)=".*?"//g; # remove 'lid' attributes $element =~ s/<\/?e:TEXT[^>]*?>//g; # remove EE tags $element =~ s/<\/?e:INTER[^>]*?>//g; eval { my $doc = $parser->parse_string($element) }; if (my $err = $@) { my @err = split /\n/, $err; my $last = pop(@err); my $modulo3 = 0; my $skip = 0; # allows us to ignore certain messages my $vfSectLoose = 0; foreach my $line (@err) { if ($line =~ m/vfSectLoose/ ) {$vfSectLoose = 1;} } foreach $line (@err) { ### Each error comes in three lines: the message, the text fragment containing the error, and a pointer ### we format the different lines in slightly different ways if ( $modulo3 == 0 ) { # if ( $line =~ m/No declaration for attribute wotd of element Entry/ ) { $skip = 1; } if ( !$skip ) { $line =~ s/^\:\d+\: //; $line = "
  • " . $line . "\n

    \n"; $dtd_errors++; } } if ( $modulo3 == 1 && !$skip) { $line =~ s//>/g; $line = "

    " . $line . "
    \n"; } if ( $modulo3 == 2 && !$skip ) { $line =~ s/ /-/g; $line = "
    " . $line . "

  • \n"; } $dtd_error_page .= $line unless $skip; $modulo3++; if ( $modulo3 == 3 ) { $modulo3 = 0 ; $skip = 0; # reset skip } } }