|
From: <cw...@us...> - 2007-08-12 17:42:34
|
Revision: 492
http://rdfapi-php.svn.sourceforge.net/rdfapi-php/?rev=492&view=rev
Author: cweiske
Date: 2007-08-12 10:42:33 -0700 (Sun, 12 Aug 2007)
Log Message:
-----------
remove whitespace
Modified Paths:
--------------
trunk/rdfapi-php/api/syntax/RdfParser.php
Modified: trunk/rdfapi-php/api/syntax/RdfParser.php
===================================================================
--- trunk/rdfapi-php/api/syntax/RdfParser.php 2007-08-12 17:42:05 UTC (rev 491)
+++ trunk/rdfapi-php/api/syntax/RdfParser.php 2007-08-12 17:42:33 UTC (rev 492)
@@ -6,25 +6,25 @@
/**
- * An RDF paser.
+ * An RDF paser.
* This class reads RDF data from files or URIs and generates models out of it. All valid
- * RDF XML syntaxes defined by the W3C in RDF/XML Syntax Specification (Revised)
+ * RDF XML syntaxes defined by the W3C in RDF/XML Syntax Specification (Revised)
* - W3C Working Draft 10 October 2003
* (http://www.w3.org/TR/2003/WD-rdf-syntax-grammar-20031010/) are supported.
- * The parser is based on the PHP version of repat
- * (http://phpxmlclasses.sourceforge.net/show_doc.php?class=class_rdf_parser.html)
- * by Luis Argerich (lra...@ya...).
- *
+ * The parser is based on the PHP version of repat
+ * (http://phpxmlclasses.sourceforge.net/show_doc.php?class=class_rdf_parser.html)
+ * by Luis Argerich (lra...@ya...).
+ *
* @version $Id$
- * @author Luis Argerich <lra...@ya...>,
+ * @author Luis Argerich <lra...@ya...>,
* Chris Bizer <ch...@bi...>,
* Radoslaw Oldakowski <ra...@gm...>
* Daniel Westphal <ma...@d-...>
* @package syntax
* @access public
*
- */
-
+ */
+
class RdfParser extends Object {
var $rdf_parser;
@@ -35,9 +35,9 @@
/**
* converts a string to its unicode NFC form (e.g. \uHHHH or \UHHHHHHHH).
-*
+*
* @param String $str
-* @return String
+* @return String
* @access private
*
*/
@@ -122,8 +122,8 @@
/**
- * @access private
- */
+ * @access private
+ */
function _new_element()
{
$e['parent']=Array(); // Parent is a blank Array
@@ -142,7 +142,7 @@
$e['statement_id']='';
$e['datatype']='';
$e['element_base_uri'] = '';
-
+
return $e;
}
@@ -151,8 +151,8 @@
* @param string $source
* @param string &$destination
*
- * @access private
- */
+ * @access private
+ */
function _copy_element($source, &$destination )
{
if( $source )
@@ -160,14 +160,14 @@
$destination['parent'] = $source;
$destination['state'] = $source['state'];
$destination['xml_lang'] = $source['xml_lang'];
- $destination['element_base_uri'] = $source['element_base_uri'];
+ $destination['element_base_uri'] = $source['element_base_uri'];
}
}
/**
* @param string &$e
- * @access private
- */
+ * @access private
+ */
function _clear_element(&$e)
{
$e['subject']='';
@@ -211,8 +211,8 @@
}
/**
- * @access private
- */
+ * @access private
+ */
function _push_element()
{
if(!isset($this->rdf_parser['free'])) {
@@ -239,8 +239,8 @@
}
/**
- * @access private
- */
+ * @access private
+ */
function _pop_element()
{
$e = $this->rdf_parser['top'];
@@ -251,32 +251,32 @@
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_rdf_property_attribute_resource($local_name )
{
- return ( $local_name == RDF_TYPE );
+ return ( $local_name == RDF_TYPE );
}
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_rdf_property_attribute_literal($local_name )
{
- return ( $local_name == RDF_VALUE )
+ return ( $local_name == RDF_VALUE )
|| ( $local_name == RDF_BAG )
|| ( $local_name == RDF_SEQ )
|| ( $local_name == RDF_ALT )
|| ( $local_name == RDF_STATEMENT )
|| ( $local_name == RDF_PROPERTY )
- || ( $local_name == RDF_LIST );
+ || ( $local_name == RDF_LIST );
}
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_rdf_ordinal( $local_name )
{
$ordinal = -1;
@@ -291,8 +291,8 @@
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_rdf_property_attribute( $local_name )
{
return $this->_is_rdf_property_attribute_resource( $local_name )
@@ -303,11 +303,11 @@
{
return ( $local_name == RDF_RDF )
|| ( $local_name == RDF_DESCRIPTION)
- || ( $local_name == RDF_ID)
+ || ( $local_name == RDF_ID)
|| ( $local_name == RDF_ABOUT )
|| ( $local_name == RDF_BAG_ID )
|| ( $local_name == RDF_PARSE_TYPE )
- || ( $local_name == RDF_RESOURCE )
+ || ( $local_name == RDF_RESOURCE )
|| ( $local_name == RDF_NODEID )
|| ( $local_name == RDF_LI )
|| ( $local_name == RDF_ABOUT_EACH )
@@ -317,8 +317,8 @@
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_rdf_property_element( $local_name )
{
return ( $local_name == RDF_TYPE )
@@ -327,75 +327,75 @@
|| ( $local_name == RDF_OBJECT )
|| ( $local_name == RDF_VALUE )
|| ( $local_name == RDF_LI )
- || ( $local_name == RDF_SEEALSO )
+ || ( $local_name == RDF_SEEALSO )
|| ( $local_name == RDF_BAG )
|| ( $local_name == RDF_SEQ )
|| ( $local_name == RDF_ALT )
|| ( $local_name == RDF_STATEMENT )
|| ( $local_name == RDF_PROPERTY )
|| ( $local_name == RDF_LIST )
- || ( $local_name == RDF_FIRST )
+ || ( $local_name == RDF_FIRST )
|| ( $local_name == RDF_REST )
|| ( $local_name{0} == '_' );
}
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_forbidden_rdf_property_element ($local_name)
{
return ( $local_name == RDF_RDF )
|| ( $local_name == RDF_DESCRIPTION)
- || ( $local_name == RDF_ID)
+ || ( $local_name == RDF_ID)
|| ( $local_name == RDF_ABOUT )
|| ( $local_name == RDF_BAG_ID )
|| ( $local_name == RDF_PARSE_TYPE )
- || ( $local_name == RDF_RESOURCE )
+ || ( $local_name == RDF_RESOURCE )
|| ( $local_name == RDF_NODEID )
|| ( $local_name == RDF_ABOUT_EACH )
|| ( $local_name == RDF_ABOUT_EACH_PREFIX )
|| ( $local_name == RDF_DATATYPE );
}
-
+
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_rdf_node_element( $local_name )
{
- return ( $local_name == RDF_DESCRIPTION )
+ return ( $local_name == RDF_DESCRIPTION )
|| ( $local_name == RDF_STATEMENT )
|| ( $local_name == RDF_SUBJECT )
|| ( $local_name == RDF_PREDICATE )
- || ( $local_name == RDF_OBJECT )
+ || ( $local_name == RDF_OBJECT )
|| ( $local_name == RDF_PROPERTY )
|| ( $local_name == RDF_TYPE )
|| ( $local_name == RDF_VALUE )
|| ( $local_name == RDF_BAG )
|| ( $local_name == RDF_SEQ )
- || ( $local_name == RDF_ALT )
- || ( $local_name == RDF_SEEALSO )
+ || ( $local_name == RDF_ALT )
+ || ( $local_name == RDF_SEEALSO )
|| ( $local_name == RDF_LIST )
- || ( $local_name == RDF_FIRST )
- || ( $local_name == RDF_REST )
- || ( $local_name == RDF_NIL )
+ || ( $local_name == RDF_FIRST )
+ || ( $local_name == RDF_REST )
+ || ( $local_name == RDF_NIL )
|| ( $local_name{0} == '_' );
}
/**
* @param string $local_name
- * @access private
- */
+ * @access private
+ */
function _is_forbidden_rdf_node_element ($local_name)
{
return ( $local_name == RDF_RDF )
- || ( $local_name == RDF_ID)
+ || ( $local_name == RDF_ID)
|| ( $local_name == RDF_ABOUT )
|| ( $local_name == RDF_BAG_ID )
|| ( $local_name == RDF_PARSE_TYPE )
- || ( $local_name == RDF_RESOURCE )
+ || ( $local_name == RDF_RESOURCE )
|| ( $local_name == RDF_NODEID )
|| ( $local_name == RDF_LI )
|| ( $local_name == RDF_ABOUT_EACH )
@@ -405,23 +405,23 @@
/**
* @param string $val
- * @access private
- */
+ * @access private
+ */
function _istalnum($val) {
return ereg("[A-Za-z0-9]",$val);
}
/**
* @param string $val
- * @access private
- */
+ * @access private
+ */
function _istalpha($val) {
return ereg("[A-Za-z]",$val);
}
/**
* @param string $uri
- * @access private
- */
+ * @access private
+ */
function _is_absolute_uri($uri )
{
$result = false;
@@ -464,10 +464,10 @@
* @param string &$path
* @param string &$query
* @param string &$fragment
- * @access private
-*/
+ * @access private
+*/
function _parse_uri($uri,$buffer,&$scheme,&$authority,&$path,&$query,&$fragment ) {
-
+
$parsed=parse_url($uri);
if(isset($parsed['scheme'])) {
$scheme=$parsed['scheme'];
@@ -506,13 +506,13 @@
* @param string $base_uri
* @param string $reference_uri
* @param string &$buffer
- * @access private
-*/
+ * @access private
+*/
function _resolve_uri_reference($base_uri,$reference_uri,&$buffer )
{
if ($reference_uri == '')
return ($buffer = preg_replace("/\#[^\/\\\]*$/", '', $base_uri));
-
+
$base_buffer='';
$reference_buffer='';
$path_buffer='';
@@ -526,15 +526,15 @@
$reference_path,
$reference_query,
$reference_fragment );
-
+
$this->_parse_uri($base_uri,
$base_buffer,
$base_scheme,
$base_authority,
$base_path,
$base_query,
- $base_fragment );
-
+ $base_fragment );
+
if( $reference_scheme == ''
&& $reference_authority == ''
&& $reference_path == ''
@@ -542,22 +542,22 @@
{
$buffer=$base_uri;
- if( $reference_fragment != '' )
+ if( $reference_fragment != '' )
{
if ($base_path == '' || $base_path == '/' || $base_path == "\\") {
- $buffer = $this->rdf_parser['document_base_uri'];
+ $buffer = $this->rdf_parser['document_base_uri'];
}
- else
+ else
{
$buffer = preg_replace("/\#[^\/\\\]*$/", '', $base_uri);
}
-
+
// CB: Changed for base URI
$c = substr($buffer, strlen($buffer)-1 ,1);
if (!($c=='#' || $c==':' || $c=='/' || $c=="\\"))
$buffer.= '#' ;
- $buffer.=$reference_fragment;
-
+ $buffer.=$reference_fragment;
+
}
}
else if( $reference_scheme != '' )
@@ -565,18 +565,18 @@
$buffer=$reference_uri;
}
else
- {
+ {
$result_scheme = $base_scheme;
$result_path = '';
-
+
if( $reference_authority != '' )
{
- $result_authority = $reference_authority;
+ $result_authority = $reference_authority;
}
else
{
$result_authority = $base_authority;
-
+
if ($reference_path != '')
{
if ($reference_path{0} == '/' || $reference_path{0} == "\\")
@@ -584,7 +584,7 @@
if ($reference_path{1} == '/' || $reference_path{1} == "\\")
{
$result_authority = '';
- $result_path = $reference_path;
+ $result_path = $reference_path;
}
else
$result_path = $reference_path;
@@ -592,30 +592,30 @@
elseif (substr($reference_path, 0, 3) == '../' ||
substr($reference_path, 0, 3) == '..\\')
{
- $slash = $reference_path{2};
- while($base_path != '' && ( substr($reference_path, 0, 3) == '../'
+ $slash = $reference_path{2};
+ while($base_path != '' && ( substr($reference_path, 0, 3) == '../'
|| substr($reference_path, 0, 3) == '..\\'))
- {
- $base_path = preg_replace("/((\/)|(\\\))[^\/\\\]*$/", '', $base_path);
+ {
+ $base_path = preg_replace("/((\/)|(\\\))[^\/\\\]*$/", '', $base_path);
if ($base_path != '') {
- $base_path = preg_replace("/((\/)|(\\\))[^\/\\\]*$/", '', $base_path);
+ $base_path = preg_replace("/((\/)|(\\\))[^\/\\\]*$/", '', $base_path);
$reference_path = substr($reference_path, 3);
}
}
-
+
$result_path = $base_path .$slash .$reference_path;
}
- else
- {
+ else
+ {
if ($base_path)
$result_path = preg_replace("/[^\/\\\]*$/", $reference_path, $base_path, 1);
- else
- $result_path = '/' .$reference_path;
- }
+ else
+ $result_path = '/' .$reference_path;
+ }
}
-
+
}
-
+
if( $result_scheme != '' )
{
$buffer=$result_scheme;
@@ -644,26 +644,26 @@
$buffer.='#';
$buffer.=$reference_fragment;
}
- }
+ }
}
/**
- * IDs which contain CombiningChars or Extenders
+ * IDs which contain CombiningChars or Extenders
* (see http://www.w3.org/TR/REC-xml-names/#NT-NCName) are assumed to be invalid.
- * If you want to use IDs containing these characters you can turn off
+ * If you want to use IDs containing these characters you can turn off
* the validating by setting the constant VALIDATE_IDS to FALSE (see constants.php).
*
* @param string $id
- * @access private
-*/
+ * @access private
+*/
function is_valid_id($id )
{
if (!VALIDATE_IDS)
return TRUE;
-
+
$result = FALSE;
-
+
if( $id )
{
if( $this->_istalpha($id{0}) || $id{0} == '_')
@@ -678,23 +678,23 @@
|| $id{$i} == '-'
|| $id{$i} == '_'))
{
- $result = FALSE;
+ $result = FALSE;
}
}
}
}
-
+
if (!$result)
$this->_report_error('illegal ID, nodeID or bagID attribute value');
- else
+ else
return TRUE;
}
/**
* @param string $id
* @param string &$buffer
- * @access private
-*/
+ * @access private
+*/
function _resolve_id($id,&$buffer )
{
$id_buffer='';
@@ -705,7 +705,7 @@
}
$this->_resolve_uri_reference( $this->rdf_get_base(), $id_buffer, $buffer );
-
+
}
/**
@@ -713,8 +713,8 @@
* @param string &$buffer
* @param string &$namespace_uri
* @param string &$local_name
- * @access private
-*/
+ * @access private
+*/
function _split_name($name, &$buffer, &$namespace_uri, &$local_name )
{
static $nul = 0;
@@ -745,8 +745,8 @@
}
/**
* @param string &$buf
- * @access private
-*/
+ * @access private
+*/
function _generate_anonymous_uri(&$buf )
{
$id='';
@@ -759,7 +759,7 @@
}
/**
- * @param string $subject_type
+ * @param string $subject_type
* @param string $subject
* @param string $predicate
* @param string $ordinal
@@ -769,8 +769,8 @@
* @param string $bag_id
* @param string $statements
* @param string $statement_id
- * @access private
-*/
+ * @access private
+*/
function _report_statement( $subject_type, $subject, $predicate, $ordinal, $object_type, $object, $xml_lang, $bag_id, $statements, $statement_id, $datatype )
{
$statement_id_type = RDF_SUBJECT_TYPE_URI;
@@ -778,7 +778,7 @@
$predicate_buffer='';
if (!$xml_lang && $object_type == RDF_OBJECT_TYPE_LITERAL && isset($this->rdf_parser['document_xml_lang']))
$xml_lang = $this->rdf_parser['document_xml_lang'];
-
+
// call add statement
$this->add_statement_to_model($this->rdf_parser['user_data'],$subject_type,$subject,$predicate,$ordinal,$object_type,$object,$xml_lang, $datatype );
@@ -837,20 +837,20 @@
'',
'',
$datatype );
-
+
if ($subject_type == RDF_SUBJECT_TYPE_BNODE)
$obj_type = RDF_OBJECT_TYPE_BNODE;
- else
- $obj_type = RDF_OBJECT_TYPE_RESOURCE;
-
-
+ else
+ $obj_type = RDF_OBJECT_TYPE_RESOURCE;
+
+
// rdf:subject
$this->_report_statement(
$statement_id_type,
$statement_id,
RDF_NAMESPACE_URI.RDF_SUBJECT,
- 0,
- $obj_type,
+ 0,
+ $obj_type,
$subject,
'',
'',
@@ -894,8 +894,8 @@
* @param string $xml_lang
* @param string $bag_id
* @param string $statements
- * @access private
-*/
+ * @access private
+*/
function _handle_property_attributes($subject_type, $subject, $attributes, $xml_lang, $bag_id, $statements )
{
$i=0;
@@ -978,7 +978,7 @@
&& ($attribute_local_name != RDF_BAG_ID)
&& ($attribute_local_name != RDF_RESOURCE)
&& ($attribute_local_name != RDF_PARSE_TYPE)
- && ($attribute_local_name != RDF_PARSE_TYPE_LITERAL)
+ && ($attribute_local_name != RDF_PARSE_TYPE_LITERAL)
&& ($attribute_local_name != RDF_PARSE_TYPE_RESOURCE)
&& ($attribute_local_name != RDF_LI)
&& ($attribute_local_name != RDF_SUBJECT)
@@ -990,7 +990,7 @@
&& ($attribute_local_name != RDF_NIL)
&& ($attribute_local_name != RDF_REST)
&& ($attribute_local_name != RDF_FIRST)
- )
+ )
{
$this->_report_statement(
$subject_type,
@@ -1004,14 +1004,14 @@
$statements,
'',
'' );
- }
+ }
}
else if( XML_NAMESPACE_URI == $attribute_namespace_uri )
{
if ($attribute_local_name == 'base')
{
$this->rdf_parser['top']['element_base_uri'] = $attribute_value;
- }
+ }
}
else if( $attribute_namespace_uri )
{
@@ -1037,8 +1037,8 @@
/**
* @param string $warning
- * @access private
-*/
+ * @access private
+*/
function _report_warning($warning)
{
$errmsg = RDFAPI_ERROR . '(class: parser): ' . $warning .'.';
@@ -1049,7 +1049,7 @@
function _report_error($error)
{
$errmsg = RDFAPI_ERROR . '(class: parser): ' . $error .'.';
- trigger_error($errmsg, E_USER_ERROR);
+ trigger_error($errmsg, E_USER_ERROR);
}
@@ -1058,8 +1058,8 @@
* @param string $local_name
* @param string $attributes
* @param string $parent
- * @access private
-*/
+ * @access private
+*/
function _handle_resource_element( $namespace_uri, $local_name, $attributes, $parent )
{
$subjects_found = 0;
@@ -1092,18 +1092,18 @@
$this->rdf_parser['top']['has_property_attributes'] = false;
$this->rdf_parser['top']['has_member_attributes'] = false;
-
+
if( $namespace_uri == RDF_NAMESPACE_URI )
{
if( ! $this->_is_rdf_node_element( $local_name ) )
- {
- $msg = 'unknown or out of context rdf node element: '.$local_name;
-
+ {
+ $msg = 'unknown or out of context rdf node element: '.$local_name;
+
if ($this->_is_forbidden_rdf_node_element($local_name))
$this->_report_error($msg);
- else
- $this->_report_warning($msg);
- }
+ else
+ $this->_report_warning($msg);
+ }
}
// examine each attribute for the standard RDF "keywords"
@@ -1127,14 +1127,14 @@
$id = $attribute_value;
++$subjects_found;
} else if( $attribute_local_name == RDF_ABOUT ) {
- $about = '_'.$attribute_value;
+ $about = '_'.$attribute_value;
++$subjects_found;
} else if( $attribute_local_name == RDF_NODEID) {
$node_id = $attribute_value;
++$subjects_found;
} else if( $attribute_local_name == RDF_ABOUT_EACH ) {
$error = 'aboutEach has been removed from the RDF specifications';
- $this->_report_error($error);
+ $this->_report_error($error);
} else if( $attribute_local_name == RDF_ABOUT_EACH_PREFIX ) {
$error = 'aboutEachPrefix has been removed from the RDF specifications';
$this->_report_error($error);
@@ -1149,12 +1149,12 @@
$this->rdf_parser['top']['has_member_attributes'] = true;
} else {
$this->rdf_parser['top']['has_property_attributes'] = true;
- $msg = 'unknown or out of context rdf attribute: '.$attribute_local_name;
-
+ $msg = 'unknown or out of context rdf attribute: '.$attribute_local_name;
+
if ($this->_is_forbidden_rdf_property_attribute($attribute_local_name))
$this->_report_error($msg);
- else
- $this->_report_warning($msg);
+ else
+ $this->_report_warning($msg);
}
}
else if( $attribute_namespace_uri == XML_NAMESPACE_URI )
@@ -1166,7 +1166,7 @@
elseif ($attribute_local_name == 'base')
{
$this->rdf_parser['top']['element_base_uri'] = $attribute_value;
- }
+ }
}
else if( $attribute_namespace_uri )
{
@@ -1183,7 +1183,7 @@
}
else if( $subjects_found > 1 )
{
- $this->_report_error('ID, about and nodeID are mutually exclusive');
+ $this->_report_error('ID, about and nodeID are mutually exclusive');
}
else if( $id )
{
@@ -1192,22 +1192,22 @@
$this->rdf_parser['top']['subject']=$id_buffer;
}
else if( $about )
- {
- $this->_resolve_uri_reference( $this->rdf_get_base(), substr($about,1), $id_buffer );
+ {
+ $this->_resolve_uri_reference( $this->rdf_get_base(), substr($about,1), $id_buffer );
$this->rdf_parser['top']['subject_type'] = RDF_SUBJECT_TYPE_URI;
$this->rdf_parser['top']['subject']=$id_buffer;
- }
+ }
else if( $node_id )
{
$this->is_valid_id($node_id);
$this->rdf_parser['top']['subject_type'] = RDF_SUBJECT_TYPE_BNODE;
$this->rdf_parser['top']['subject']=$node_id;
}
-
+
// if the subject is empty, assign it the document uri
if( $this->rdf_parser['top']['subject'] == '' )
{
- $this->rdf_parser['top']['subject']=$this->rdf_get_base();
+ $this->rdf_parser['top']['subject']=$this->rdf_get_base();
}
if( $bag_id )
@@ -1233,7 +1233,7 @@
'',
$this->rdf_parser['top']['bag_id'],
$this->rdf_parser['top']['statements'],
- '',
+ '',
$datatype);
}
@@ -1243,10 +1243,10 @@
if( $parent )
{
if ($this->rdf_parser['top']['subject_type'] == RDF_SUBJECT_TYPE_BNODE)
- $objtype = RDF_OBJECT_TYPE_BNODE;
+ $objtype = RDF_OBJECT_TYPE_BNODE;
else
- $objtype = RDF_OBJECT_TYPE_RESOURCE;
-
+ $objtype = RDF_OBJECT_TYPE_RESOURCE;
+
$this->_report_statement(
$parent['parent']['subject_type'],
$parent['parent']['subject'],
@@ -1257,7 +1257,7 @@
'',
$parent['parent']['bag_id'],
$parent['parent']['statements'],
- $parent['statement_id'],
+ $parent['statement_id'],
$parent['datatype']);
}
@@ -1278,8 +1278,8 @@
* @param string &$namespace_uri
* @param string &$local_name
* @param string &$attributes
- * @access private
-*/
+ * @access private
+*/
function _handle_property_element( &$namespace_uri, &$local_name, &$attributes )
{
$buffer='';
@@ -1303,7 +1303,7 @@
$bag_id = '';
$parse_type = '';
$node_id = '';
- $datatype = '';
+ $datatype = '';
$this->rdf_parser['top']['ordinal'] = 0;
@@ -1311,14 +1311,14 @@
{
if( ! $this->_is_rdf_property_element( $local_name ) )
{
- $msg = 'unknown or out of context rdf property element: '.$local_name;
-
+ $msg = 'unknown or out of context rdf property element: '.$local_name;
+
if ($this->_is_forbidden_rdf_property_element($local_name))
$this->_report_error($msg);
- else
+ else
$this->_report_warning($msg);
}
-
+
}
$buffer=$namespace_uri;
@@ -1332,7 +1332,7 @@
$this->rdf_parser['top']['ordinal']=$this->rdf_parser['top']['ordinal'];
$buffer.='_'.$this->rdf_parser['top']['ordinal'];
-
+
}
else
{
@@ -1344,7 +1344,7 @@
$this->rdf_parser['top']['has_property_attributes'] = false;
$this->rdf_parser['top']['has_member_attributes'] = false;
-
+
for( $i = 0; isset($attributes[$i]); $i += 2 )
{
$this->_split_name(
@@ -1362,19 +1362,19 @@
{
if( ( $attribute_local_name == RDF_ID ) )
{
- $statement_id = $attribute_value;
+ $statement_id = $attribute_value;
}
else if( $attribute_local_name == RDF_PARSE_TYPE )
- {
+ {
$parse_type = $attribute_value;
}
else if( $attribute_local_name == RDF_RESOURCE )
{
- $resource = $attribute_value;
+ $resource = $attribute_value;
}
else if( $attribute_local_name == RDF_NODEID )
- {
- $node_id = $attribute_value;
+ {
+ $node_id = $attribute_value;
}
else if( $attribute_local_name == RDF_BAG_ID )
{
@@ -1393,7 +1393,7 @@
{
$this->_report_warning('unknown rdf attribute: '.$attribute_local_name );
return;
- }
+ }
}
else if( $attribute_namespace_uri == XML_NAMESPACE_URI )
{
@@ -1404,29 +1404,29 @@
elseif ($attribute_local_name == 'base')
{
$this->rdf_parser['top']['element_base_uri'] = $attribute_value;
- }
+ }
}
else if( $attribute_namespace_uri )
{
$this->rdf_parser['top']['has_property_attributes'] = true;
}
- }
+ }
if( $statement_id )
{
$this->_resolve_id($statement_id, $buffer );
$this->rdf_parser['top']['statement_id']=$buffer;
}
-
+
if ($node_id)
{
$this->is_valid_id($node_id);
-
+
if ($resource)
{
$this->_report_error('nodeID and resource are mutually exclusive');
- }
- if ($statement_id)
+ }
+ if ($statement_id)
{
// reify statement
$this->_report_statement(
@@ -1434,17 +1434,17 @@
$this->rdf_parser['top']['parent']['subject'],
$this->rdf_parser['top']['predicate'],
$this->rdf_parser['top']['ordinal'],
- RDF_OBJECT_TYPE_BNODE,
- $node_id,
+ RDF_OBJECT_TYPE_BNODE,
+ $node_id,
'',
$this->rdf_parser['top']['parent']['bag_id'],
$this->rdf_parser['top']['parent']['statements'],
- $this->rdf_parser['top']['statement_id'],
- '');
- $statement_id = '';
- }
- else
- {
+ $this->rdf_parser['top']['statement_id'],
+ '');
+ $statement_id = '';
+ }
+ else
+ {
$this->_report_statement(
$this->rdf_parser['top']['parent']['subject_type'],
$this->rdf_parser['top']['parent']['subject'],
@@ -1456,12 +1456,12 @@
$this->rdf_parser['top']['parent']['bag_id'],
$this->rdf_parser['top']['parent']['statements'],
'',
- $datatype );
- }
-
- $this->rdf_parser['top']['state'] = IN_PROPERTY_EMPTY_RESOURCE;
+ $datatype );
+ }
+
+ $this->rdf_parser['top']['state'] = IN_PROPERTY_EMPTY_RESOURCE;
}
-
+
if( $parse_type )
{
if( $resource ) {
@@ -1478,7 +1478,7 @@
$this->_report_error('property elements with rdf:parseType do not allow property attributes');
return;
}
-
+
if( $attribute_value == RDF_PARSE_TYPE_RESOURCE )
{
$this->_generate_anonymous_uri( $buffer );
@@ -1503,18 +1503,18 @@
$this->rdf_parser['top']['subject']=$buffer;
$this->rdf_parser['top']['bag_id']='';
$this->rdf_parser['top']['datatype']= $datatype;
-
- }
+
+ }
elseif ( $attribute_value == RDF_PARSE_TYPE_LITERAL )
{
$this->rdf_parser['top']['state'] = IN_PROPERTY_PARSE_TYPE_LITERAL;
$this->rdf_parser['top']['datatype']= RDF_NAMESPACE_URI .RDF_XMLLITERAL;
- $this->rdf_parser['xml_literal']['buffer'] = '';
- $this->rdf_parser['xml_literal']['depth'] = 0;
+ $this->rdf_parser['xml_literal']['buffer'] = '';
+ $this->rdf_parser['xml_literal']['depth'] = 0;
}
- elseif ($attribute_value == RDF_PARSE_TYPE_COLLECTION)
+ elseif ($attribute_value == RDF_PARSE_TYPE_COLLECTION)
{
- $this->_generate_anonymous_uri( $buffer );
+ $this->_generate_anonymous_uri( $buffer );
$this->_report_statement(
$this->rdf_parser['top']['parent']['subject_type'],
$this->rdf_parser['top']['parent']['subject'],
@@ -1527,14 +1527,14 @@
$this->rdf_parser['top']['parent']['statements'],
$this->rdf_parser['top']['statement_id'],
$datatype );
-
+
$this->rdf_parser['top']['state'] = IN_PROPERTY_PARSE_TYPE_COLLECTION;
$this->rdf_parser['top']['collection']['first_blank_node_id'] = $buffer;
- }
-
+ }
+
else
{
-
+
$this->_report_statement(
$this->rdf_parser['top']['parent']['subject_type'],
$this->rdf_parser['top']['parent']['subject'],
@@ -1580,11 +1580,11 @@
$this->rdf_parser['top']['parent']['statements'],
$this->rdf_parser['top']['statement_id'],
$datatype ); // should we allow IDs?
-
+
if( $bag_id )
{
$this->_resolve_id( $bag_id, $buffer );
- $this->rdf_parser['top']['bag_id']=$buffer;
+ $this->rdf_parser['top']['bag_id']=$buffer;
}
if( $this->rdf_parser['top']['has_property_attributes'] )
@@ -1595,17 +1595,17 @@
$attributes,
$this->rdf_parser['top']['xml_lang'],
$this->rdf_parser['top']['bag_id'],
- $this->rdf_parser['top']['statements'] );
+ $this->rdf_parser['top']['statements'] );
}
- }
+ }
}
-
+
/**
* @param string &$namespace_uri
* @param string &$local_name
* @param string &$attributes
- * @access private
-*/
+ * @access private
+*/
function _handle_collection_element(&$namespace_uri, &$local_name, &$attributes)
{
$aux2=Array();
@@ -1615,7 +1615,7 @@
}
$attributes=$aux2;
/* collection construction site
-// old:
+// old:
if ( ($namespace_uri == RDF_NAMESPACE_URI || $namespace_uri == '')
&& ($local_name == RDF_DESCRIPTION || $local_name == RDF_LI) )
{
@@ -1628,13 +1628,13 @@
$attribute_local_name );
$attribute_value = $attributes[ $i + 1 ];
-
+
if( $attribute_namespace_uri == '' || $attribute_namespace_uri == RDF_NAMESPACE_URI )
{
- if( $attribute_local_name == RDF_ABOUT ||
- $attribute_local_name == RDF_RESOURCE)
+ if( $attribute_local_name == RDF_ABOUT ||
+ $attribute_local_name == RDF_RESOURCE)
{
- $this->rdf_parser['top']['parent']['collection']['object_type'][] = RDF_OBJECT_TYPE_RESOURCE;
+ $this->rdf_parser['top']['parent']['collection']['object_type'][] = RDF_OBJECT_TYPE_RESOURCE;
}
elseif ( $attribute_local_name == RDF_NODEID ) {
$this->rdf_parser['top']['parent']['collection']['object_type'][] = RDF_OBJECT_TYPE_BNODE;
@@ -1655,30 +1655,30 @@
$attribute_local_name );
$attribute_value = $attributes[ $i + 1 ];
-
+
if( $attribute_namespace_uri == '' || $attribute_namespace_uri == RDF_NAMESPACE_URI )
{
$tmp_subject_type = RDF_SUBJECT_TYPE_URI;
- if( $attribute_local_name == RDF_ABOUT ||
- $attribute_local_name == RDF_RESOURCE)
+ if( $attribute_local_name == RDF_ABOUT ||
+ $attribute_local_name == RDF_RESOURCE)
{
- $this->rdf_parser['top']['parent']['collection']['object_type'][] = RDF_OBJECT_TYPE_RESOURCE;
+ $this->rdf_parser['top']['parent']['collection']['object_type'][] = RDF_OBJECT_TYPE_RESOURCE;
}
elseif ( $attribute_local_name == RDF_NODEID ) {
$this->rdf_parser['top']['parent']['collection']['object_type'][] = RDF_OBJECT_TYPE_BNODE;
$tmp_subject_type = RDF_SUBJECT_TYPE_BNODE;
}
$id_buffer = '';
- $this->_resolve_uri_reference( $this->rdf_get_base(), $attribute_value, $id_buffer );
+ $this->_resolve_uri_reference( $this->rdf_get_base(), $attribute_value, $id_buffer );
$this->rdf_parser['top']['parent']['collection']['object_label'][] = $id_buffer;
-
+
if (!( ($namespace_uri == RDF_NAMESPACE_URI || $namespace_uri == '')
&& ($local_name == RDF_DESCRIPTION || $local_name == RDF_LI) ))
- {
+ {
$this->_report_statement(
$tmp_subject_type,
- $id_buffer,
- RDF_NAMESPACE_URI.RDF_TYPE,
+ $id_buffer,
+ RDF_NAMESPACE_URI.RDF_TYPE,
'',
RDF_OBJECT_TYPE_RESOURCE,
$namespace_uri.$local_name,
@@ -1692,15 +1692,15 @@
}
-// collection construction site
+// collection construction site
}
/**
* @param string &$namespace_uri
* @param string &$local_name
* @param string &$attributes
- * @access private
-*/
+ * @access private
+*/
function _handle_xml_start_element(&$namespace_uri, &$local_name, &$attributes)
{
$aux2=Array();
@@ -1709,9 +1709,9 @@
$aux2[]=$atvalue;
}
$attributes=$aux2;
-
- $element = '<' .$this->_join_name_and_declare_prefix($namespace_uri, $local_name);
-
+
+ $element = '<' .$this->_join_name_and_declare_prefix($namespace_uri, $local_name);
+
for( $i = 0; isset($attributes[$i]); $i += 2 )
{
$this->_split_name(
@@ -1723,42 +1723,42 @@
$attribute_value = $attributes[ $i + 1 ];
$element .= ' ' .$this->_join_name_and_declare_prefix($attribute_namespace_uri, $attribute_local_name);
- $element .= '=\"' .$attribute_value .'\"';
+ $element .= '=\"' .$attribute_value .'\"';
}
$element .= '>';
-
+
$this->rdf_parser['xml_literal']['buffer'] .= $element;
}
/**
* @param string $name
- * @access private
-*/
+ * @access private
+*/
function _handle_xml_end_element($name)
{
$buffer='';
$namespace_uri='';
$local_name='';
-
+
$this->_split_name(
$name,
$buffer,
$namespace_uri,
$local_name );
-
- $element = '</';
-
- if ($namespace_uri && isset($this->rdf_parser['default_namespace'])
+
+ $element = '</';
+
+ if ($namespace_uri && isset($this->rdf_parser['default_namespace'])
&&$namespace_uri != $this->rdf_parser['default_namespace'])
{
- $element .= $this->rdf_parser['namespaces'][$namespace_uri] .':';
+ $element .= $this->rdf_parser['namespaces'][$namespace_uri] .':';
}
-
+
$element .= $local_name .'>';
-
- $this->rdf_parser['xml_literal']['buffer'] .= $element;
+
+ $this->rdf_parser['xml_literal']['buffer'] .= $element;
$depth = $this->rdf_parser['xml_literal']['depth']--;
-
+
if (isset($this->rdf_parser['xml_literal']['declared_ns']))
foreach ($this->rdf_parser['xml_literal']['declared_ns'] as $prefix => $_depth)
{
@@ -1770,66 +1770,66 @@
/**
* @param string $namespace_uri
* @param string $local_name
- * @access private
-*/
+ * @access private
+*/
function _join_name_and_declare_prefix($namespace_uri, $local_name) {
-
+
$name = '';
-
+
if ($namespace_uri)
- {
+ {
if (isset($this->rdf_parser['default_namespace'])
&& $namespace_uri == $this->rdf_parser['default_namespace'])
- {
+ {
$name .= $local_name;
-
+
if (!isset($this->rdf_parser['xml_literal']['declared_ns']['_DEFAULT_'])
&& $namespace_uri != XML_NAMESPACE_URI)
{
$name .= ' xmlns=' . '\"' .$namespace_uri .'\"';
-
- $this->rdf_parser['xml_literal']['declared_ns']['_DEFAULT_']
+
+ $this->rdf_parser['xml_literal']['declared_ns']['_DEFAULT_']
= $this->rdf_parser['xml_literal']['depth'];
}
}
else
{
- $ns_prefix = $this->rdf_parser['namespaces'][$namespace_uri];
- $name .= $ns_prefix .':' .$local_name;
-
+ $ns_prefix = $this->rdf_parser['namespaces'][$namespace_uri];
+ $name .= $ns_prefix .':' .$local_name;
+
if (!isset($this->rdf_parser['xml_literal']['declared_ns'][$ns_prefix])
&& $namespace_uri != XML_NAMESPACE_URI)
{
$name .= " xmlns:$ns_prefix=" . '\"' .$namespace_uri .'\"';
-
- $this->rdf_parser['xml_literal']['declared_ns'][$ns_prefix]
+
+ $this->rdf_parser['xml_literal']['declared_ns'][$ns_prefix]
= $this->rdf_parser['xml_literal']['depth'];
}
}
-
+
}
else
$name .= $local_name;
-
+
return $name;
-
+
}
/**
- * @access private
-*/
+ * @access private
+*/
function _end_collection() {
-
+
if (isset($this->rdf_parser['top']['collection']))
- {
-
+ {
+
$subject = $this->rdf_parser['top']['collection']['first_blank_node_id'];
-
- for ($i=0; isset($this->rdf_parser['top']['collection']['object_label'][$i]); $i++)
- {
-
+
+ for ($i=0; isset($this->rdf_parser['top']['collection']['object_label'][$i]); $i++)
+ {
+
$this->_report_statement(
- RDF_SUBJECT_TYPE_BNODE,
+ RDF_SUBJECT_TYPE_BNODE,
$subject,
RDF_NAMESPACE_URI.RDF_FIRST,
'',
@@ -1844,17 +1844,17 @@
if (!isset($this->rdf_parser['top']['collection']['object_label'][$i+1]))
{
$obj_type_2 = RDF_OBJECT_TYPE_RESOURCE;
- $object_2 = RDF_NAMESPACE_URI.RDF_NIL;
+ $object_2 = RDF_NAMESPACE_URI.RDF_NIL;
}
- else
+ else
{
$obj_type_2= RDF_OBJECT_TYPE_BNODE;
$this->_generate_anonymous_uri($object_2);
- }
-
-
+ }
+
+
$this->_report_statement(
- RDF_SUBJECT_TYPE_BNODE,
+ RDF_SUBJECT_TYPE_BNODE,
$subject,
RDF_NAMESPACE_URI.RDF_REST,
'',
@@ -1864,10 +1864,10 @@
'',
'',
'',
- '');
+ '');
- $subject = $object_2;
- }
+ $subject = $object_2;
+ }
}
}
@@ -1875,8 +1875,8 @@
* @param string $parser
* @param string $name
* @param string $attributes
- * @access private
-*/
+ * @access private
+*/
function _start_element_handler($parser, $name, $attributes )
{
$buffer='';
@@ -1896,31 +1896,31 @@
switch( $this->rdf_parser['top']['state'] )
{
case IN_TOP_LEVEL:
- // set base_uri, if possible
+ // set base_uri, if possible
foreach ($attributes as $key => $value) {
- if($key == XML_NAMESPACE_URI . NAMESPACE_SEPARATOR_CHAR . 'base') {
+ if($key == XML_NAMESPACE_URI . NAMESPACE_SEPARATOR_CHAR . 'base') {
$this->rdf_parser['base_uri'] = $value;
- $this->rdf_parser['document_base_uri'] = $value;
-
+ $this->rdf_parser['document_base_uri'] = $value;
+
$c = substr($value, strlen($value)-1 ,1);
if (!($c=='#' || $c==':' || $c=='/' || $c=="\\"))
$this->rdf_parser['normalized_base_uri'] = $value . '#';
else
- $this->rdf_parser['normalized_base_uri'] = $value;
-
+ $this->rdf_parser['normalized_base_uri'] = $value;
+
}
elseif ($key == XML_NAMESPACE_URI . NAMESPACE_SEPARATOR_CHAR .'lang')
$this->rdf_parser['document_xml_lang'] = $value;
echo "";
}
-
-
+
+
if( RDF_NAMESPACE_URI.NAMESPACE_SEPARATOR_STRING.RDF_RDF == $name )
- {
+ {
$this->rdf_parser['top']['state'] = IN_RDF;
- break;
- }
+ break;
+ }
case IN_RDF:
$this->rdf_parser['top']['state'] = IN_DESCRIPTION;
$this->_handle_resource_element( $namespace_uri, $local_name, $attributes, '' );
@@ -1953,7 +1953,7 @@
/* fall through */
case IN_XML:
$this->rdf_parser['xml_literal']['depth']++;
- $this->_handle_xml_start_element($namespace_uri, $local_name, $attributes);
+ $this->_handle_xml_start_element($namespace_uri, $local_name, $attributes);
break;
case IN_PROPERTY_RESOURCE:
$this->_report_warning(
@@ -1973,8 +1973,8 @@
IN_PROPERTY_LITERAL. as character data is received from expat,
it is saved in a buffer and reported when the end tag is
received.
- * @access private
-*/
+ * @access private
+*/
function _end_literal_property()
{
if(!isset($this->rdf_parser['top']['statement_id'])) {
@@ -2011,7 +2011,7 @@
$this->rdf_parser['top']['xml_lang'],
$this->rdf_parser['top']['parent']['bag_id'],
$this->rdf_parser['top']['parent']['statements'],
- $this->rdf_parser['top']['statement_id'],
+ $this->rdf_parser['top']['statement_id'],
$this->rdf_parser['top']['datatype']);
}
@@ -2019,18 +2019,18 @@
/**
* @param string $parser
* @param string $name
- * @access private
-*/
+ * @access private
+*/
function _end_element_handler( $parser, $name )
{
switch( $this->rdf_parser['top']['state'] )
{
case IN_TOP_LEVEL:
- break;
+ break;
case IN_XML:
- $this->_handle_xml_end_element($name);
+ $this->_handle_xml_end_element($name);
break;
- case IN_PROPERTY_UNKNOWN_OBJECT:
+ case IN_PROPERTY_UNKNOWN_OBJECT:
case IN_PROPERTY_LITERAL:
$this->_end_literal_property( );
break;
@@ -2040,17 +2040,17 @@
case IN_PROPERTY_PARSE_TYPE_LITERAL:
// $search = array((0) => chr(10), (1) => chr(13), (2) => chr(9));
// $replace = array((0) => '\n' , (1) => '\r' , (2) => '\t');
-// $this->rdf_parser["xml_literal"]["buffer"]
+// $this->rdf_parser["xml_literal"]["buffer"]
// = str_replace($search, $replace, $this->rdf_parser["xml_literal"]["buffer"]);
$this->rdf_parser['top']['data'] = $this->rdf_parser['xml_literal']['buffer'];
- $this->_end_literal_property();
- $this->rdf_parser['xml_literal']['buffer'] = '';
-
+ $this->_end_literal_property();
+ $this->rdf_parser['xml_literal']['buffer'] = '';
+
break;
case IN_PROPERTY_PARSE_TYPE_COLLECTION:
$this->_end_collection();
- break;
+ break;
case IN_RDF:
case IN_DESCRIPTION:
case IN_PROPERTY_RESOURCE:
@@ -2065,14 +2065,14 @@
/**
* @param string $parser
* @param string $s
- * @access private
-*/
+ * @access private
+*/
function _character_data_handler( $parser,$s)
{
$len=strlen($s);
switch( $this->rdf_parser['top']['state'] )
{
- case IN_PROPERTY_LITERAL:
+ case IN_PROPERTY_LITERAL:
case IN_PROPERTY_UNKNOWN_OBJECT:
if( isset($this->rdf_parser['top']['data']) )
{
@@ -2088,7 +2088,7 @@
if( $this->rdf_parser['top']['state'] == IN_PROPERTY_UNKNOWN_OBJECT )
{
/* look for non-whitespace */
- for( $i = 0; (( $i < $len ) && ( ereg(" |\n|\t",$s{ $i }) )); $i++ );
+ for( $i = 0; (( $i < $len ) && ( ereg(" |\n|\t",$s{ $i }) )); $i++ );
/* if we found non-whitespace, this is a literal */
if( $i < $len )
{
@@ -2097,12 +2097,12 @@
}
break;
- case IN_TOP_LEVEL:
+ case IN_TOP_LEVEL:
break;
- case IN_PROPERTY_PARSE_TYPE_LITERAL:
- case IN_XML:
+ case IN_PROPERTY_PARSE_TYPE_LITERAL:
+ case IN_XML:
$this->rdf_parser['xml_literal']['buffer'] .= $s;
- break;
+ break;
case IN_RDF:
case IN_DESCRIPTION:
case IN_PROPERTY_RESOURCE:
@@ -2118,7 +2118,7 @@
* Adds a new statement to the model
* This method is called by generateModel().
*
- * @access private
+ * @access private
* @param string &$user_data
* @param string $subject_type
* @param string $subject
@@ -2128,7 +2128,7 @@
* @param string $object
* @param string $xml_lang )
* @return object MemModel
- */
+ */
function add_statement_to_model(
&$user_data,
$subject_type,
@@ -2147,40 +2147,40 @@
$predicate=$this->str2unicode_nfc($predicate);
$object=$this->str2unicode_nfc($object);
}
-
+
//create subject
- if ($subject_type == RDF_SUBJECT_TYPE_BNODE)
+ if ($subject_type == RDF_SUBJECT_TYPE_BNODE)
$objsub = new BlankNode($subject);
else
$objsub = new Resource($subject);
-
- // create predicate
+
+ // create predicate
$objpred = new Resource($predicate);
-
+
// create object
if (($object_type == RDF_OBJECT_TYPE_RESOURCE) || ($object_type == RDF_OBJECT_TYPE_BNODE)) {
- if ($object_type == RDF_OBJECT_TYPE_BNODE)
+ if ($object_type == RDF_OBJECT_TYPE_BNODE)
$objobj = new BlankNode($object);
else
- $objobj = new Resource($object);
+ $objobj = new Resource($object);
} else {
-
+
$objobj = new Literal($object);
if ($datatype != '') {
$objobj->setDatatype($datatype);
- }
+ }
elseif ($xml_lang !='') {
$objobj->setLanguage($xml_lang);
- }
+ }
}
// create statement
$statement = new Statement($objsub, $objpred, $objobj);
-
+
// add statement to model
if(CREATE_MODEL_WITHOUT_DUPLICATES == TRUE){
$this->model->addWithoutDuplicates($statement);
- }else
+ }else
$this->model->add($statement);
}
@@ -2189,25 +2189,25 @@
/**
* Generates a new MemModel from a URI, a file or from memory.
- * If you want to parse an RDF document, pass the URI or location in the filesystem
+ * If you want to parse an RDF document, pass the URI or location in the filesystem
* of the RDF document. You can also pass RDF code direct to the function. If you pass
- * RDF code directly to the parser and there is no xml:base included, you should set
- * the base URI manually using the optional second parameter $rdfBaseURI.
+ * RDF code directly to the parser and there is no xml:base included, you should set
+ * the base URI manually using the optional second parameter $rdfBaseURI.
* Make sure that here are proper namespace declarations in your input document.
*
- * @access public
+ * @access public
* @param string $base
- * @param boolean $rdfBaseURI
+ * @param boolean $rdfBaseURI
* @return object MemModel
- */
+ */
function & generateModel($base,$rdfBaseURI = false, $model = false) {
// Check if $base is a URI or filename or a string containing RDF code.
if (substr(ltrim($base),0 ,1) != '<') {
-
+
// $base is URL or filename
$this->model = $model?$model:new MemModel($base);
-
+echo $base;
$input = fopen($base,'r') or die("RDF Parser: Could not open File: $base. Stopped parsing.");
$this->rdf_parser_create( NULL );
$this->rdf_set_base($base);
@@ -2216,7 +2216,7 @@
{
$buf = fread( $input, 512 );
$done = feof($input);
-
+
if ( ! $this->rdf_parse( $buf, feof($input) ) )
{
$err_code = xml_get_error_code( $this->rdf_get_xml_parser());
@@ -2224,16 +2224,16 @@
$errmsg = RDFAPI_ERROR . '(class: parser; method: generateModel): XML-parser-error ' . $err_code .' in Line ' . $line .' of input document.';
trigger_error($errmsg, E_USER_ERROR);
}
- }
+ }
/* close file. */
fclose( $input );
-
+
} else {
// $base is RDF string
$this->model = $model?$model:new MemModel($base);
-
+
$this->rdf_parser_create( NULL );
-
+
if ($rdfBaseURI!==false)
{
$this->rdf_set_base($rdfBaseURI);
@@ -2241,13 +2241,13 @@
{
$this->rdf_set_base( NULL );
}
-
+
if ( ! $this->rdf_parse( $base, TRUE ) )
{
$err_code = xml_get_error_code( $this->rdf_get_xml_parser());
$line = xml_get_current_line_number($this->rdf_get_xml_parser() );
$errmsg = RDFAPI_ERROR . '(class: parser; method: generateModel): XML-parser-error ' . $err_code .' in Line ' . $line .' of input document.';
- trigger_error($errmsg, E_USER_ERROR);
+ trigger_error($errmsg, E_USER_ERROR);
}
}
// base_uri could have changed while parsing
@@ -2256,24 +2256,24 @@
if(isset($this->rdf_parser['namespaces'])){
$this->model->addParsedNamespaces($this->rdf_parser['namespaces']);
}
-
+
$this->rdf_parser_free();
-
- return $this->model;
+ return $this->model;
+
}
/**
* @param string $encoding
- * @access private
-*/
+ * @access private
+*/
function rdf_parser_create( $encoding )
{
$parser = xml_parser_create_ns( $encoding, NAMESPACE_SEPARATOR_CHAR );
- xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+ xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
$this->rdf_parser['xml_parser'] = $parser;
xml_set_object($this->rdf_parser['xml_parser'], $this);
@@ -2288,26 +2288,26 @@
* @param resource &$parser
* @param string $ns_prefix
* @param string $ns_uri
- * @access private
-*/
+ * @access private
+*/
function _start_ns_declaration_handler(&$parser, $ns_prefix, $ns_uri)
{
- if (!$ns_prefix)
+ if (!$ns_prefix)
$this->rdf_parser['default_namespace'] = $ns_uri;
- else
+ else
$this->rdf_parser['namespaces'][$ns_uri] = $ns_prefix;
}
/**
- * @access private
-*/
+ * @access private
+*/
function rdf_parser_free( )
{
$z=3;
$this->rdf_parser['base_uri']='';
- $this->rdf_parser['document_base_uri'] = '';
+ $this->rdf_parser['document_base_uri'] = '';
unset( $this->rdf_parser );
}
@@ -2315,16 +2315,16 @@
/**
* @param string $s
* @param string $is_final
- * @access private
-*/
+ * @access private
+*/
function rdf_parse( $s, $is_final )
{
return XML_Parse( $this->rdf_parser['xml_parser'], $s, $is_final );
}
/**
- * @access private
-*/
+ * @access private
+*/
function rdf_get_xml_parser()
{
return ( $this->rdf_parser['xml_parser']);
@@ -2332,31 +2332,31 @@
/**
* @param string $base
- * @access private
-*/
+ * @access private
+*/
function rdf_set_base($base )
{
-
+
$this->rdf_parser['base_uri']=$base;
-
+
$c = substr($base, strlen($base)-1 ,1);
if (!($c=='#' || $c==':' || $c=='/' || $c=="\\"))
$this->rdf_parser['normalized_base_uri'] = $base . '#';
else
- $this->rdf_parser['normalized_base_uri'] = $base;
+ $this->rdf_parser['normalized_base_uri'] = $base;
return 0;
}
/**
- * @access private
-*/
+ * @access private
+*/
function rdf_get_base()
{
if ($this->rdf_parser['top']['element_base_uri'])
return $this->rdf_parser['top']['element_base_uri'];
- else
- return $this->rdf_parser['base_uri'];
+ else
+ return $this->rdf_parser['base_uri'];
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|