You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2002/04/25 03:56:50 UTC
cvs commit: xml-xerces/perl Xerces-extra.pm
jasons 02/04/24 18:56:50
Modified: perl Xerces-extra.pm
Log:
* Xerces-extra.pm (Repository):
Added error()
Added DOM_Element::get_text()
Turned all die() to croak() and warn() to carp()
Revision Changes Path
1.3 +45 -7 xml-xerces/perl/Xerces-extra.pm
Index: Xerces-extra.pm
===================================================================
RCS file: /home/cvs/xml-xerces/perl/Xerces-extra.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Xerces-extra.pm 28 Mar 2002 07:53:27 -0000 1.2
+++ Xerces-extra.pm 25 Apr 2002 01:56:50 -0000 1.3
@@ -17,6 +17,25 @@
XML::Xerces::XMLPlatformUtils::Terminate();
}
+package XML::Xerces;
+use Carp;
+use vars qw(@EXPORT_OK);
+@EXPORT_OK = qw(error);
+sub error {
+ my $error = shift;
+ print STDERR "Error in eval: ";
+ if (ref $error) {
+ if ($error->isa('XML::Xerces::DOM_DOMException')) {
+ croak "Message: <", $error->getMessage(),
+ "> Code: ", $XML::Xerces::DOM_DOMException::CODES[$error->getCode];
+ } else {
+ croak $error->getMessage();
+ }
+ } else {
+ croak $error;
+ }
+}
+
############# Class : XML::Xerces::PerlContentHandler ##############
package XML::Xerces::PerlContentHandler;
use vars qw(@ISA);
@@ -90,6 +109,7 @@
############# Class : XML::Xerces::PerlErrorHandler ##############
package XML::Xerces::PerlErrorHandler;
+use Carp;
use vars qw(@ISA);
@ISA = qw();
sub new {
@@ -102,7 +122,7 @@
my $line_num = $_[1]->getLineNumber;
my $col_num = $_[1]->getColumnNumber;
my $msg = $_[1]->getMessage;
- warn(<<EOT);
+ carp(<<EOT);
WARNING:
FILE: $system_id
LINE: $line_num
@@ -116,7 +136,7 @@
my $line_num = $_[1]->getLineNumber;
my $col_num = $_[1]->getColumnNumber;
my $msg = $_[1]->getMessage;
- die(<<EOT);
+ croak(<<EOT);
ERROR:
FILE: $system_id
LINE: $line_num
@@ -130,7 +150,7 @@
my $line_num = $_[1]->getLineNumber;
my $col_num = $_[1]->getColumnNumber;
my $msg = $_[1]->getMessage;
- die(<<EOT);
+ croak(<<EOT);
FATAL ERROR:
FILE: $system_id
LINE: $line_num
@@ -344,25 +364,43 @@
return shift->{msg};
}
+sub getCode {
+ return shift->{code};
+}
+
package XML::Xerces::DOM_Node;
+use Carp;
sub isNull {
- warn("using DOM_Node::isNULL() is depricated");
+ carp("using DOM_Node::isNULL() is depricated");
return 0;
}
sub actual_cast {
- warn("using DOM_Node::actual_cast() is depricated");
+ carp("using DOM_Node::actual_cast() is depricated");
return $_[0];
}
package XML::Xerces::DOM_Document;
+use Carp;
sub createDocument {
- warn("using DOM_Document::createDocument() is depricated");
+ carp("using DOM_Document::createDocument() is depricated");
return undef;
}
package XML::Xerces::DOMParser;
+use Carp;
sub setToCreateXMLDeclTypeNode {
- warn("using DOMParser::setToCreateXMLDeclTypeNode() is depricated");
+ carp("using DOMParser::setToCreateXMLDeclTypeNode() is depricated");
}
+package XML::Xerces::DOM_Element;
+sub get_text {
+ my $node = shift;
+ my @nodes = $node->getChildNodes();
+ my $text;
+ foreach (@nodes) {
+ $text .= $_->getNodeValue()
+ if $_->isa('XML::Xerces::DOM_Text');
+ }
+ return $text;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org