xsl-list
[Top] [All Lists]

[xsl] Grouping Problem

2006-11-07 05:24:29
Hi there,

This is my XML File:
<?xml version="1.0" encoding="UTF-8"?>
<acclist>
   <acc>
       <code>3709</code>
       <name>Hotel 3709</name>
       <location>
           <destination>
               <code>Dest1</code>
               <name>dest 1</name>
           </destination>
           <zone>
               <code>zone1</code>
               <name>zone 1</name>
           </zone>
       </location>
       <category>
           <code>4sta</code>
           <name>4 STARS</name>
       </category>
       <room>
           <code>TPL.SU</code>
           <name>TRIPLE SUPERIOR</name>
           <occupancy>
               <adults>3</adults>
               <children>0</children>
               <rooms>1</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>99.96</price>
           </cost>
       </room>
       <room>
           <code>DBL.SU</code>
           <name>DOUBLE/ TWIN SUPERIOR</name>
           <occupancy>
               <adults>2</adults>
               <children>0</children>
               <rooms>1</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>65.00</price>
           </cost>
       </room>
       <room>
           <code>TPL.ST</code>
           <name>TRIPLE STANDARD</name>
           <occupancy>
               <adults>3</adults>
               <children>0</children>
               <rooms>1</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>128.98</price>
           </cost>
       </room>
       <room>
           <code>DBL.ST</code>
           <name>DOUBLE/ TWIN STANDARD</name>
           <occupancy>
               <adults>2</adults>
               <children>0</children>
               <rooms>1</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>99.96</price>
           </cost>
       </room>
       <room>
           <code>DBL.SU</code>
           <name>DOUBLE/ TWIN SUPERIOR</name>
           <occupancy>
               <adults>1</adults>
               <children>0</children>
               <rooms>2</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>70.94</price>
           </cost>
       </room>
       <room>
           <code>DBL.ST</code>
           <name>DOUBLE/ TWIN STANDARD</name>
           <occupancy>
               <adults>1</adults>
               <children>0</children>
               <rooms>2</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>99.96</price>
           </cost>
       </room>
   </acc>
   <acc>
       <code>725</code>
       <name>Hotel 725</name>
       <location>
           <destination>
               <code>dest1</code>
               <name>dest 1</name>
           </destination>
           <zone>
               <code>zone3</code>
               <name>zone 3</name>
           </zone>
       </location>
       <category>
           <code>3sta</code>
           <name>3 STARS</name>
       </category>
       <room>
           <code>TPL.SU</code>
           <name>TRIPLE SUPERIOR</name>
           <occupancy>
               <adults>3</adults>
               <children>0</children>
               <rooms>1</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>97.81</price>
           </cost>
       </room>
       <room>
           <code>DBL.SU</code>
           <name>DOUBLE/ TWIN SUPERIOR</name>
           <occupancy>
               <adults>2</adults>
               <children>0</children>
               <rooms>1</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>65.56</price>
           </cost>
       </room>
       <room>
           <code>SGL.SU</code>
           <name>SINGLE SUPERIOR</name>
           <occupancy>
               <adults>1</adults>
               <children>0</children>
               <rooms>2</rooms>
           </occupancy>
           <cost>
               <board>
                   <code>HD</code>
                   <name>BED AND BREAKFAST</name>
               </board>
               <currency>USD</currency>
               <price>56.96</price>
           </cost>
       </room>
   </acc>
</acclist>


This is XSL File:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
   <xsl:output method="html" omit-xml-declaration="yes"/>
   <xsl:template match="text()">
       <xsl:value-of select="." />
   </xsl:template>
   <xsl:template match="acclist/acc">
           <xsl:variable name="HotelCode" select="code"/>
           <br/>
           <table width="100%" border="0" class="TableBorders">
                <xsl:for-each select="room">
                   <xsl:sort order="ascending" data-type="text"
select="cost/board/code"/>
                   <xsl:sort order="descending" data-type="text"
select="substring-after(code,'.')"/>
                   <xsl:sort order="ascending" data-type="number"
select="occupancy/adults"/>
                   <xsl:sort order="ascending" data-type="number"
select="occupancy/children"/>
                   <xsl:sort order="ascending" data-type="number"
select="occupancy/rooms"/>

                   <xsl:variable name="rtype" select="code"/>
                   <tr class="TableData">
                       <td colspan="2"><xsl:value-of select="name"/></td>
                       <td width="31%"></td>
                       <td width="13%"></td>
                   </tr>
                       <xsl:for-each select="cost">
                           <xsl:variable name="amt" select="price" />
                           <xsl:variable name="famt"
select="format-number($amt, '###,###,###.##')"/>
                           <xsl:variable name="curr" >
                               <xsl:choose>
                                   <xsl:when
test="currency='EUR'"><xsl:text>€</xsl:text></xsl:when>
                                   <xsl:when
test="currency='USD'"><xsl:text>$</xsl:text></xsl:when>
                                   <xsl:when
test="currency='GBP'"><xsl:text>£</xsl:text></xsl:when>
                                   <xsl:when
test="currency='YEN'"><xsl:text>¥</xsl:text></xsl:when>
                                   <xsl:otherwise><xsl:value-of
select="currency"/></xsl:otherwise>
                               </xsl:choose>
                           </xsl:variable>
                           <tr class="TableData">
                               <td width="48%"></td>
                               <td width="8%"><xsl:value-of
select="board/code"/></td>
                               <td><xsl:value-of
select="$curr"/><xsl:text> </xsl:text><xsl:value-of
select="$famt"/></td>
                               <td></td>
                           </tr>
                       </xsl:for-each>
               </xsl:for-each>
           </table>
   </xsl:template>
</xsl:stylesheet>

The file is currently displaying like:

<br><table width="100%" border="0" class="TableBorders">
<tr class="TableData">
<td colspan="2">DOUBLE/ TWIN SUPERIOR</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 70.94</td>
<td></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">RO</td>
<td>$ 79.96</td>
<td></td>
</tr>
<tr class="TableData">
<td colspan="2">DOUBLE/ TWIN SUPERIOR</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 65</td>
<td></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">RO</td>
<td>$ 62</td>
<td></td>
</tr>
<tr class="TableData">
<td colspan="2">TRIPLE SUPERIOR</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 99.96</td>
<td></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">RO</td>
<td>$ 99.96</td>
<td></td>
</tr>
<tr class="TableData">
<td colspan="2">DOUBLE/ TWIN STANDARD</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 99.96</td>
<td></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">RO</td>
<td>$ 99.96</td>
<td></td>
</tr>
<tr class="TableData">
<td colspan="2">DOUBLE/ TWIN STANDARD</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 99.96</td>
<td></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">RO</td>
<td>$ 79.96</td>
<td></td>
</tr>
<tr class="TableData">
<td colspan="2">TRIPLE STANDARD</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 128.98</td>
<td></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">RO</td>
<td>$ 102</td>
<td></td>
</tr>
</table>
   <br><table width="100%" border="0" class="TableBorders">
<tr class="TableData">
<td colspan="2">SINGLE SUPERIOR</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 56.96</td>
<td></td>
</tr>
<tr class="TableData">
<td colspan="2">DOUBLE/ TWIN SUPERIOR</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 65.56</td>
<td></td>
</tr>
<tr class="TableData">
<td colspan="2">TRIPLE SUPERIOR</td>
<td width="31%"></td>
<td width="13%"></td>
</tr>
<tr class="TableData">
<td width="48%"></td>
<td width="8%">HD</td>
<td>$ 97.81</td>
<td></td>
</tr>
</table>

I had made the XSL to display each room type(i.e. room/code)
separately & separate it in an ascending order of board
type(i.e.board/code) and later Adults, Children & rooms. As shown
above in the HTML Code above. But i cant separate the Board type(i.e.
Board/code)

I Now want the data to display like:

<table width="100%" border="0" class="TableBorders">
 <tr class="TableData">
   <td colspan="4"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0"
CELLPADDING="0">
       <TR>
         <TD WIDTH="14%">&nbsp;</TD>
         <TD WIDTH="34%">DOUBLE/ TWIN SUPERIOR</TD>
         <TD WIDTH="19%" ALIGN="RIGHT">$ 70.94</TD>
         <TD WIDTH="33%">&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>DOUBLE/ TWIN SUPERIOR</TD>
         <TD ALIGN="RIGHT">$ 65.00</TD>
         <TD>&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>TRIPLE SUPERIOR</TD>
         <TD ALIGN="RIGHT">$ 99.96</TD>
         <TD>&nbsp;</TD>
       </TR>
     </TABLE></td>
 </tr>
   <tr class="TableData">
     <td width="30%"></td>
     <td width="37%">HD</td>
     <td WIDTH="18%">$ 235.90</td>
     <td WIDTH="15%">&nbsp;</td>
   </tr>
 <tr class="TableData">
   <td colspan="4"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0"
CELLPADDING="0">
       <TR>
         <TD WIDTH="14%">&nbsp;</TD>
         <TD WIDTH="34%">SINGLE STANDARD</TD>
         <TD WIDTH="19%" ALIGN="RIGHT">$ 99.96</TD>
         <TD WIDTH="33%">&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>DOUBLE/ TWIN STANDARD</TD>
         <TD ALIGN="RIGHT">$ 99.96</TD>
         <TD>&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>TRIPLE STANDARD</TD>
         <TD ALIGN="RIGHT">$128.98</TD>
         <TD>&nbsp;</TD>
       </TR>
     </TABLE></td>
 </tr>
   <tr class="TableData">
     <td width="30%"></td>

   <td width="37%">HD</td>
   <td>$ 328.90</td>
     <td>&nbsp;</td>
   </tr>
        <tr class="TableData">
   <td colspan="4"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0"
CELLPADDING="0">
       <TR>
         <TD WIDTH="14%">&nbsp;</TD>
         <TD WIDTH="34%">DOUBLE/ TWIN SUPERIOR</TD>
         <TD WIDTH="19%" ALIGN="RIGHT">$ 79.96</TD>
         <TD WIDTH="33%">&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>DOUBLE/ TWIN SUPERIOR</TD>
         <TD ALIGN="RIGHT">$ 62.00</TD>
         <TD>&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>TRIPLE SUPERIOR</TD>
         <TD ALIGN="RIGHT">$ 99.96</TD>
         <TD>&nbsp;</TD>
       </TR>
     </TABLE></td>
 </tr>
   <tr class="TableData">
     <td width="30%"></td>

   <td width="37%">RO</td>

   <td WIDTH="18%">$ 241.92</td>
     <td WIDTH="15%">&nbsp;</td>
   </tr>
 <tr class="TableData">
   <td colspan="4"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0"
CELLPADDING="0">
       <TR>
         <TD WIDTH="14%">&nbsp;</TD>
         <TD WIDTH="34%">SINGLE sTANDARD</TD>
         <TD WIDTH="19%" ALIGN="RIGHT">$ 79.96</TD>
         <TD WIDTH="33%">&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>DOUBLE/ TWIN STANDARD</TD>
         <TD ALIGN="RIGHT">$ 62.00</TD>
         <TD>&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>TRIPLE STANDARD</TD>
         <TD ALIGN="RIGHT">$ 99.96</TD>
         <TD>&nbsp;</TD>
       </TR>
     </TABLE></td>
 </tr>
   <tr class="TableData">
     <td width="30%"></td>
     <td width="37%">RO</td>
     <td>$ 241.92</td>
     <td>&nbsp;</td>
   </tr>
</table>
<BR><table width="100%" border="0" class="TableBorders">
 <tr class="TableData">
   <td colspan="4"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0"
CELLPADDING="0">
       <TR>
         <TD WIDTH="14%">&nbsp;</TD>
         <TD WIDTH="34%">DOUBLE/ TWIN SUPERIOR</TD>
         <TD WIDTH="19%" ALIGN="RIGHT">$ 56.96</TD>
         <TD WIDTH="33%">&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>DOUBLE/ TWIN SUPERIOR</TD>
         <TD ALIGN="RIGHT">$ 65.56</TD>
         <TD>&nbsp;</TD>
       </TR>
       <TR>
         <TD>&nbsp;</TD>
         <TD>TRIPLE SUPERIOR</TD>
         <TD ALIGN="RIGHT">$ 97.81</TD>
         <TD>&nbsp;</TD>
       </TR>
     </TABLE></td>
 </tr>
   <tr class="TableData">
     <td width="30%"></td>
     <td width="37%">HD</td>

   <td WIDTH="18%">$ 220.33</td>
     <td WIDTH="15%">&nbsp;</td>
   </tr>
</table>

i want that the superior rooms should be in one group and the standard
in one group.and i also want to group all the room types belonging to
a particular boardtype in one boardtype group.

i know wat i want but i cant get it. Please help me!!

Regards,

Alistair Rodrigues.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Grouping Problem, Alistair Rodrigues <=