← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:28 2013

Filename/usr/lib64/perl5/vendor_perl/5.16.0/x86_64-linux/XML/LibXML/Error.pm
StatementsExecuted 123 statements in 13.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11126.5ms54.8msXML::LibXML::Error::::BEGIN@257XML::LibXML::Error::BEGIN@257
111102µs203µsXML::LibXML::Error::::BEGIN@11XML::LibXML::Error::BEGIN@11
11195µs316µsXML::LibXML::Error::::BEGIN@22XML::LibXML::Error::BEGIN@22
11185µs152µsXML::LibXML::Error::::BEGIN@245XML::LibXML::Error::BEGIN@245
11181µs255µsXML::LibXML::Error::::BEGIN@67XML::LibXML::Error::BEGIN@67
11170µs234µsXML::LibXML::Error::::BEGIN@56XML::LibXML::Error::BEGIN@56
11166µs234µsXML::LibXML::Error::::BEGIN@63XML::LibXML::Error::BEGIN@63
11165µs256µsXML::LibXML::Error::::BEGIN@47XML::LibXML::Error::BEGIN@47
11163µs275µsXML::LibXML::Error::::BEGIN@61XML::LibXML::Error::BEGIN@61
11162µs235µsXML::LibXML::Error::::BEGIN@36XML::LibXML::Error::BEGIN@36
11161µs233µsXML::LibXML::Error::::BEGIN@37XML::LibXML::Error::BEGIN@37
11161µs247µsXML::LibXML::Error::::BEGIN@64XML::LibXML::Error::BEGIN@64
11159µs236µsXML::LibXML::Error::::BEGIN@46XML::LibXML::Error::BEGIN@46
11158µs225µsXML::LibXML::Error::::BEGIN@42XML::LibXML::Error::BEGIN@42
11155µs88µsXML::LibXML::Error::::BEGIN@12XML::LibXML::Error::BEGIN@12
11154µs135µsXML::LibXML::Error::::BEGIN@83XML::LibXML::Error::BEGIN@83
11153µs290µsXML::LibXML::Error::::BEGIN@20XML::LibXML::Error::BEGIN@20
11153µs275µsXML::LibXML::Error::::BEGIN@34XML::LibXML::Error::BEGIN@34
11152µs242µsXML::LibXML::Error::::BEGIN@54XML::LibXML::Error::BEGIN@54
11149µs262µsXML::LibXML::Error::::BEGIN@57XML::LibXML::Error::BEGIN@57
11149µs343µsXML::LibXML::Error::::BEGIN@19XML::LibXML::Error::BEGIN@19
11149µs228µsXML::LibXML::Error::::BEGIN@58XML::LibXML::Error::BEGIN@58
11148µs240µsXML::LibXML::Error::::BEGIN@52XML::LibXML::Error::BEGIN@52
11148µs110µsXML::LibXML::Error::::BEGIN@15XML::LibXML::Error::BEGIN@15
11148µs229µsXML::LibXML::Error::::BEGIN@65XML::LibXML::Error::BEGIN@65
11148µs225µsXML::LibXML::Error::::BEGIN@62XML::LibXML::Error::BEGIN@62
11147µs284µsXML::LibXML::Error::::BEGIN@35XML::LibXML::Error::BEGIN@35
11147µs216µsXML::LibXML::Error::::BEGIN@59XML::LibXML::Error::BEGIN@59
11147µs221µsXML::LibXML::Error::::BEGIN@48XML::LibXML::Error::BEGIN@48
11147µs233µsXML::LibXML::Error::::BEGIN@51XML::LibXML::Error::BEGIN@51
11147µs222µsXML::LibXML::Error::::BEGIN@53XML::LibXML::Error::BEGIN@53
11146µs237µsXML::LibXML::Error::::BEGIN@66XML::LibXML::Error::BEGIN@66
11146µs218µsXML::LibXML::Error::::BEGIN@39XML::LibXML::Error::BEGIN@39
11146µs213µsXML::LibXML::Error::::BEGIN@60XML::LibXML::Error::BEGIN@60
11146µs219µsXML::LibXML::Error::::BEGIN@45XML::LibXML::Error::BEGIN@45
11146µs218µsXML::LibXML::Error::::BEGIN@55XML::LibXML::Error::BEGIN@55
11146µs215µsXML::LibXML::Error::::BEGIN@40XML::LibXML::Error::BEGIN@40
11145µs213µsXML::LibXML::Error::::BEGIN@43XML::LibXML::Error::BEGIN@43
11145µs212µsXML::LibXML::Error::::BEGIN@44XML::LibXML::Error::BEGIN@44
11145µs211µsXML::LibXML::Error::::BEGIN@50XML::LibXML::Error::BEGIN@50
11145µs213µsXML::LibXML::Error::::BEGIN@49XML::LibXML::Error::BEGIN@49
11144µs210µsXML::LibXML::Error::::BEGIN@41XML::LibXML::Error::BEGIN@41
11123µs23µsXML::LibXML::Error::::BEGIN@17XML::LibXML::Error::BEGIN@17
0000s0sXML::LibXML::Error::::__ANON__[:25]XML::LibXML::Error::__ANON__[:25]
0000s0sXML::LibXML::Error::::__ANON__[:28]XML::LibXML::Error::__ANON__[:28]
0000s0sXML::LibXML::Error::::__ANON__[:82]XML::LibXML::Error::__ANON__[:82]
0000s0sXML::LibXML::Error::::_callback_errorXML::LibXML::Error::_callback_error
0000s0sXML::LibXML::Error::::_instant_error_callbackXML::LibXML::Error::_instant_error_callback
0000s0sXML::LibXML::Error::::_report_errorXML::LibXML::Error::_report_error
0000s0sXML::LibXML::Error::::_report_warningXML::LibXML::Error::_report_warning
0000s0sXML::LibXML::Error::::as_stringXML::LibXML::Error::as_string
0000s0sXML::LibXML::Error::::domainXML::LibXML::Error::domain
0000s0sXML::LibXML::Error::::dumpXML::LibXML::Error::dump
0000s0sXML::LibXML::Error::::int1XML::LibXML::Error::int1
0000s0sXML::LibXML::Error::::int2XML::LibXML::Error::int2
0000s0sXML::LibXML::Error::::newXML::LibXML::Error::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Id: Error.pm,v 1.1.2.1 2004/04/20 20:09:48 pajas Exp $
2#
3# This is free software, you may use it and distribute it under the same terms as
4# Perl itself.
5#
6# Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas
7#
8#
9package XML::LibXML::Error;
10
112156µs2304µs
# spent 203µs (102+101) within XML::LibXML::Error::BEGIN@11 which was called: # once (102µs+101µs) by XML::LibXML::BEGIN@24 at line 11
use strict;
# spent 203µs making 1 call to XML::LibXML::Error::BEGIN@11 # spent 101µs making 1 call to strict::import
122177µs2122µs
# spent 88µs (55+34) within XML::LibXML::Error::BEGIN@12 which was called: # once (55µs+34µs) by XML::LibXML::BEGIN@24 at line 12
use warnings;
# spent 88µs making 1 call to XML::LibXML::Error::BEGIN@12 # spent 34µs making 1 call to warnings::import
13
14# To avoid a "Deep recursion on subroutine as_string" warning
152138µs2173µs
# spent 110µs (48+62) within XML::LibXML::Error::BEGIN@15 which was called: # once (48µs+62µs) by XML::LibXML::BEGIN@24 at line 15
no warnings 'recursion';
# spent 110µs making 1 call to XML::LibXML::Error::BEGIN@15 # spent 62µs making 1 call to warnings::unimport
16
172140µs123µs
# spent 23µs within XML::LibXML::Error::BEGIN@17 which was called: # once (23µs+0s) by XML::LibXML::BEGIN@24 at line 17
use Encode ();
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@17
18
192147µs2636µs
# spent 343µs (49+294) within XML::LibXML::Error::BEGIN@19 which was called: # once (49µs+294µs) by XML::LibXML::BEGIN@24 at line 19
use vars qw(@error_domains $VERSION $WARNINGS);
# spent 343µs making 1 call to XML::LibXML::Error::BEGIN@19 # spent 294µs making 1 call to vars::import
202570µs2528µs
# spent 290µs (53+237) within XML::LibXML::Error::BEGIN@20 which was called: # once (53µs+237µs) by XML::LibXML::BEGIN@24 at line 20
use Carp;
# spent 290µs making 1 call to XML::LibXML::Error::BEGIN@20 # spent 237µs making 1 call to Exporter::import
21use overload
22
# spent 316µs (95+221) within XML::LibXML::Error::BEGIN@22 which was called: # once (95µs+221µs) by XML::LibXML::BEGIN@24 at line 29
'""' => \&as_string,
23 'eq' => sub {
24 ("$_[0]" eq "$_[1]")
25 },
26 'cmp' => sub {
27 ("$_[0]" cmp "$_[1]")
28 },
292290µs2537µs fallback => 1;
# spent 316µs making 1 call to XML::LibXML::Error::BEGIN@22 # spent 221µs making 1 call to overload::import
30
3112µs$WARNINGS = 0; # 0: supress, 1: report via warn, 2: report via die
3212µs$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE
33
342161µs2498µs
# spent 275µs (53+222) within XML::LibXML::Error::BEGIN@34 which was called: # once (53µs+222µs) by XML::LibXML::BEGIN@24 at line 34
use constant XML_ERR_NONE => 0;
# spent 275µs making 1 call to XML::LibXML::Error::BEGIN@34 # spent 222µs making 1 call to constant::import
352163µs2521µs
# spent 284µs (47+237) within XML::LibXML::Error::BEGIN@35 which was called: # once (47µs+237µs) by XML::LibXML::BEGIN@24 at line 35
use constant XML_ERR_WARNING => 1; # A simple warning
# spent 284µs making 1 call to XML::LibXML::Error::BEGIN@35 # spent 237µs making 1 call to constant::import
362170µs2408µs
# spent 235µs (62+173) within XML::LibXML::Error::BEGIN@36 which was called: # once (62µs+173µs) by XML::LibXML::BEGIN@24 at line 36
use constant XML_ERR_ERROR => 2; # A recoverable error
# spent 235µs making 1 call to XML::LibXML::Error::BEGIN@36 # spent 173µs making 1 call to constant::import
372154µs2406µs
# spent 233µs (61+172) within XML::LibXML::Error::BEGIN@37 which was called: # once (61µs+172µs) by XML::LibXML::BEGIN@24 at line 37
use constant XML_ERR_FATAL => 3; # A fatal error
# spent 233µs making 1 call to XML::LibXML::Error::BEGIN@37 # spent 172µs making 1 call to constant::import
38
392152µs2389µs
# spent 218µs (46+171) within XML::LibXML::Error::BEGIN@39 which was called: # once (46µs+171µs) by XML::LibXML::BEGIN@24 at line 39
use constant XML_ERR_FROM_NONE => 0;
# spent 218µs making 1 call to XML::LibXML::Error::BEGIN@39 # spent 171µs making 1 call to constant::import
402148µs2384µs
# spent 215µs (46+169) within XML::LibXML::Error::BEGIN@40 which was called: # once (46µs+169µs) by XML::LibXML::BEGIN@24 at line 40
use constant XML_ERR_FROM_PARSER => 1; # The XML parser
# spent 215µs making 1 call to XML::LibXML::Error::BEGIN@40 # spent 169µs making 1 call to constant::import
412144µs2376µs
# spent 210µs (44+166) within XML::LibXML::Error::BEGIN@41 which was called: # once (44µs+166µs) by XML::LibXML::BEGIN@24 at line 41
use constant XML_ERR_FROM_TREE => 2; # The tree module
# spent 210µs making 1 call to XML::LibXML::Error::BEGIN@41 # spent 166µs making 1 call to constant::import
422155µs2392µs
# spent 225µs (58+167) within XML::LibXML::Error::BEGIN@42 which was called: # once (58µs+167µs) by XML::LibXML::BEGIN@24 at line 42
use constant XML_ERR_FROM_NAMESPACE => 3; # The XML Namespace module
# spent 225µs making 1 call to XML::LibXML::Error::BEGIN@42 # spent 167µs making 1 call to constant::import
432151µs2380µs
# spent 213µs (45+167) within XML::LibXML::Error::BEGIN@43 which was called: # once (45µs+167µs) by XML::LibXML::BEGIN@24 at line 43
use constant XML_ERR_FROM_DTD => 4; # The XML DTD validation
# spent 213µs making 1 call to XML::LibXML::Error::BEGIN@43 # spent 167µs making 1 call to constant::import
442168µs2378µs
# spent 212µs (45+166) within XML::LibXML::Error::BEGIN@44 which was called: # once (45µs+166µs) by XML::LibXML::BEGIN@24 at line 44
use constant XML_ERR_FROM_HTML => 5; # The HTML parser
# spent 212µs making 1 call to XML::LibXML::Error::BEGIN@44 # spent 166µs making 1 call to constant::import
452151µs2391µs
# spent 219µs (46+173) within XML::LibXML::Error::BEGIN@45 which was called: # once (46µs+173µs) by XML::LibXML::BEGIN@24 at line 45
use constant XML_ERR_FROM_MEMORY => 6; # The memory allocator
# spent 219µs making 1 call to XML::LibXML::Error::BEGIN@45 # spent 173µs making 1 call to constant::import
462209µs2414µs
# spent 236µs (59+178) within XML::LibXML::Error::BEGIN@46 which was called: # once (59µs+178µs) by XML::LibXML::BEGIN@24 at line 46
use constant XML_ERR_FROM_OUTPUT => 7; # The serialization code
# spent 236µs making 1 call to XML::LibXML::Error::BEGIN@46 # spent 178µs making 1 call to constant::import
472163µs2447µs
# spent 256µs (65+191) within XML::LibXML::Error::BEGIN@47 which was called: # once (65µs+191µs) by XML::LibXML::BEGIN@24 at line 47
use constant XML_ERR_FROM_IO => 8; # The Input/Output stack
# spent 256µs making 1 call to XML::LibXML::Error::BEGIN@47 # spent 191µs making 1 call to constant::import
482151µs2394µs
# spent 221µs (47+174) within XML::LibXML::Error::BEGIN@48 which was called: # once (47µs+174µs) by XML::LibXML::BEGIN@24 at line 48
use constant XML_ERR_FROM_FTP => 9; # The FTP module
# spent 221µs making 1 call to XML::LibXML::Error::BEGIN@48 # spent 174µs making 1 call to constant::import
492146µs2381µs
# spent 213µs (45+168) within XML::LibXML::Error::BEGIN@49 which was called: # once (45µs+168µs) by XML::LibXML::BEGIN@24 at line 49
use constant XML_ERR_FROM_HTTP => 10; # The FTP module
# spent 213µs making 1 call to XML::LibXML::Error::BEGIN@49 # spent 168µs making 1 call to constant::import
502146µs2377µs
# spent 211µs (45+166) within XML::LibXML::Error::BEGIN@50 which was called: # once (45µs+166µs) by XML::LibXML::BEGIN@24 at line 50
use constant XML_ERR_FROM_XINCLUDE => 11; # The XInclude processing
# spent 211µs making 1 call to XML::LibXML::Error::BEGIN@50 # spent 166µs making 1 call to constant::import
512153µs2420µs
# spent 233µs (47+187) within XML::LibXML::Error::BEGIN@51 which was called: # once (47µs+187µs) by XML::LibXML::BEGIN@24 at line 51
use constant XML_ERR_FROM_XPATH => 12; # The XPath module
# spent 233µs making 1 call to XML::LibXML::Error::BEGIN@51 # spent 187µs making 1 call to constant::import
522153µs2431µs
# spent 240µs (48+192) within XML::LibXML::Error::BEGIN@52 which was called: # once (48µs+192µs) by XML::LibXML::BEGIN@24 at line 52
use constant XML_ERR_FROM_XPOINTER => 13; # The XPointer module
# spent 240µs making 1 call to XML::LibXML::Error::BEGIN@52 # spent 192µs making 1 call to constant::import
532191µs2396µs
# spent 222µs (47+175) within XML::LibXML::Error::BEGIN@53 which was called: # once (47µs+175µs) by XML::LibXML::BEGIN@24 at line 53
use constant XML_ERR_FROM_REGEXP => 14; # The regular expressions module
# spent 222µs making 1 call to XML::LibXML::Error::BEGIN@53 # spent 175µs making 1 call to constant::import
542162µs2433µs
# spent 242µs (52+191) within XML::LibXML::Error::BEGIN@54 which was called: # once (52µs+191µs) by XML::LibXML::BEGIN@24 at line 54
use constant XML_ERR_FROM_DATATYPE => 15; # The W3C XML Schemas Datatype module
# spent 242µs making 1 call to XML::LibXML::Error::BEGIN@54 # spent 191µs making 1 call to constant::import
552155µs2390µs
# spent 218µs (46+172) within XML::LibXML::Error::BEGIN@55 which was called: # once (46µs+172µs) by XML::LibXML::BEGIN@24 at line 55
use constant XML_ERR_FROM_SCHEMASP => 16; # The W3C XML Schemas parser module
# spent 218µs making 1 call to XML::LibXML::Error::BEGIN@55 # spent 172µs making 1 call to constant::import
562158µs2399µs
# spent 234µs (70+164) within XML::LibXML::Error::BEGIN@56 which was called: # once (70µs+164µs) by XML::LibXML::BEGIN@24 at line 56
use constant XML_ERR_FROM_SCHEMASV => 17; # The W3C XML Schemas validation module
# spent 234µs making 1 call to XML::LibXML::Error::BEGIN@56 # spent 164µs making 1 call to constant::import
572182µs2475µs
# spent 262µs (49+213) within XML::LibXML::Error::BEGIN@57 which was called: # once (49µs+213µs) by XML::LibXML::BEGIN@24 at line 57
use constant XML_ERR_FROM_RELAXNGP => 18; # The Relax-NG parser module
# spent 262µs making 1 call to XML::LibXML::Error::BEGIN@57 # spent 213µs making 1 call to constant::import
582154µs2407µs
# spent 228µs (49+179) within XML::LibXML::Error::BEGIN@58 which was called: # once (49µs+179µs) by XML::LibXML::BEGIN@24 at line 58
use constant XML_ERR_FROM_RELAXNGV => 19; # The Relax-NG validator module
# spent 228µs making 1 call to XML::LibXML::Error::BEGIN@58 # spent 179µs making 1 call to constant::import
592151µs2386µs
# spent 216µs (47+169) within XML::LibXML::Error::BEGIN@59 which was called: # once (47µs+169µs) by XML::LibXML::BEGIN@24 at line 59
use constant XML_ERR_FROM_CATALOG => 20; # The Catalog module
# spent 216µs making 1 call to XML::LibXML::Error::BEGIN@59 # spent 169µs making 1 call to constant::import
602148µs2379µs
# spent 213µs (46+166) within XML::LibXML::Error::BEGIN@60 which was called: # once (46µs+166µs) by XML::LibXML::BEGIN@24 at line 60
use constant XML_ERR_FROM_C14N => 21; # The Canonicalization module
# spent 213µs making 1 call to XML::LibXML::Error::BEGIN@60 # spent 166µs making 1 call to constant::import
612173µs2487µs
# spent 275µs (63+212) within XML::LibXML::Error::BEGIN@61 which was called: # once (63µs+212µs) by XML::LibXML::BEGIN@24 at line 61
use constant XML_ERR_FROM_XSLT => 22; # The XSLT engine from libxslt
# spent 275µs making 1 call to XML::LibXML::Error::BEGIN@61 # spent 212µs making 1 call to constant::import
622154µs2402µs
# spent 225µs (48+177) within XML::LibXML::Error::BEGIN@62 which was called: # once (48µs+177µs) by XML::LibXML::BEGIN@24 at line 62
use constant XML_ERR_FROM_VALID => 23; # The DTD validation module with valid context
# spent 225µs making 1 call to XML::LibXML::Error::BEGIN@62 # spent 177µs making 1 call to constant::import
632157µs2403µs
# spent 234µs (66+169) within XML::LibXML::Error::BEGIN@63 which was called: # once (66µs+169µs) by XML::LibXML::BEGIN@24 at line 63
use constant XML_ERR_FROM_CHECK => 24; # The error-checking module
# spent 234µs making 1 call to XML::LibXML::Error::BEGIN@63 # spent 169µs making 1 call to constant::import
642192µs2433µs
# spent 247µs (61+186) within XML::LibXML::Error::BEGIN@64 which was called: # once (61µs+186µs) by XML::LibXML::BEGIN@24 at line 64
use constant XML_ERR_FROM_WRITER => 25; # The xmlwriter module
# spent 247µs making 1 call to XML::LibXML::Error::BEGIN@64 # spent 186µs making 1 call to constant::import
652154µs2411µs
# spent 229µs (48+181) within XML::LibXML::Error::BEGIN@65 which was called: # once (48µs+181µs) by XML::LibXML::BEGIN@24 at line 65
use constant XML_ERR_FROM_MODULE => 26; # The dynamically-loaded module module
# spent 229µs making 1 call to XML::LibXML::Error::BEGIN@65 # spent 181µs making 1 call to constant::import
662157µs2428µs
# spent 237µs (46+191) within XML::LibXML::Error::BEGIN@66 which was called: # once (46µs+191µs) by XML::LibXML::BEGIN@24 at line 66
use constant XML_ERR_FROM_I18N => 27; # The module handling character conversion
# spent 237µs making 1 call to XML::LibXML::Error::BEGIN@66 # spent 191µs making 1 call to constant::import
672596µs2429µs
# spent 255µs (81+174) within XML::LibXML::Error::BEGIN@67 which was called: # once (81µs+174µs) by XML::LibXML::BEGIN@24 at line 67
use constant XML_ERR_FROM_SCHEMATRONV=> 28; # The Schematron validator module
# spent 255µs making 1 call to XML::LibXML::Error::BEGIN@67 # spent 174µs making 1 call to constant::import
68
69128µs@error_domains = ("", "parser", "tree", "namespace", "validity",
70 "HTML parser", "memory", "output", "I/O", "ftp",
71 "http", "XInclude", "XPath", "xpointer", "regexp",
72 "Schemas datatype", "Schemas parser", "Schemas validity",
73 "Relax-NG parser", "Relax-NG validity",
74 "Catalog", "C14N", "XSLT", "validity", "error-checking",
75 "xmlwriter", "dynamic loading", "i18n",
76 "Schematron validity");
77
7812µsmy $MAX_ERROR_PREV_DEPTH = 100;
79
8016µsfor my $field (qw<code _prev level file line nodename message column context
81 str1 str2 str3 num1 num2 __prev_depth>) {
8215136µs my $method = sub { $_[0]{$field} };
8324.27ms2215µs
# spent 135µs (54+80) within XML::LibXML::Error::BEGIN@83 which was called: # once (54µs+80µs) by XML::LibXML::BEGIN@24 at line 83
no strict 'refs';
# spent 135µs making 1 call to XML::LibXML::Error::BEGIN@83 # spent 80µs making 1 call to strict::unimport
8415191µs *$field = $method;
85}
86
87{
88
8912µs sub new {
90 my ($class,$xE) = @_;
91 my $terr;
92 if (ref($xE)) {
93 my ($context,$column) = $xE->context_and_column();
94 $terr =bless {
95 domain => $xE->domain(),
96 level => $xE->level(),
97 code => $xE->code(),
98 message => $xE->message(),
99 file => $xE->file(),
100 line => $xE->line(),
101 str1 => $xE->str1(),
102 str2 => $xE->str2(),
103 str3 => $xE->str3(),
104 num1 => $xE->num1(),
105 num2 => $xE->num2(),
106 __prev_depth => 0,
107 (defined($context) ?
108 (
109 context => $context,
110 column => $column,
111 ) : ()),
112 }, $class;
113 } else {
114 # !!!! problem : got a flat error
115 # warn("PROBLEM: GOT A FLAT ERROR $xE\n");
116 $terr =bless {
117 domain => 0,
118 level => 2,
119 code => -1,
120 message => $xE,
121 file => undef,
122 line => undef,
123 str1 => undef,
124 str2 => undef,
125 str3 => undef,
126 num1 => undef,
127 num2 => undef,
128 __prev_depth => 0,
129 }, $class;
130 }
131 return $terr;
132 }
133
134 sub _callback_error {
135 #print "CALLBACK\n";
136 my ($xE,$prev) = @_;
137 my $terr;
138 $terr=XML::LibXML::Error->new($xE);
139 if ($terr->{level} == XML_ERR_WARNING and $WARNINGS!=2) {
140 warn $terr if $WARNINGS;
141 return $prev;
142 }
143 #unless ( defined $terr->{file} and length $terr->{file} ) {
144 # this would make it easier to recognize parsed strings
145 # but it breaks old implementations
146 # [CG] $terr->{file} = 'string()';
147 #}
148 #warn "Saving the error ",$terr->dump;
149
150 if (ref($prev))
151 {
152 if ($prev->__prev_depth() >= $MAX_ERROR_PREV_DEPTH)
153 {
154 return $prev;
155 }
156 $terr->{_prev} = $prev;
157 $terr->{__prev_depth} = $prev->__prev_depth() + 1;
158 }
159 else
160 {
161 $terr->{_prev} = defined($prev) && length($prev) ? XML::LibXML::Error->new($prev) : undef;
162 }
163 return $terr;
164 }
165 sub _instant_error_callback {
166 my $xE = shift;
167 my $terr= XML::LibXML::Error->new($xE);
168 print "Reporting an instanteous error ",$terr->dump;
169 die $terr;
170 }
171 sub _report_warning {
172 my ($saved_error) = @_;
173 #print "CALLBACK WARN\n";
174 if ( defined $saved_error ) {
175 #print "reporting a warning ",$saved_error->dump;
176 warn $saved_error;
177 }
178 }
179 sub _report_error {
180 my ($saved_error) = @_;
181 #print "CALLBACK ERROR: $saved_error\n";
182 if ( defined $saved_error ) {
183 die $saved_error;
184 }
185 }
186}
187
188
189# backward compatibility
190sub int1 { $_[0]->num1 }
191sub int2 { $_[0]->num2 }
192
193sub domain {
194 my ($self)=@_;
195 return undef unless ref($self);
196 my $domain = $self->{domain};
197 # Newer versions of libxml2 might yield errors in domains that aren't
198 # listed above. Invent something reasonable in that case.
199 return $domain < @error_domains ? $error_domains[$domain] : "domain_$domain";
200}
201
202sub as_string {
203 my ($self)=@_;
204 my $msg = "";
205 my $level;
206
207 if (defined($self->{_prev})) {
208 $msg = $self->{_prev}->as_string;
209 }
210
211 if ($self->{level} == XML_ERR_NONE) {
212 $level = "";
213 } elsif ($self->{level} == XML_ERR_WARNING) {
214 $level = "warning";
215 } elsif ($self->{level} == XML_ERR_ERROR ||
216 $self->{level} == XML_ERR_FATAL) {
217 $level = "error";
218 }
219 my $where="";
220 if (defined($self->{file})) {
221 $where="$self->{file}:$self->{line}";
222 } elsif (($self->{domain} == XML_ERR_FROM_PARSER)
223 and
224 $self->{line}) {
225 $where="Entity: line $self->{line}";
226 }
227 if ($self->{nodename}) {
228 $where.=": element ".$self->{nodename};
229 }
230 $msg.=$where.": " if $where ne "";
231 $msg.=$self->domain." ".$level." :";
232 my $str=$self->{message}||"";
233 chomp($str);
234 $msg.=" ".$str."\n";
235 if (($self->{domain} == XML_ERR_FROM_XPATH) and
236 defined($self->{str1})) {
237 $msg.=$self->{str1}."\n";
238 $msg.=(" " x $self->{num1})."^\n";
239 } elsif (defined $self->{context}) {
240 # If the error relates to character-encoding problems in the context,
241 # then doing textual operations on it will spew warnings that
242 # XML::LibXML can do nothing to fix. So just disable all such
243 # warnings. This has the pleasing benefit of making the test suite
244 # run warning-free.
2452745µs2220µs
# spent 152µs (85+68) within XML::LibXML::Error::BEGIN@245 which was called: # once (85µs+68µs) by XML::LibXML::BEGIN@24 at line 245
no warnings 'utf8';
# spent 152µs making 1 call to XML::LibXML::Error::BEGIN@245 # spent 68µs making 1 call to warnings::unimport
246 my $context = Encode::encode('utf8', $self->{context}, Encode::FB_DEFAULT);
247 $msg.=$context."\n";
248 $context = substr($context,0,$self->{column});
249 $context=~s/[^\t]/ /g;
250 $msg.=$context."^\n";
251 }
252 return $msg;
253}
254
255sub dump {
256 my ($self)=@_;
2572987µs255.0ms
# spent 54.8ms (26.5+28.2) within XML::LibXML::Error::BEGIN@257 which was called: # once (26.5ms+28.2ms) by XML::LibXML::BEGIN@24 at line 257
use Data::Dumper;
# spent 54.8ms making 1 call to XML::LibXML::Error::BEGIN@257 # spent 230µs making 1 call to Exporter::import
258 return Data::Dumper->new([$self],['error'])->Dump;
259}
260
261136µs1;