Commits

Shlomi Fish committed 39e56dc

Extract _calc_parser.

Comments (0)

Files changed (2)

XML-GrammarBase/Changes

 Revision history for XML-GrammarBase
 
+         * lib/XML/GrammarBase/Role/RelaxNG.pm : add the
+         _calc_parser method that can be overrided for calculating and
+         returning the XML::LibXML parser.
+
 0.1.2    Sat  5 Jan 10:05:33 IST 2013
          * Add t/01libxml-basic.t for diag()s for libxml2 and XML::LibXML
          (so we'll know which versions of them are failing).

XML-GrammarBase/lib/XML/GrammarBase/Role/RelaxNG.pm

     return;
 }
 
+sub _calc_parser
+{
+    my ($self) = @_;
+
+    my $xml_parser = XML::LibXML->new();
+
+    $xml_parser->validation(0);
+    $xml_parser->load_ext_dtd(0);
+    $xml_parser->no_network(1);
+
+    return $xml_parser;
+}
+
 sub rng_validate_file
 {
     my ($self, $filename) = @_;
 
-    my $xml_parser = XML::LibXML->new();
-    $xml_parser->validation(0);
-
-    my $dom = $xml_parser->parse_file($filename);
+    my $dom = $self->_calc_parser()->parse_file($filename);
 
     return $self->rng_validate_dom($dom);
 }
 {
     my ($self, $xml_string) = @_;
 
-    my $xml_parser = XML::LibXML->new();
-    $xml_parser->validation(0);
-
-    my $dom = $xml_parser->parse_string($xml_string);
+    my $dom = $self->_calc_parser()->parse_string($xml_string);
 
     return $self->rng_validate_dom($dom);
 }