r26927 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26926‎ | r26927 | r26928 >
Date:16:56, 24 October 2007
Author:vrandezo
Status:old
Tags:
Comment:
Changed the underlying ontology from SMW to SWIVT
Modified paths:
  • /trunk/extensions/SemanticMediaWiki (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/ExportRDF/SMW_SpecialExportRDF.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/ExportRDF/SMW_SpecialExportRDF.php
@@ -282,7 +282,7 @@
283283 private $global_namespaces;
284284
285285 /**
286 - * Array of references to the SMW schema. Will be added at the end of the
 286+ * Array of references to the SWIVT schema. Will be added at the end of the
287287 * export.
288288 */
289289 private $schema_refs;
@@ -551,8 +551,7 @@
552552 "\t<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n" .
553553 "\t<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>\n" .
554554 "\t<!ENTITY owl 'http://www.w3.org/2002/07/owl#'>\n" .
555 - "\t<!ENTITY smw 'http://smw.ontoware.org/2005/smw#'>\n" .
556 - "\t<!ENTITY smwdt 'http://smw.ontoware.org/2005/smw-datatype#'>\n" .
 555+ "\t<!ENTITY swivt 'http://semantic-mediawiki.org/swivt/1.0#'>\n" .
557556 // A note on "wiki": this namespace is crucial as a fallback when it would be illegal to start e.g. with a number. In this case, one can always use wiki:... followed by "_" and possibly some namespace, since _ is legal as a first character.
558557 "\t<!ENTITY wiki '" . $this->wiki_xmlns_xml . "'>\n" .
559558 "\t<!ENTITY property '" . $this->wiki_xmlns_xml .
@@ -563,20 +562,21 @@
564563 "\txmlns:rdf=\"&rdf;\"\n" .
565564 "\txmlns:rdfs=\"&rdfs;\"\n" .
566565 "\txmlns:owl =\"&owl;\"\n" .
567 - "\txmlns:smw=\"&smw;\"\n" .
 566+ "\txmlns:swivt=\"&swivt;\"\n" .
568567 "\txmlns:wiki=\"&wiki;\"\n" .
569568 "\txmlns:property=\"&property;\"";
570 - $this->global_namespaces = array('rdf'=>true, 'rdfs'=>true, 'owl'=>true, 'smw'=>true, 'wiki'=>true, 'property'=>true);
 569+ $this->global_namespaces = array('rdf'=>true, 'rdfs'=>true, 'owl'=>true, 'swivt'=>true, 'wiki'=>true, 'property'=>true);
571570
572571 $this->post_ns_buffer .=
573572 ">\n\t<!-- Ontology header -->\n" .
574573 "\t<owl:Ontology rdf:about=\"\">\n" .
575 - "\t\t<smw:exportDate rdf:datatype=\"http://www.w3.org/2001/XMLSchema#dateTime\">" . date(DATE_W3C) . "</smw:exportDate>\n" .
 574+ "\t\t<swivt:creationDate rdf:datatype=\"http://www.w3.org/2001/XMLSchema#dateTime\">" . date(DATE_W3C) . "</swivt:creationDate>\n" .
 575+ "\t\t<owl:imports rdf:resource=\"http://semantic-mediawiki.org/swivt/1.0\" />\n" .
576576 "\t</owl:Ontology>\n" .
577577 "\t<!-- exported page data -->\n";
578 - $this->addSchemaRef( "hasArticle", "owl:AnnotationProperty" );
579 - $this->addSchemaRef( "exportDate", "owl:AnnotationProperty" );
580 - $this->addSchemaRef( "Thing", "owl:Class" );
 578+ $this->addSchemaRef( "page", "owl:AnnotationProperty" );
 579+ $this->addSchemaRef( "creationDate", "owl:AnnotationProperty" );
 580+ $this->addSchemaRef( "Subject", "owl:Class" );
581581 }
582582
583583 /**
@@ -588,20 +588,20 @@
589589 foreach (array_keys($this->schema_refs) as $name) {
590590 $type = $this->schema_refs[$name];
591591 $this->post_ns_buffer .=
592 - "\t<$type rdf:about=\"&smw;$name\">\n" .
593 - "\t\t<rdfs:isDefinedBy rdf:resource=\"http://smw.ontoware.org/2005/smw\"/>\n" .
 592+ "\t<$type rdf:about=\"&swivt;$name\">\n" .
 593+ "\t\t<rdfs:isDefinedBy rdf:resource=\"http://semantic-mediawiki.org/swivt/1.0\"/>\n" .
594594 "\t</$type>\n";
595595 }
596 - $this->post_ns_buffer .= "\t<!-- Created with Semantic MediaWiki, http://ontoworld.org/wiki/SMW -->\n";
 596+ $this->post_ns_buffer .= "\t<!-- Created with Semantic MediaWiki, http://semantic-mediawiki.org -->\n";
597597 $this->post_ns_buffer .= '</rdf:RDF>';
598598 }
599599
600600 /**
601 - * Adds a reference to the SMW schema. This will make sure that at the end of the page,
 601+ * Adds a reference to the SWIVT schema. This will make sure that at the end of the page,
602602 * all required schema references will be defined and point to the appropriate ontology.
603603 *
604604 * @param string $name The fragmend identifier of the entity to be referenced.
605 - * The SMW namespace is assumed.
 605+ * The SWIVT namespace is added.
606606 * @param string $type The type of the referenced identifier, i.e. is it an annotation
607607 * property, an object property, a class, etc. Should be given as a QName
608608 * (i.e. in the form "owl:Class", etc.)
@@ -649,12 +649,7 @@
650650 switch ($et->title_namespace) {
651651 case SMW_NS_PROPERTY:
652652 $equality_rel = "owl:equivalentProperty";
653 - global $smwgExportSemanticRelationHierarchy;
654 - if ($smwgExportSemanticRelationHierarchy) {
655 - $subprop_rel = "rdfs:subPropertyOf";
656 - } else {
657 - $subprop_rel = "smw:subPropertyOf";
658 - }
 653+ $subprop_rel = "rdfs:subPropertyOf";
659654
660655 switch ($et->has_type) {
661656 case '': case '_wpg': case '_uri': case '_ema': case '__nry':
@@ -677,7 +672,7 @@
678673 $equality_rel = "owl:equivalentClass";
679674 break;
680675 default:
681 - $type = 'smw:Thing';
 676+ $type = 'swivt:Subject';
682677 $category_rel = "rdf:type";
683678 $equality_rel = "owl:sameAs";
684679 break;
@@ -691,23 +686,23 @@
692687 }
693688 $this->post_ns_buffer .= ">\n" .
694689 "\t\t<rdfs:label>" . $et->label . "</rdfs:label>\n" .
695 - "\t\t<smw:hasArticle rdf:resource=\"&wikiurl;" .
 690+ "\t\t<swivt:page rdf:resource=\"&wikiurl;" .
696691 $et->title_prefurl . "\"/>\n" .
697692 "\t\t<rdfs:isDefinedBy rdf:resource=\"" .
698693 $this->special_url . '/' . $et->title_prefurl . "\"/>\n";
699694 // If the property is modified by a unit, export the modifier
700695 // and the base relation explicitly
701696 if ( $et->has_type && $et->modifier ) {
702 - $this->post_ns_buffer .= "\t\t<smw:hasModifier rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">" .
 697+ $this->post_ns_buffer .= "\t\t<swivt:modifier rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">" .
703698 smwfXMLContentEncode($et->modifier) .
704 - "</smw:hasModifier>\n";
 699+ "</swivt:modifier>\n";
705700 $baseprop = $this->getExportTitle($et->title_text, SMW_NS_PROPERTY);
706 - $this->post_ns_buffer .= "\t\t<smw:baseProperty rdf:resource=\"" . $baseprop->long_uri . "\"/>\n";
 701+ $this->post_ns_buffer .= "\t\t<swivt:baseProperty rdf:resource=\"" . $baseprop->long_uri . "\"/>\n";
707702 if (!array_key_exists($baseprop->hashkey, $this->element_queue)) {
708703 $this->element_queue[$baseprop->hashkey] = $baseprop;
709704 }
710705 $this->addSchemaRef( "baseProperty", "owl:AnnotationProperty" );
711 - $this->addSchemaRef( "hasModifier", "owl:AnnotationProperty" );
 706+ $this->addSchemaRef( "modifier", "owl:AnnotationProperty" );
712707 }
713708
714709 if ( ($fullexport) && ($et->exists) ) {
@@ -721,10 +716,10 @@
722717 }
723718
724719 // TODO: this is not convincing, esp. now that we have custom types
725 - if (isset($datatype_handler)) {
726 - $this->post_ns_buffer .= "\t\t<smw:hasType " . 'rdf:resource="&smwdt;' . $datatype_handler->getID() . "\"/>\n";
727 - $this->addSchemaRef( "hasType", "owl:AnnotationProperty" );
728 - }
 720+// if (isset($datatype_handler)) {
 721+// $this->post_ns_buffer .= "\t\t<swivt:type " . 'rdf:resource="&??;' . $datatype_handler->getID() . "\"/>\n";
 722+// $this->addSchemaRef( "type", "owl:AnnotationProperty" );
 723+// }
729724
730725 // add statements about equivalence to (external) URIs
731726 // FIXME: temporarily disabled
@@ -753,8 +748,6 @@
754749 if (!array_key_exists($supprop->hashkey, $this->element_queue)) {
755750 $this->element_queue[$supprop->hashkey] = $supprop;
756751 }
757 - if (!$smwgExportSemanticRelationHierarchy)
758 - $this->addSchemaRef( "subPropertyOf", "owl:AnnotationProperty");
759752 }
760753 }
761754
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php
@@ -102,9 +102,6 @@
103103 ##
104104 $smwgAllowRecursiveExport = false; // can normal users request recursive export?
105105 $smwgExportBacklinks = true; // should backlinks be included by default?
106 -$smwgExportSemanticRelationHierarchy = false; // should subrelations be exported with or wo semantics?
107 -// as long as the underlying implementation does not support the semantics the export
108 -// should reflect the same.
109106 $smwgOWLFullExport = false; // decides, if the RDF export will export, by default,
110107 // OWL Full or rather nice OWL DL. Can be overriden in the RDF export class.
111108 // global $smwgNamespace; // The Namespace of exported URIs.
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php
@@ -358,7 +358,7 @@
359359 */
360360 public function exportToRDF( $QName, ExportRDF $exporter ) {
361361 $rdf = "\t\t<$QName>\n";
362 - $rdf.= "\t\t\t<smw:NAry>\n";
 362+ $rdf.= "\t\t\t<swivt:Container>\n";
363363 $count = 0;
364364 foreach ($this->m_values as $value) {
365365 $count++;
@@ -366,17 +366,17 @@
367367 continue;
368368 }
369369 if (($value->getTypeID() == '_wpg') || ($value->getTypeID() == '_uri') || ($value->getTypeID() == '_ema')) {
370 - $element = "nary" . $count . "o";
371 - $rdf .= "\t\t" . $value->exportToRDF( "smw:$element", $exporter );
 370+ $element = "object" . $count;
 371+ $rdf .= "\t\t" . $value->exportToRDF( "swivt:$element", $exporter );
372372 $exporter->addSchemaRef( $element, "owl:ObjectProperty" );
373373 } else {
374 - $element = "nary" . $count;
375 - $rdf .= "\t\t" . $value->exportToRDF( "smw:$element", $exporter );
 374+ $element = "value" . $count;
 375+ $rdf .= "\t\t" . $value->exportToRDF( "swivt:$element", $exporter );
376376 $exporter->addSchemaRef( $element, "owl:DatatypeProperty" );
377377 }
378378 }
379 - $rdf .= "\t\t\t</smw:NAry>\n";
380 - $exporter->addSchemaRef( "NAry", "owl:Class" );
 379+ $rdf .= "\t\t\t</swivt:Container>\n";
 380+ $exporter->addSchemaRef( "Container", "owl:Class" );
381381 $rdf .= "\t\t</$QName>\n";
382382 return $rdf;
383383 }
Property changes on: trunk/extensions/SemanticMediaWiki
___________________________________________________________________
Added: svn:ignore
384384 + .project
.settings

Status & tagging log