Index: trunk/extensions/SemanticMediaWiki/specials/ExportRDF/SMW_SpecialExportRDF.php |
— | — | @@ -104,6 +104,7 @@ |
105 | 105 | public $ext_nsid = false; |
106 | 106 | public $ext_section = false; |
107 | 107 | // relevant title values, mandatory |
| 108 | + public $title; |
108 | 109 | public $title_text; |
109 | 110 | public $title_namespace; |
110 | 111 | public $title_id; |
— | — | @@ -127,6 +128,7 @@ |
128 | 129 | * provided DB handler. |
129 | 130 | */ |
130 | 131 | public function SMWExportTitle($title, $export, $modifier = '') { |
| 132 | + $this->title = $title; |
131 | 133 | $this->title_text = $title->getText(); |
132 | 134 | $this->title_id = $title->getArticleID(); |
133 | 135 | $this->title_namespace = $title->getNamespace(); |
— | — | @@ -551,6 +553,9 @@ |
552 | 554 | "\t<owl:AnnotationProperty rdf:about=\"&smw;hasType\">\n" . |
553 | 555 | "\t\t<rdfs:isDefinedBy rdf:resource=\"http://smw.ontoware.org/2005/smw\"/>\n" . |
554 | 556 | "\t</owl:AnnotationProperty>\n" . |
| 557 | + "\t<owl:AnnotationProperty rdf:about=\"&smw;subPropertyOf\">\n" . |
| 558 | + "\t\t<rdfs:isDefinedBy rdf:resource=\"http://smw.ontoware.org/2005/smw\"/>\n" . |
| 559 | + "\t</owl:AnnotationProperty>\n" . |
555 | 560 | "\t<owl:Class rdf:about=\"&smw;Thing\">\n" . |
556 | 561 | "\t\t<rdfs:isDefinedBy rdf:resource=\"http://smw.ontoware.org/2005/smw\"/>\n" . |
557 | 562 | "\t</owl:Class>\n" . |
— | — | @@ -565,12 +570,20 @@ |
566 | 571 | $datatype_rel = false; |
567 | 572 | $category_rel = false; |
568 | 573 | $equality_rel = false; |
| 574 | + $subrel_rel = false; |
| 575 | + $subatt_rel = false; |
569 | 576 | |
570 | 577 | // Set parameters for export |
571 | 578 | switch ($et->title_namespace) { |
572 | 579 | case SMW_NS_RELATION: |
573 | 580 | $type = 'owl:ObjectProperty'; |
574 | 581 | $equality_rel = "owl:equivalentProperty"; |
| 582 | + global $smwgExportSemanticRelationHierarchy; |
| 583 | + if ($smwgExportSemanticRelationHierarchy) { |
| 584 | + $subrel_rel = "rdfs:subPropertyOf"; |
| 585 | + } else { |
| 586 | + $subrel_rel = "smw:subPropertyOf"; |
| 587 | + } |
575 | 588 | break; |
576 | 589 | case SMW_NS_ATTRIBUTE: |
577 | 590 | if ( $et->has_type === false ) return; //attributes w/o type not exportable, TODO: is this what we want? |
— | — | @@ -585,6 +598,12 @@ |
586 | 599 | } |
587 | 600 | $equality_rel = "owl:equivalentProperty"; |
588 | 601 | } |
| 602 | + global $smwgExportSemanticRelationHierarchy; |
| 603 | + if ($smwgExportSemanticRelationHierarchy) { |
| 604 | + $subatt_rel = "rdfs:subPropertyOf"; |
| 605 | + } else { |
| 606 | + $subatt_rel = "smw:subPropertyOf"; |
| 607 | + } |
589 | 608 | break; |
590 | 609 | case NS_CATEGORY: |
591 | 610 | $type = 'owl:Class'; |
— | — | @@ -641,29 +660,33 @@ |
642 | 661 | // } |
643 | 662 | |
644 | 663 | // add rdfs:subPropertyOf statements |
645 | | - // FIXME: temporarily disabled |
646 | | -// if ($subrel_rel) { |
647 | | -// $relations = smwfGetSpecialPropertyValues($title,SMW_SP_IS_SUBRELATION_OF); |
648 | | -// foreach ($relations as $relation) { |
649 | | -// $relURIs = $this->getURIs($relation,0); |
650 | | -// //@TODO: do type checks here or on saving ... |
651 | | -// $this->post_ns_buffer .= "\t\t<$subrel_rel rdf:resource=\"$relURIs[0]\"/>\n"; |
652 | | -// if (!array_key_exists($relURIs[2], $this->element_queue)) { |
653 | | -// $this->element_queue[$relURIs[2]] = true; |
654 | | -// } |
655 | | -// } |
656 | | -// } |
657 | | -// if ($subatt_rel) { |
658 | | -// $attributes = smwfGetSpecialPropertyValues($title,SMW_SP_IS_SUBRELATION_OF); |
659 | | -// foreach ($attributes as $attribute) { |
660 | | -// $attURIs = $this->getURIs($attribute[2]); |
661 | | -// //@TODO: do type checks here or on saving ... |
662 | | -// $this->post_ns_buffer .= "\t\t<$subatt_rel rdf:resource=\"$attURIs[0]\"/>\n"; |
663 | | -// if (!array_key_exists($attURIs[2], $this->element_queue)) { |
664 | | -// $this->element_queue[$attURIs[2]] = true; |
665 | | -// } |
666 | | -// } |
667 | | -// } |
| 664 | + if ($subrel_rel) { |
| 665 | + $relations = &smwfGetStore()->getSpecialValues($et->title, SMW_SP_IS_SUBRELATION_OF); |
| 666 | + foreach ($relations as $relation) { |
| 667 | + // TODO in future, check type safety relations <-> attributes |
| 668 | + // TODO check also the type of what I am pointing to (is it a relation or sth else?) |
| 669 | + $suprel = $this->getExportTitle($relation, SMW_NS_RELATION); |
| 670 | + $this->post_ns_buffer .= "\t\t<$subrel_rel rdf:resource=\"" . $suprel->long_uri . "\"/>\n"; |
| 671 | + if (!array_key_exists($suprel->hashkey, $this->element_queue)) { |
| 672 | + $this->element_queue[$suprel->hashkey] = $suprel; |
| 673 | + } |
| 674 | + } |
| 675 | + } |
| 676 | + if ($subatt_rel) { |
| 677 | + $attributes = &smwfGetStore()->getSpecialValues($et->title, SMW_SP_IS_SUBATTRIBUTE_OF); |
| 678 | + foreach ($attributes as $attribute) { |
| 679 | + // TODO in future, check type safety relations <-> attributes |
| 680 | + // TODO check also the type of what I am pointing to (is it an atrribute or sth else?) |
| 681 | + // TODO check the type of the attribute pointed to, does it match? |
| 682 | + // Could lead to inconsistencies in the output -- and in the wiki? But this will |
| 683 | + // need to be dealt with as soon as people add subattribute semantics to the wiki |
| 684 | + $supatt = $this->getExportTitle($attribute, SMW_NS_ATTRIBUTE); |
| 685 | + $this->post_ns_buffer .= "\t\t<$subatt_rel rdf:resource=\"" . $supatt->long_uri . "\"/>\n"; |
| 686 | + if (!array_key_exists($supatt->hashkey, $this->element_queue)) { |
| 687 | + $this->element_queue[$supatt->hashkey] = $supatt; |
| 688 | + } |
| 689 | + } |
| 690 | + } |
668 | 691 | |
669 | 692 | if ($et->is_individual) { // do not print relations for schema elements, stay in OWL DL |
670 | 693 | // print all relations |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php |
— | — | @@ -56,6 +56,9 @@ |
57 | 57 | ## |
58 | 58 | $smwgAllowRecursiveExport = false; // can normal users request recursive export? |
59 | 59 | $smwgExportBacklinks = true; // should backlinks be included by default? |
| 60 | +$smwgExportSemanticRelationHierarchy = false; // should subrelations be exported with or wo semantics? |
| 61 | +// as long as the underlying implementation does not support the semantics the export |
| 62 | +// should reflect the same. |
60 | 63 | ## |
61 | 64 | |
62 | 65 | ### |