Link to home
Start Free TrialLog in
Avatar of robert_jenkin
robert_jenkin

asked on

How to create a colaspible table using xml and xslt

I have an xml structure that contains data from a database. It has multiple rows and multiple columns.

I like to figure out an xsl that would take the data from the xml and create a html table component show the data from the xml.

I would also like to have the table use +/- to expand/colaspe sections based on differnent values in fields as well as total some columns.

Is this something doable with xslt?
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

well, XSLT can be used to build any html table based on values and structures in the data table.
but in order to do the collapse and expand, potentially sorting and all that, you will need something that controls the rendering of the table.

Most common way to achieve this task is to use an Ajax type approach
Use javascript in an HTML page to launch the XSLT that returns an HTML table with controls (buttons or whatever)
Make the click events refresh the table by running the XSLT with different parameters rendering a different type of table

This is pretty easy to set up if you would use a library such as Sarissa,
which would make running the XSLT in JavaScript browser independent

I have done a large amount of similar projects using XSLT and Sarissa to give full control on data in an HTML page
If that is what you want, you need to give us some more detaisl so we could come up with an example

Answer to your question: Is this doable using XSLT?
Yes
You can't simply delete this question.
You have asked a question, I have given a complete answer
please accept the answer, or give more detail as requested
Avatar of robert_jenkin
robert_jenkin

ASKER

All data to/from webpage is done by means of webservices. Aweb service is call and xml is returned. The tools be used are pure java (web service) and java script. The xml returned is basically data from a sql datas (the system is a report writer) the user chooses the columns to be included, the columns to order by, group by and to tally on.  

I am trying to find a way to take the xml and present it on the web page where by sections of the data (controled by group by columns) can be colapsed/expanded and to also show the tallys. The basic structure is a control-break report. the xml is already provided in data order based on use section.
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Was of little help was expect some type of example. but I guess its the way I asked the question
yep, you could have asked for an example.

question was "Is this something doable with xslt?"
Not directly a request for examples, I just told you how, noone stops you from given more detail.
Note that I made the offer in my first response
"If that is what you want, you need to give us some more details so we could come up with an example"
I have reviewed your recommended library and it does not address the need, helps... Like I said when I closed this, it was the way I asked the question... I need a javascript solution that can do the following ;

sample xml (note actual will include alot more columns).


 <data>
 <row>
  <reference_no>00700010000208NA</reference_no>
  <balance>1500</balance>
  </row>
   <row>
  <reference_no>00700010000208NA</reference_no>
  <balance>1500</balance>
  </row>
 <row>
  <reference_no>00700010000208NA</reference_no>
  <balance>1500</balance>
  </row>
 <row>
  <reference_no>00700010000208</reference_no>
  <balance>1500</balance>
  </row>
 <row>
  <reference_no>00700010000208</reference_no>
  <balance>1500</balance>
  </row>
 <row>
  <reference_no>00700010000208</reference_no>
  <balance>1500</balance>
  </row>
 <row>
  <reference_no>00700010000208</reference_no>
  <balance>1500</balance>
  </row>
</data>

 I currently return the xml to the webbrowser via webservice. In the browser I like to display the data in some type of table form where sections can be colapsed and expanded and all so so totals. using the sample data below I would like to see something like this

+/-   Reference                                       Balance
-     00700010000208NA                       4,500.00
      00700010000208NA                       1,500.00
      00700010000208NA                       1,500.00
      00700010000208NA                       1,500.00
+     00700010000208                           6,000.00

The columns that control the grouping and totals are not always the same.

I like to do this with xsl and javascript. I assume I would have to write the xsl on the fly based on the columns being returned in xml. it is my understanding that xsl can handle the task of totals and the generating of the table. if I am wrong please let me know and I will look for a different solution.