Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using xsl to put xml data into a table

    Hi guys,

    I'm pretty new to XML and XSL, so I'm trying to get a grasp on how to use XSL to put data from an XML document into a table.

    This is the data:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE internetUsage SYSTEM "HomeInternetUsage2011Census.dtd">
    <internetUsage src="Australian Bureau of Statistics 81460DO004_201011 Household Use of Information Technology, Australia, 2010-11">
       <descriptions group="title">
          <usage type='1'>Persons who accessed the internet at home</usage>
          <usage type='2'>Accessing government services</usage>
          <usage type='3'>Buying or selling goods or services</usage>
          <usage type='4'>Creating online content</usage>
          <usage type='5'>Downloading video or music</usage>
          <usage type='6'>Educational purposes</usage>
          <usage type='7'>Emailing</usage>
          <usage type='8'>Listening to music or watching videos/movies online</usage>
          <usage type='9'>Paying bills online or online banking</usage>
          <usage type='10'>Research or news and general browsing</usage>
          <usage type='11'>Social networking and online gaming</usage>
          <usage type='12'>Voice or video calls over the internet</usage>
       </descriptions>
       <descriptions group="units">
          <usage type='1'>1000s</usage>
          <usage type='2'>%</usage>
          <usage type='3'>%</usage>
          <usage type='4'>%</usage>
          <usage type='5'>%</usage>
          <usage type='6'>%</usage>
          <usage type='7'>%</usage>
          <usage type='8'>%</usage>
          <usage type='9'>%</usage>
          <usage type='10'>%</usage>
          <usage type='11'>%</usage>
          <usage type='12'>%</usage>
       </descriptions>
       <ageGroup group="15-17">
          <usage type='1'>778</usage>
          <usage type='2'>23</usage>
          <usage type='3'>24</usage>
          <usage type='4'>54</usage>
          <usage type='5'>65</usage>
          <usage type='6'>78</usage>
          <usage type='7'>79</usage>
          <usage type='8'>83</usage>
          <usage type='9'>15</usage>
          <usage type='10'>85</usage>
          <usage type='11'>88</usage>
          <usage type='12'>22</usage>
       </ageGroup>
       <ageGroup group="18-24">
          <usage type='1'>1910</usage>
          <usage type='2'>44</usage>
          <usage type='3'>46</usage>
          <usage type='4'>57</usage>
          <usage type='5'>60</usage>
          <usage type='6'>61</usage>
          <usage type='7'>93</usage>
          <usage type='8'>81</usage>
          <usage type='9'>66</usage>
          <usage type='10'>89</usage>
          <usage type='11'>86</usage>
          <usage type='12'>27</usage>
       </ageGroup>
       <ageGroup group="25-34">
          <usage type='1'>2820</usage>
          <usage type='2'>53</usage>
          <usage type='3'>55</usage>
          <usage type='4'>50</usage>
          <usage type='5'>50</usage>
          <usage type='6'>50</usage>
          <usage type='7'>93</usage>
          <usage type='8'>68</usage>
          <usage type='9'>78</usage>
          <usage type='10'>87</usage>
          <usage type='11'>75</usage>
          <usage type='12'>33</usage>
       </ageGroup>
       <ageGroup group="35-44">
          <usage type='1'>2691</usage>
          <usage type='2'>53</usage>
          <usage type='3'>51</usage>
          <usage type='4'>38</usage>
          <usage type='5'>36</usage>
          <usage type='6'>51</usage>
          <usage type='7'>91</usage>
          <usage type='8'>51</usage>
          <usage type='9'>71</usage>
          <usage type='10'>89</usage>
          <usage type='11'>53</usage>
          <usage type='12'>29</usage>
       </ageGroup>
       <ageGroup group="45-54">
          <usage type='1'>2411</usage>
          <usage type='2'>48</usage>
          <usage type='3'>44</usage>
          <usage type='4'>31</usage>
          <usage type='5'>23</usage>
          <usage type='6'>44</usage>
          <usage type='7'>90</usage>
          <usage type='8'>39</usage>
          <usage type='9'>64</usage>
          <usage type='10'>88</usage>
          <usage type='11'>37</usage>
          <usage type='12'>26</usage>
       </ageGroup>
       <ageGroup group="55-64">
          <usage type='1'>1717</usage>
          <usage type='2'>46</usage>
          <usage type='3'>38</usage>
          <usage type='4'>28</usage>
          <usage type='5'>16</usage>
          <usage type='6'>37</usage>
          <usage type='7'>89</usage>
          <usage type='8'>27</usage>
          <usage type='9'>60</usage>
          <usage type='10'>86</usage>
          <usage type='11'>28</usage>
          <usage type='12'>25</usage>
       </ageGroup>
       <ageGroup group="65-">
          <usage type='1'>1029</usage>
          <usage type='2'>35</usage>
          <usage type='3'>26</usage>
          <usage type='4'>23</usage>
          <usage type='5'>9</usage>
          <usage type='6'>24</usage>
          <usage type='7'>91</usage>
          <usage type='8'>19</usage>
          <usage type='9'>43</usage>
          <usage type='10'>81</usage>
          <usage type='11'>17</usage>
          <usage type='12'>25</usage>
       </ageGroup>
       <gender group="male">
          <usage type='1'>6663</usage>
          <usage type='2'>47</usage>
          <usage type='3'>47</usage>
          <usage type='4'>37</usage>
          <usage type='5'>40</usage>
          <usage type='6'>47</usage>
          <usage type='7'>89</usage>
          <usage type='8'>56</usage>
          <usage type='9'>63</usage>
          <usage type='10'>88</usage>
          <usage type='11'>51</usage>
          <usage type='12'>29</usage>
       </gender>
       <gender group="female">
          <usage type='1'>6693</usage>
          <usage type='2'>47</usage>
          <usage type='3'>43</usage>
          <usage type='4'>44</usage>
          <usage type='5'>34</usage>
          <usage type='6'>51</usage>
          <usage type='7'>93</usage>
          <usage type='8'>50</usage>
          <usage type='9'>65</usage>
          <usage type='10'>87</usage>
          <usage type='11'>59</usage>
          <usage type='12'>27</usage>
       </gender>
       <employment group="employed">
          <usage type='1'>9825</usage>
          <usage type='2'>50</usage>
          <usage type='3'>49</usage>
          <usage type='4'>42</usage>
          <usage type='5'>39</usage>
          <usage type='6'>50</usage>
          <usage type='7'>91</usage>
          <usage type='8'>55</usage>
          <usage type='9'>70</usage>
          <usage type='10'>88</usage>
          <usage type='11'>57</usage>
          <usage type='12'>29</usage>
       </employment>
       <employment group="unemployed">
          <usage type='1'>3531</usage>
          <usage type='2'>39</usage>
          <usage type='3'>33</usage>
          <usage type='4'>37</usage>
          <usage type='5'>31</usage>
          <usage type='6'>44</usage>
          <usage type='7'>90</usage>
          <usage type='8'>48</usage>
          <usage type='9'>46</usage>
          <usage type='10'>85</usage>
          <usage type='11'>51</usage>
          <usage type='12'>26</usage>
       </employment>
       <location group="urban">
          <usage type='1'>11969</usage>
          <usage type='2'>47</usage>
          <usage type='3'>45</usage>
          <usage type='4'>41</usage>
          <usage type='5'>38</usage>
          <usage type='6'>49</usage>
          <usage type='7'>91</usage>
          <usage type='8'>54</usage>
          <usage type='9'>64</usage>
          <usage type='10'>87</usage>
          <usage type='11'>56</usage>
          <usage type='12'>29</usage>
       </location>
       <location group="rural">
          <usage type='1'>1387</usage>
          <usage type='2'>47</usage>
          <usage type='3'>43</usage>
          <usage type='4'>36</usage>
          <usage type='5'>27</usage>
          <usage type='6'>45</usage>
          <usage type='7'>88</usage>
          <usage type='8'>40</usage>
          <usage type='9'>59</usage>
          <usage type='10'>86</usage>
          <usage type='11'>46</usage>
          <usage type='12'>21</usage>
       </location>
    </internetUsage>
    if anyone can help me at with a template or an example using my variables so i can understand the structure further on down the line would be greatly appreciated.

    thanks

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Random thought: it looks like you already have the table. You might not need XSL when CSS can do the job for you. That is, if you care only about presentation of the data.

    If you're thinking of transforming it into a HTML table, then yeah, you might want to skip that... because the HTML table would be presentation only.

    I did some exploring along these lines over ten years ago. It wasn't that hard, really, but I forget exactly what it was I did.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the quick reply Alex,

    For the moment I want to stick to using XSL so I can understand it further.

    Other things I want to do further on down the track is highlight the lower percentages in red, and create ordered lists, but i need the table first. I may CSS just to colour the back fill of the table for the presentation.

    But i'm trying to stick to XSL for now. But yes I do want to transform the data into a HTML table. A couple of people have recommended using a for-each statement, but i'm unsure where to start for now.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •