bladestonight has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to learn how to use a XSL stylesheet after creating my XML file with XML::twig, but I think my end desire is a little too complicated for a begineer. Perhaps the XML file should be reordered. Looking at it now I think condensing the elements into attributes instead of children of the node was probably a big mistake. I would like a fresh view on the following...
I have this xml file, which I am trying to generate a table in html format.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <Volumetrics> <VolumeReport Name="v_example.gri" Version="1.0"> <CellSize CellSizeX="500.000" CellSizeY="500.000" Refinement="10"> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>147977918</CumulativeVol> </CellSize> <CellSize CellSizeX="500.000" CellSizeY="500.000" Refinement="4"> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>147751938</CumulativeVol> </CellSize> <CellSize CellSizeX="1000.000" CellSizeY="1000.000" Refinement="10 +"> <runtime units="seconds">8</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>134856090</CumulativeVol> </CellSize> <CellSize CellSizeX="1000.000" CellSizeY="1000.000" Refinement="4" +> <runtime units="seconds">9</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>134324000</CumulativeVol> </CellSize> <VolumeReport Name="south.gri" Version="1.0"> <CellSize CellSizeX="10.000" CellSizeY="10.000" Refinement="4"> <runtime units="seconds">7</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>125970002642</CumulativeVol> </CellSize> </VolumeReport> <VolumeReport Name="v_example.gri" Version="2.0"> <CellSize CellSizeX="500.000" CellSizeY="500.000" Refinement="10"> <runtime units="seconds">12</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>147977918</CumulativeVol> </CellSize> <CellSize CellSizeX="500.000" CellSizeY="500.000" Refinement="4"> <runtime units="seconds">10</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>147751938</CumulativeVol> </CellSize> <CellSize CellSizeX="1000.000" CellSizeY="1000.000" Refinement="10 +"> <runtime units="seconds">8</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>134880540</CumulativeVol> </CellSize> <CellSize CellSizeX="1000.000" CellSizeY="1000.000" Refinement="4" +> <runtime units="seconds">10</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>134324000</CumulativeVol> </CellSize> <VolumeReport Name="south.gri" Version="2.0"> <CellSize CellSizeX="10.000" CellSizeY="10.000" Refinement="4"> <runtime units="seconds">8</runtime> <VolumeUnits id="m3">Cubic Metres</VolumeUnits> <CumulativeVol>125970002642</CumulativeVol> </CellSize> </VolumeReport> </Volumetrics>
I desire my html to be a number of tables on the webpage. There should be a new table for each @Name, and new header rows for each different @Version. The rows should be the different CellSize/@CellSizeX and CellSize/@CellSizeY and the columns should be made up of CellSize/@Refinement,runtime and CumulativeVol. I desire these tables:
| v_example.gri | Grid Refinements | |||||
|---|---|---|---|---|---|---|
| Version 15.5 | 4 | 10 | ||||
| CellSize | Runtime | Volume | Runtime | Volume | ||
| (500.000,500.000) | 10 | 147751938 | 12 | 147977918 | ||
| (1000.000,1000.000) | 10 | 134856090 | 8 | 134472204 | ||
| v_example.gri | Grid Refinements | |||
|---|---|---|---|---|
| Version 16.0 | 4 | 10 | ||
| CellSize | Runtime | Volume | Runtime | Volume |
| (500.000,500.000) | 10 | 147751938 | 12 | 147977918 |
| (1000.000,1000.000) | 10 | 134324000 | 8 | 134880540 |
| south.gri | Grid Refinements | |||
|---|---|---|---|---|
| Version 15.5 | 4 | 10 | ||
| CellSize | Runtime | Volume | Runtime | Volume |
| (10.000,10.000) | 6 | 125970002642 | ||
| south.gri | Grid Refinements | |||
|---|---|---|---|---|
| Version 16.0 | 4 | 10 | ||
| CellSize | Runtime | Volume | Runtime | Volume |
| (10.000,10.000) | 8 | 125970002642 | ||
My XSL stylesheet is a slightly modified example off the internet, it doesn't even get close to producing the above so I don't think it would be very useful to post it here.
Firstly, should I reorder my XML?
Secondly, is there a kind soul out there who could show me what my stylesheet should look like?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML to XHTML table
by Herkum (Parson) on Apr 26, 2007 at 19:38 UTC | |
by bladestonight (Novice) on Apr 27, 2007 at 00:38 UTC |