Thank you Markus, I guess that means that I should write my own result printer, which is basically a copy of the 'table' one, but producing an array rather than a html table? I will do that! (Just thought that there might be some function ready to use)

/Leo Wallentin


Leonard Wallentin
leo_wallentin@hotmail.com
+46 (0)735-933 543
http://säsongsmat.nu
http://nairobikoll.se/
http://twitter.com/leo_wallentin
Skype: leo_wallentin


> Date: Sun, 12 Jun 2011 12:29:56 +0100
> From: markus@semantic-mediawiki.org
> To: leo_wallentin@hotmail.com
> CC: semediawiki-devel@lists.sourceforge.net
> Subject: Re: [SMW-devel] Getting property values from query, the right way?
>
> Hi Leonard,
>
> is the SMWQueryResult object that you get from query answering not
> exactly what you want? It basically encodes the structure of a three
> dimensional array (rows -- cells in row -- values in cell), but using
> custom SMW classes for convenient (and efficient) access to the data.
>
> The table format, for example, preserves this structure, while the list
> format (as you rightly remark) does not separate the values coming from
> different cells if property labels are not shown. If you need another
> form of display, you should easily be able to create it from the
> SMWQueryResult. Basically, this means you are writing your own result
> printer. If you look at the code of the table result printer in SMW, you
> can see that the iteration over a three dimensional array is a bit
> cumbersome (esp. if interleaved with formatting customizations), but in
> the end it should not be too difficult to understand. From your email,
> it does not sound as if you really want to print data anyway, but the
> iteration over the data could be the same in other code, just without
> creating text from the data values.
>
> I hope this helps,
>
> Markus
>
>
> On 11/06/11 00:02, Leonard Wallentin wrote:
> > Hello, I'm sorry if this is a very simple question, but I've been
> > reading the manual for the whole day without getting it right. I'm
> > making a query from an extension, asking for two properties, one of
> > which will have multiple values. Problem is that when using
> > SMWQueryProcessor I am stuck with a few predefined formats, more
> > suitable for printing to the screen. What I would like is to get an
> > array or an object, something like this would be neat:
> >
> > 0 => { title => Article 1, property 1=> value, property 2=>{0 => a
> > value, 1 => another value}}, 1 => ...
> >
> > Using the 'list' format I get something like this:
> >
> > ”Article 1 (value, a value, another value)”
> >
> > Starting to write complex parsing functions to convert that into an
> > array seems wrong, as I'm sure the data must, at some point, have been
> > stored in a more progammatically accesible way, after being fetched from
> > the database, but before being written to a string like such.
> >
> >
> > My function is something like this:
> >
> > function doRequest ( $query, $properties = array() ) {
> >
> > $params = array('link'=>'none');
> > $context = SMWQueryProcessor::INLINE_QUERY;
> > $format = 'list';
> > $printouts = array();
> > foreach ( $properties as $p ) {
> >
> > $printouts[] = new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, "",
> > SMWPropertyValue::makeUserProperty($p));
> >
> > }
> >
> > $query = SMWQueryProcessor::createQuery($qs, $params, $context, $format,
> > $printouts);
> > $result = SMWQueryProcessor::getResultFromQuery($query, $params,
> > $printouts, SMW_OUTPUT_WIKI, $context, $format);
> >
> > return ($result);
> >
> > }
> >
> > Any directions on how to proceed would be very appreciated!
> >
> > Best regards
> > Leo Wallentin
> >
> > Leonard Wallentin
> > leo_wallentin@hotmail.com
> > +46 (0)735-933 543
> > http://säsongsmat.nu
> > http://nairobikoll.se/
> > http://twitter.com/leo_wallentin
> > Skype: leo_wallentin
> >
> > -----BEGIN PGP PUBLIC KEY BLOCK-----
> > Version: GnuPG v1.4.10 (GNU/Linux)
> >
> > mQENBE1JuiUBCADsAnoxo1o3G2Apkjs8NHSfbN4g/H8HbS4XXfjruZ6Afu6PBMJI
> > CoiopKmTzQojjUZEjM2i4QsynU2xX4PmpMloPCOXEWxQg7q6HgHKyBU9NroL+17T
> > WA/30jGTmi2pkuznX1LpYKz0r8oSUsrg9oIeJmSbPRP6bNjwlgaDzarfYjcfEFXu
> > Y0s8KdVT1M8Zw2Sq7QuYPaiT+gfLMN5FaCzCZPdHZu8L1lXszTtFxztiF0hTd2C6
> > 8yAW3DlTqTOSWqQtt10tf8VxeXPGxfqs6Ti8s5MsAsUtg9vw0A7gQC36SmRXel7W
> > l/rYbkESqDKANgIT6ofbIru0ozdy/BxnL2wXABEBAAG0LUxlb25hcmQgV2FsbGVu
> > dGluIDxsZW9fd2FsbGVudGluQGhvdG1haWwuY29tPokBOAQTAQIAIgUCTUm6JQIb
> > AwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQOYTL0N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
> > r3wzIiopALjOj/2N9kxaHg9MQOfERV6prfZmkxPP69ptlCnJVZL7vwTO/0E=
> > =KIpq
> > -----END PGP PUBLIC KEY BLOCK-----
> >
> >
> >
> >
> > ------------------------------------------------------------------------------
> > EditLive Enterprise is the world's most technically advanced content
> > authoring tool. Experience the power of Track Changes, Inline Image
> > Editing and ensure content is compliant with Accessibility Checking.
> > http://p.sf.net/sfu/ephox-dev2dev
> >
> >
> >
> > _______________________________________________
> > Semediawiki-devel mailing list
> > Semediawiki-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
>