Commit a38c78f2 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

EFA: Don't crash when calling ->identified_data or ->lines without XML

parent 4e1fefca
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -271,6 +271,10 @@ sub check_for_ambiguous {
sub identified_data {
	my ($self) = @_;

	if ( not $self->{tree} ) {
		return;
	}

	my $xp_place
	  = XML::LibXML::XPathExpression->new('//itdOdv/itdOdvPlace/odvPlaceElem');
	my $xp_name
@@ -286,6 +290,14 @@ sub lines {
	my ($self) = @_;
	my @lines;

	if ( $self->{lines} ) {
		return @{ $self->{lines} };
	}

	if ( not $self->{tree} ) {
		return;
	}

	my $xp_element
	  = XML::LibXML::XPathExpression->new('//itdServingLines/itdServingLine');

@@ -293,10 +305,6 @@ sub lines {
	my $xp_route = XML::LibXML::XPathExpression->new('./itdRouteDescText');
	my $xp_oper  = XML::LibXML::XPathExpression->new('./itdOperator/name');

	if ( $self->{lines} ) {
		return @{ $self->{lines} };
	}

	for my $e ( $self->{tree}->findnodes($xp_element) ) {

		my $e_info  = ( $e->findnodes($xp_info) )[0];
@@ -376,6 +384,10 @@ sub results {
	my ($self) = @_;
	my @results;

	if ( $self->{results} ) {
		return @{ $self->{results} };
	}

	if ( not $self->{tree} ) {
		return;
	}
@@ -394,10 +406,6 @@ sub results {
	my $xp_next_route
	  = XML::LibXML::XPathExpression->new('./itdOnwardStopSeq/itdPoint');

	if ( $self->{results} ) {
		return @{ $self->{results} };
	}

	$self->lines;

	for my $e ( $self->{tree}->findnodes($xp_element) ) {