Semanticmediawiki: Sparql query issue with links

Created on 19 Mar 2020  路  3Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

Setup and configuration

  • SMW version: 3.1.5
  • MW 1.31.6
  • PHP version: 7.3.15 (cgi-fcgi)
  • MySQL 5.6.41-log
  • PageForms 4.8
  • LinkedWiki 3.3.7

Old versions

  • SMW version: 2.5.8
  • MediaWiki 1.31.1
  • PHP 7.1.30 (apache2handler)
  • MySQL 5.6.10
  • PageForms 4.5.1
  • LinkedWiki 3.1.1 (73067e5) 14:39, 13 January 2018

Issue

Using short urls

I have Pageforms - query form That I have been using for some time. after upgrade, The SPARQL query works, however the links are bad know.

  • I get: server.comClient_Firewall/TS-2DRoadmap
  • it should be: server.com/wiki/Client_Firewall/TS-Roadmap
    ask query works fine
    I ran the SPARQL query at the endpoint and I come up with the same problem.
    Something like this, I'm not sure what I'm missing.
PREFIX property:<server.comProperty-3A>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX swivt:<http://semantic-mediawiki.org/swivt/1.0#>
SELECT ?supported_by ?Subcategory ?name ?version ?technology_name ?owner ?contact ?publication_date ?publication_status ?support_status ?manufacturer ?start_date ?end_date WHERE { ?s property:Has_technology ?name .
?s property:Has_parent_page ?parent.
  ?s property:Has_subobject ?subobject .
  ?subobject property:Has_Version ?version .
  ?subobject property:Technology_Name ?technology_name .
  ?subobject property:Has_Support_Status ?support_status .
  ?subobject property:Supported_By ?supported_by .
  ?subobject property:Has_Start_Date ?start_date .
...
}

Stack trace

No errors just bad links

To reproduce the issue, write a SPARQL Query with links on a wiki with short urls
I opened an issue on LinkedWiki talk
https://www.mediawiki.org/wiki/Extension_talk:LinkedWiki

question

Most helpful comment

I have to say I'm having a hard time to understand the core issue of this ticket, so let me guess on what this is about.

I get: server.comClient_Firewall/TS-2DRoadmap
it should be: server.com/wiki/Client_Firewall/TS-Roadmap

It is about the URI scheme used as reference in your SPARQL queries which seem different from what you used to be and those that are used as resource references.

The documentation of enableSemantics [0] states of what to expect and what not to do. For example, using enableSemantics( 'example.org/wiki', false ); produces a SPARQL with something like http://example.org/wiki/mw-foo/....

PREFIX wiki: <http://example.org/wiki/mw-foo/index.php/Special:URIResolver/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#>
PREFIX property: <http://example.org/wiki/mw-foo/index.php/Special:URIResolver/Property-3A>

while using enableSemantics( 'example.org/wiki/', true ); would generate a different URI scheme.

PREFIX wiki: <example.org/wiki/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#>
PREFIX property: <example.org/wiki/Property-3A>

So, yes, it is important to understand the difference and how those settings change the underlying assumptions about URIs which is why [0] explicitly states "... It is strongly recommended to not change the setting of this function after the initial setup of the wiki ...".

PS: The way enableSemantics works or is used to set $smwg颅Namespace hasn't changed. The base URI is generated from [1].

[0] https://www.semantic-mediawiki.org/wiki/Help:EnableSemantics
[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/includes/export/SMW_Exporter.php#L147-L190

All 3 comments

Hi, I have no experience with SPARQL but I know that SMW 3.0.0 has altered SPARQL settings. See https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/3315 and https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki_3.0.0#Breaking_changes_and_deprecations.

Also, visit Special:SemanticMediaWiki in your wiki to see other probably deprecations.

I have to say I'm having a hard time to understand the core issue of this ticket, so let me guess on what this is about.

I get: server.comClient_Firewall/TS-2DRoadmap
it should be: server.com/wiki/Client_Firewall/TS-Roadmap

It is about the URI scheme used as reference in your SPARQL queries which seem different from what you used to be and those that are used as resource references.

The documentation of enableSemantics [0] states of what to expect and what not to do. For example, using enableSemantics( 'example.org/wiki', false ); produces a SPARQL with something like http://example.org/wiki/mw-foo/....

PREFIX wiki: <http://example.org/wiki/mw-foo/index.php/Special:URIResolver/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#>
PREFIX property: <http://example.org/wiki/mw-foo/index.php/Special:URIResolver/Property-3A>

while using enableSemantics( 'example.org/wiki/', true ); would generate a different URI scheme.

PREFIX wiki: <example.org/wiki/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#>
PREFIX property: <example.org/wiki/Property-3A>

So, yes, it is important to understand the difference and how those settings change the underlying assumptions about URIs which is why [0] explicitly states "... It is strongly recommended to not change the setting of this function after the initial setup of the wiki ...".

PS: The way enableSemantics works or is used to set $smwg颅Namespace hasn't changed. The base URI is generated from [1].

[0] https://www.semantic-mediawiki.org/wiki/Help:EnableSemantics
[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/includes/export/SMW_Exporter.php#L147-L190

Thanks mwjames
enableSemantics( 'example.org/wiki/', true ); fixed most of the issues

Was this page helpful?
0 / 5 - 0 ratings