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 2001/10/10 22:07:11 UTC

cvs commit: xml-xerces/perl/samples DOMPrint.pl

jasons      01/10/10 13:07:11

  Modified:    perl/samples DOMPrint.pl
  Log:
  	* samples/DOMPrint.pl (Repository):
  	Added USAGE output if no input files are specified
  	new exception handling code
  
  Revision  Changes    Path
  1.8       +14 -4     xml-xerces/perl/samples/DOMPrint.pl
  
  Index: DOMPrint.pl
  ===================================================================
  RCS file: /home/cvs/xml-xerces/perl/samples/DOMPrint.pl,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DOMPrint.pl	2001/07/09 23:13:34	1.7
  +++ DOMPrint.pl	2001/10/10 20:07:10	1.8
  @@ -87,15 +87,17 @@
     * = Default if not provided explicitly
   
   EOU
  -my $VERSION = q[$Id: DOMPrint.pl,v 1.7 2001/07/09 23:13:34 jasons Exp $];
  +my $VERSION = q[$Id: DOMPrint.pl,v 1.8 2001/10/10 20:07:10 jasons Exp $];
   my %OPTIONS;
   my $rc = GetOptions(\%OPTIONS,
   		    'v=s',
   		    'n',
   		    's');
   
  -die "$USAGE" unless $rc;
  +die $USAGE unless $rc;
   
  +die $USAGE unless scalar @ARGV;
  +
   my $file = $ARGV[0];
   -f $file or die "File '$file' does not exist!\n";
   
  @@ -117,7 +119,6 @@
   # Parse and print
   #
   
  -my $file = $ARGV[0];
   my $parser = XML::Xerces::DOMParser->new();
   $parser->setValidationScheme ($validate);
   $parser->setDoNamespaces ($namespace);
  @@ -126,7 +127,16 @@
   $parser->setToCreateXMLDeclTypeNode(1);
   my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
   $parser->setErrorHandler($ERROR_HANDLER);
  -$parser->parse (XML::Xerces::LocalFileInputSource->new($file));
  +eval {
  +  $parser->parse (XML::Xerces::LocalFileInputSource->new($file));
  +};
  +if ($@) {
  +  if (ref $@) {
  +    die $@->getMessage();
  +  } else {
  +    die $@;
  +  }
  +}
   my $doc = $parser->getDocument ();
   
   XML::Xerces::DOMParse::unformat ($doc);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org