Summary: A new feature in SMW allows you to write queries that return plain unformatted values, useful when results are not directly displayed but further processed.
Details:
Many innovative (and sometimes quite hacky ;) applications of SMW use the
results of a query for further processing, e.g. to calculate with returned
numbers, to manipulate strings in the result, or to further process page names
in templates.
In all of these cases, it is desirable that outputs are not fancily formatted
for the user's eye, but rather returned in a plain simple format that is easy
to process. However, numbers so far were always returned in forms like
"1,234,567", properties would sometimes show tooltips, and links could only be
turned off globally for all query outputs.
A new feature is provided to address this problem in the next release
(currently available in SVN). By specifying "-" or "" (empty string) as an
output format in queries, outputs are returned in plain, unformatted form.
Example query:
{{#ask: [[Category:Country]]
| ?area#km²
| ?population#
| ?capital#-
}}
will return a table of four columns, all of which have an explicit output
format (the content after #). The first column are simply the countries, the
second is their area converted to "km²" as usual. The third one is their
population as a plain string (caveat: when numbers get large, scientific
notation is used; fixes for preventing this are welcome). The fourth column is
their capital, again as a plain (unlinked) string. Empty format strings and
"-" mean the same. Spaces are ignored.
For switching off all links (even in the first column), one can set the
parameter "link=none" or replace the first standard column with a new version
by adding the parameter "mainlabel=-" (hide first column) and the new printout
"?#" (display main column, with empty formatting string). I note that
currently there is a difference between "link=none" and the empty format: the
former simply avoids linking and tooltips, while the latter switches off all
formatting. Also, the new feature provides much better control since it can be
selected individually for each printout.
I hope the syntax is acceptable (it is an extension of the current syntax, but
the absence of readable keywords may render it somewhat technical; the
advantage is that it is pretty international).
Developers of own datatypes can extend their datatype implementations to act
appropriately when a datavalue's field "m_outformat" is set to "-" (this is
the only case you need to care about, empty strings won't appear at this
level). Currently, most SMW datatypes make their output as plain as possible
with this formatting switch: page names and URLs are unlinked, dates are in
ISO format, numbers are simple strings.
Cheers,
Markus
--
Markus Krötzsch
Semantic MediaWiki http://semantic-mediawiki.org
http://korrekt.org [email protected]
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Semediawiki-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
