Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Deep recursion error using LibXML

by mertserger (Curate)
on Dec 30, 2010 at 13:19 UTC ( #879787=note: print w/replies, xml ) Need Help??


in reply to Re: Deep recursion error using LibXML
in thread Deep recursion error using LibXML

I am not sure where to add that line to my code.

I have looked at the code again and I think the problem is in the subroutine which is trying to parse the entry against the DTD, rather than the code finding additional errors. The DTD checking sub routine is:
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/<Entry[^>]*? 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 co +ntaining 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 e +lement Entry/ ) { $skip = 1; } if ( !$skip ) { $line =~ s/^\:\d+\: //; $line = "<li>" . $line . "\n<p>\n"; $dtd_errors++; } } if ( $modulo3 == 1 && !$skip) { $line =~ s/</&lt;/g; $line =~ s/>/&gt;/g; $line = "<pre>" . $line . "</pre>\n"; } if ( $modulo3 == 2 && !$skip ) { $line =~ s/ /-/g; $line = "<pre>" . $line . "</pre></p></li>\n"; } $dtd_error_page .= $line unless $skip; $modulo3++; if ( $modulo3 == 3 ) { $modulo3 = 0 ; $skip = 0; # reset skip } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://879787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2022-05-21 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (78 votes). Check out past polls.

    Notices?