SparqlExtension: problem with formatting links

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SparqlExtension: problem with formatting links

Schneider, Martin
Hello all,

our configuration: MediaWiki 1.17.5, SMW 1.7.1, SparqlExtension 0.7 and Jena/Fuseki 1.0.0.

I have encountered a problem with the formatting of the SparqlExtension.
I have a Sparql-Query which returns links and labels and I want to show only the label.
The typical wiki syntax for this is [[ link | label ]].

So I have put the following into my output template:
[[ {{{link}}} | {{{label}}} ]]

The link and the label are replaced by the values from the sparql query in the correct way but the display is not just the label as expected.
Instead the complete expression is shown, with parentheses ("[]") and "|" .

Here is an example:
Sparql query:

{{#sparql:
PREFIX a:  ...

SELECT ?link  ?label
WHERE {a:{{{1}}} property:linkTo ?link.
 ?link ?property:hasLabel ?label.
}
|format=template
|template = label-list
|default=none
}}

Template label-list:
* [[ {{{link}}} | {{{label}}} ]]

A typical result could be: link: testpage , label testlabel
The asterisk would be correctly presented as a bullet point. And behind this would be [[ testpage | testlabel ]] where testpage works as link to testpage.

For now I have simply added text so the user knows that the link belongs to the label. (e.g. label: testlabel (link: testpage) ) But this is not nice and uses too much space.

Does anybody know how to resolve this?


Best regards,
Martin


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|

Re: SparqlExtension: problem with formatting links

Schneider, Martin
Hello all,

I have found the solution myself.

Usually, the results of the query will be automatically linked to pages with the corresponding names. This has happened here. This automatic linking has to be deactivated.

This is done by adding "|link=none" to the sparql query:
{{#sparql:
PREFIX a:  ...

SELECT ?link  ?label
WHERE {a:{{{1}}} property:linkTo ?link.
 ?link ?property:hasLabel ?label.
}
|format=template
|template = label-list
|default=none
|link=none
}}

I have realized this while comparing #ask to #sparql.
See here: http://semantic-mediawiki.org/wiki/Help:Template_format, paragraph "Using templates for custom formatting".

I have simply tried it and it works. I have looked afterwards at the documentation of the SparqlExtension (http://www.mediawiki.org/wiki/Extension:SparqlExtension) again, and in fact, this "|link=none" is used in the template example but without any explanation.

Learned a lot this morning ... ;-)

Best regards,
Martin


-----Urspr√ľngliche Nachricht-----
Von: Schneider, Martin [mailto:[hidden email]]
Gesendet: Dienstag, 18. Februar 2014 10:06
An: [hidden email]
Betreff: [Semediawiki-user] SparqlExtension: problem with formatting links

Hello all,

our configuration: MediaWiki 1.17.5, SMW 1.7.1, SparqlExtension 0.7 and Jena/Fuseki 1.0.0.

I have encountered a problem with the formatting of the SparqlExtension.
I have a Sparql-Query which returns links and labels and I want to show only the label.
The typical wiki syntax for this is [[ link | label ]].

So I have put the following into my output template:
[[ {{{link}}} | {{{label}}} ]]

The link and the label are replaced by the values from the sparql query in the correct way but the display is not just the label as expected.
Instead the complete expression is shown, with parentheses ("[]") and "|" .

Here is an example:
Sparql query:

{{#sparql:
PREFIX a:  ...

SELECT ?link  ?label
WHERE {a:{{{1}}} property:linkTo ?link.
 ?link ?property:hasLabel ?label.
}
|format=template
|template = label-list
|default=none
}}

Template label-list:
* [[ {{{link}}} | {{{label}}} ]]

A typical result could be: link: testpage , label testlabel The asterisk would be correctly presented as a bullet point. And behind this would be [[ testpage | testlabel ]] where testpage works as link to testpage.

For now I have simply added text so the user knows that the link belongs to the label. (e.g. label: testlabel (link: testpage) ) But this is not nice and uses too much space.

Does anybody know how to resolve this?


Best regards,
Martin


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|

SparqlExtension: how to display units of quantities?

Schneider, Martin
In reply to this post by Schneider, Martin
Hello all,

our configuration: MediaWiki 1.17.5, SMW 1.7.1, SparqlExtension 0.7 and Jena/Fuseki 1.0.0.

We are querying our semantic data with sparql queries. Now we have some properties of type "Quantity". During testing I have noticed that I don't get any unit when querying for those properties. Reading the documentation I have noticed that only the value is stored in the rdf triplestore. But how can I get the units?

I thought it would be possible to get the units also in the sparql query, e.g. by adding this to the query:

property:myQuantity property:Corresponds to ?unit.

But this won't work. (And if this would work this would have another problem: if I would get all units for one quantity how could I decide which is the default one?)

Any hints are welcome!

Best regards,
Martin




------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user