Table visualization of xquery results

Thursday, 16 August 2012 · 5 messages · last reply 17 Aug 2012
RH
Rob Heiser16 Aug 2012 02:02 #
I'm using BaseXGUI to develop xqueries. The xqueries transform some data from the database into XML that will be rendered as a table. Will the table visualization view in BasexGUI work this way? My xqueries look something like this:
 let $dbName := "foo"
   return
     <table>
       <columns>
         <column>Name</column>
         <column>Child name</column>
       </columns>
       <rows>
       {
         for $item in doc($dbname)/some/xpath
           return
             <row>
               <cell>{$item/name/text()}</cell>
               <cell>{$item/child/name/text()}</cell>
             </row>
       }
       </rows>
     </table>
The text view of the results look like I expect it to, and using the xqueries inside the application I'm developing works once I get them written and debugged. I'd like to preview the tables inside BaseXGUI if possible, before returning to the IDE and having to run the application, if possible. Thanks for any guidance.
-- Rob
DK
Dirk Kirsten16 Aug 2012 09:07 #
Hello Rob, I doubt that this is possible. The Table View (as the TreeView) displays the data in the currently opened database. The table view then marks nodes if they are within the result set of your XPath. It is made for and therefore can not interpret your XQuery and the specific result there. In fact, the table view is the same as the TreeView, just in a tabular fashion. And it is also not possible in the TreeView to render arbitrary data. It really is just a tool to look at your documents in the database. Cheers, Dirk
Quoted text · Rob Heiser · 38 lines
On Thu, Aug 16, 2012 at 12:02 AM, Rob Heiser <rheiser at gmail.com> wrote: > I'm using BaseXGUI to develop xqueries. The xqueries transform some > data from the database into XML that will be rendered as a table. Will > the table visualization view in BasexGUI work this way? My xqueries > look something like this: > > let $dbName := "foo" > return > <table> > <columns> > <column>Name</column> > <column>Child name</column> > </columns> > <rows> > { > for $item in doc($dbname)/some/xpath > return > <row> > <cell>{$item/name/text()}</cell> > <cell>{$item/child/name/text()}</cell> > </row> > } > </rows> > </table> > > The text view of the results look like I expect it to, and using the > xqueries inside the application I'm developing works once I get them > written and debugged. I'd like to preview the tables inside BaseXGUI > if possible, before returning to the IDE and having to run the > application, if possible. Thanks for any guidance. > > -- > Rob > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
MS
Michael Seiferlein reply to Rob Heiser, 16 Aug 2012, 02:0216 Aug 2012 11:20 #
Hi Rob, this might be a little detour, but still worth a try: By using RestXQ [1] you could transform your data to an HTML table and display it in any browser. E.g. like so: https://gist.github.com/45cdb78b093fc3d91cac The htmlize() function will simply rename your elements to math their html counterparts. You may then call this function from whithin RestXQ and see the results in any browser :) Kind regards Michael [1] http://docs.basex.org/wiki/RESTXQ
Quoted text · Rob Heiser · 37 lines
Am 16.08.2012 um 00:02 schrieb Rob Heiser <rheiser at gmail.com>: > I'm using BaseXGUI to develop xqueries. The xqueries transform some > data from the database into XML that will be rendered as a table. Will > the table visualization view in BasexGUI work this way? My xqueries > look something like this: > > let $dbName := "foo" > return > <table> > <columns> > <column>Name</column> > <column>Child name</column> > </columns> > <rows> > { > for $item in doc($dbname)/some/xpath > return > <row> > <cell>{$item/name/text()}</cell> > <cell>{$item/child/name/text()}</cell> > </row> > } > </rows> > </table> > > The text view of the results look like I expect it to, and using the > xqueries inside the application I'm developing works once I get them > written and debugged. I'd like to preview the tables inside BaseXGUI > if possible, before returning to the IDE and having to run the > application, if possible. Thanks for any guidance. > > -- > Rob > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Christian Grünin reply to Rob Heiser, 16 Aug 2012, 02:0216 Aug 2012 17:54 #
Hi Rob, one more cute workaround is the following one: 1) create an empty database and open it in the gui 2) write your query and store the result to this database An example query is attached below (it requires the creation of a "visdb" database). Hope this helps, Christian ___________________________
(: replaces database contents with new result :)
declare %updating function local:visualize($result) {
  db:replace('visdb', 'visdb', document { $result })
};

local:visualize(
  (: open database
  let $db := doc("foo") :)
  (: alternative: main-memory fragment
     to make it self-contained :)
  let $db := document {
    <some>
      <xpath>
        <name>bla</name>
        <child><name>blu</name></child>
      </xpath>
    </some>
  }
  return
   <table>
     <columns>
       <column>Name</column>
       <column>Child name</column>
     </columns>
     <rows>
     {
       for $item in $db/some/xpath
         return
           <row>
             <cell>{$item/name/text()}</cell>
             <cell>{$item/child/name/text()}</cell>
           </row>
     }
     </rows>
   </table>
)
Quoted text · Rob Heiser · 36 lines
> I'm using BaseXGUI to develop xqueries. The xqueries transform some > data from the database into XML that will be rendered as a table. Will > the table visualization view in BasexGUI work this way? My xqueries > look something like this: > > let $dbName := "foo" > return > <table> > <columns> > <column>Name</column> > <column>Child name</column> > </columns> > <rows> > { > for $item in doc($dbname)/some/xpath > return > <row> > <cell>{$item/name/text()}</cell> > <cell>{$item/child/name/text()}</cell> > </row> > } > </rows> > </table> > > The text view of the results look like I expect it to, and using the > xqueries inside the application I'm developing works once I get them > written and debugged. I'd like to preview the tables inside BaseXGUI > if possible, before returning to the IDE and having to run the > application, if possible. Thanks for any guidance. > > -- > Rob > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
RH
Rob Heiser17 Aug 2012 06:00 #
Thanks for the help, guys. Inserting into a sandbox database sounds interesting, I may try that. Otherwise, it's not too painful to just create the xquery file in the application and re-run. During quick iterations even small time savings add up, so it was worth asking the question. Thanks, again.
-- Rob

⚡Generated with XQuery