|
From: <cw...@us...> - 2007-08-13 11:13:18
|
Revision: 508
http://rdfapi-php.svn.sourceforge.net/rdfapi-php/?rev=508&view=rev
Author: cweiske
Date: 2007-08-13 04:13:15 -0700 (Mon, 13 Aug 2007)
Log Message:
-----------
Add N3Parser class option for output compression via []
Modified Paths:
--------------
trunk/rdfapi-php/api/syntax/N3Serializer.php
Modified: trunk/rdfapi-php/api/syntax/N3Serializer.php
===================================================================
--- trunk/rdfapi-php/api/syntax/N3Serializer.php 2007-08-13 10:00:37 UTC (rev 507)
+++ trunk/rdfapi-php/api/syntax/N3Serializer.php 2007-08-13 11:13:15 UTC (rev 508)
@@ -43,6 +43,8 @@
var $res;
var $anon;
+ var $styleCompress = false;
+
/**
* Constructor
*
@@ -200,6 +202,14 @@
};
}
+ /**
+ * Set to true, if the N3 serializer should try to compress the blank node
+ * syntax using [] whereever possible.
+ */
+ function setCompress($compress)
+ {
+ $this->styleCompress = $compress;
+ }
/* ==================== Private Methods from here ==================== */
@@ -274,6 +284,7 @@
}
$this->done[$r->getURI()]=TRUE;
+ $compress = false;
if ( is_a($r, 'Resource') ) {
@@ -281,11 +292,11 @@
//test, if this blanknode is referenced somewhere
$rbn=$this->model->find(null, null, $r);
-
- if (count($rbn->triples)>0 | !N3SER_BNODE_SHORT) {
+ $compress = count($rbn->triples) == 0 && (N3SER_BNODE_SHORT || $this->styleCompress);
+ if ($compress) {
+ $out.='[ ';
+ } else {
$out.='_:'.$r->getLabel();
- } else {
- $out.='[ ';
};
} else {
@@ -347,7 +358,9 @@
}
}
- if (isset($rbn) && !count($rbn->triples)>0 && N3SER_BNODE_SHORT) {$out.=' ] ';};
+ if ($compress) {
+ $out .= ' ] ';
+ };
$this->resourcetext[$r->getURI()]=$out;
return TRUE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|