Skip to content

Commit

Permalink
Rely on exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Mar 25, 2012
1 parent 19771c8 commit 2d12294
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions RDF/Parser.php
Expand Up @@ -598,9 +598,7 @@ function _resolve_id($id, &$buffer)
$id_buffer = '';

$result = $this->is_valid_id($id);
if (PEAR::isError($result)) {
return $result;
}

if ($result) {
$id_buffer = "#$id";
}
Expand Down Expand Up @@ -693,9 +691,6 @@ function _report_statement($subject_type, $subject, $predicate, $ordinal,
$xml_lang,
$datatype
);
if (PEAR::isError($result)) {
return $result;
}

if ($bag_id) {
if ($statements == '') {
Expand Down Expand Up @@ -1067,9 +1062,6 @@ function _handle_resource_element($namespace_uri, $local_name, $attributes, $par
$this->rdf_parser['top']['subject'] = $id_buffer;
} else if ($node_id) {
$result = $this->is_valid_id($node_id);
if (PEAR::isError($result)) {
return $result;
}
$this->rdf_parser['top']['subject_type'] = RDF_SUBJECT_TYPE_BNODE;
$this->rdf_parser['top']['subject'] = $node_id;
}
Expand Down Expand Up @@ -1251,9 +1243,6 @@ function _handle_property_element(&$namespace_uri, &$local_name, &$attributes)

if ($node_id) {
$result = $this->is_valid_id($node_id);
if (PEAR::isError($result)) {
return $result;
}

if ($resource) {
throw new RDF_Exception('nodeID and resource are mutually exclusive', RDF_ERROR);
Expand Down Expand Up @@ -1694,17 +1683,11 @@ function _start_element_handler($parser, $name, $attributes)
case RDF_IN_RDF:
$this->rdf_parser['top']['state'] = RDF_IN_DESCRIPTION;
$result = $this->_handle_resource_element($namespace_uri, $local_name, $attributes, '');
if (PEAR::isError($result)) {
return $result;
}
break;
case RDF_IN_DESCRIPTION:
case RDF_IN_PROPERTY_PARSE_TYPE_RESOURCE:
$this->rdf_parser['top']['state'] = RDF_IN_PROPERTY_UNKNOWN_OBJECT;
$result = $this->_handle_property_element($namespace_uri, $local_name, $attributes);
if (PEAR::isError($result)) {
return $result;
}
break;
case RDF_IN_PROPERTY_PARSE_TYPE_COLLECTION:
$this->_handle_collection_element($namespace_uri, $local_name, $attributes);
Expand All @@ -1721,9 +1704,6 @@ function _start_element_handler($parser, $name, $attributes)
$attributes,
$this->rdf_parser['top']['parent']
);
if (PEAR::isError($result)) {
return $result;
}
break;
case RDF_IN_PROPERTY_LITERAL:
$this->_report_warning('no markup allowed in literals');
Expand Down Expand Up @@ -1907,14 +1887,8 @@ function add_statement_to_model(&$user_data, $subject_type, $subject,
} else {
$objsub =& RDF_Resource::factory($subject);
}
if (PEAR::isError($objsub)) {
return $objsub;
}
// create predicate
$objpred =& RDF_Resource::factory($predicate);
if (PEAR::isError($objpred)) {
return $objpred;
}
// create object
if (($object_type == RDF_OBJECT_TYPE_RESOURCE)
|| ($object_type == RDF_OBJECT_TYPE_BNODE)
Expand All @@ -1924,14 +1898,8 @@ function add_statement_to_model(&$user_data, $subject_type, $subject,
} else {
$objobj =& RDF_Resource::factory($object);
}
if (PEAR::isError($objobj)) {
return $objobj;
}
} else {
$objobj =& RDF_Literal::factory($object);
if (PEAR::isError($objobj)) {
return $objobj;
}
if ($datatype != '') {
$objobj->setDatatype($datatype);
} elseif ($xml_lang != "") {
Expand All @@ -1940,9 +1908,6 @@ function add_statement_to_model(&$user_data, $subject_type, $subject,
}
// create statement
$statement =& RDF_Statement::factory($objsub, $objpred, $objobj);
if (PEAR::isError($statement)) {
return $statement;
}
// add statement to model
return $this->model->add($statement);
}
Expand Down

0 comments on commit 2d12294

Please sign in to comment.