[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: grouping by attribute

Subject: Re: grouping by attribute
From: Manu KY <manu_kry@xxxxxxxxx>
Date: Wed, 10 Oct 2001 12:08:16 +0530
com.xpegs.v2000q3.hotelml
Hi Kiran,
try this:

<xsl:template match="Property" xmlns:def="com/xpegs/v2000Q3/HotelML">
        <table>
                <xsl:for-each select="def:Amenity">
                        <tr><td><xsl:value-of select="@Code"/></td>
                              <td><xsl:value-of select="@Description"/></td>
                        </tr>
                </xsl:for-each>
        </table>
</xsl:template>

Manu


HI,

My XML code has a following pattern:

<?xml version="1.0"?>

<Property xmlns="com/xpegs/v2000Q3/HotelML" Name="Pride Hotel"
Code="UI;29966" Token="979242313749">

<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="ROOM24" Description="24
Hour Room Service"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="HAIR"
Description="Hairdryer in Room"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="TEL"
Description="Telephone"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="LOUNGE"
Description="Lounge"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="TVCAB"
Description="Television with Cable"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="TMPCTL"
Description="Temperature Control"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="HEALTH"
Description="Health Club"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="REST"
Description="Restaurant"/>
<Amenity xmlns="com/xpegs/v2000Q3/HotelML" Code="BELL"
Description="Porters"/>


</Property>


My XSL output is expected to be: <table> <tr> <td>24 Hour Room Service</td> <td>Hairdryer in Room</td> <td>Telephone</td> </tr>

<tr>
<td>Lounge</td>
<td>Television with Cable</td>
<td>Temperature Control</td>
</tr>

<tr>
<td>Health Club</td>
<td>Restaurant</td>
<td>Porters</td>
</tr>
<table>

I have tried the following options as given in your XSL FAQ section
(http://www.dpawson.co.uk/xsl/sect2/N4486.html#d137e42)
but none of them works......:(:(:(:(

<xsl:template match="/">
        <html>



1.              <table width="373" cellspacing="0" cellpadding="0" border="1"
bordercolor="#BCBCBC">

<xsl:for-each select="Property">

<tr>

<td>

<xsl:for-each
select="{Amenity@Description}[count(preceding-sibling::Amenity[1] |
current()) = 1]">

<xsl:value-of select="Amenity@Description"/>,

</xsl:for-each>

</td>

</tr>

</xsl:for-each>

</table>




2. <table width="373" cellspacing="0" cellpadding="0" border="1" bordercolor="#BCBCBC">

<xsl:for-each select="Property/Amenity">

<xsl:template match="{@Description}[position() mod 3 = 1]"
priority="2">

<tr>

<td><xsl:value-of select="." mode="1"/></td>

<td><xsl:value-of
select="following-sibling::{@Description}[1]"/></td>

<td><xsl:value-of
select="following-sibling::{@Description}[2]"/></td>

</tr>

</xsl:template>

</xsl:for-each>

</table>




3. <table width="373" cellspacing="0" cellpadding="0" border="1" bordercolor="#BCBCBC">

<xsl:for-each select="Property">

<xsl:call-template name="triples">

<xsl:with-param name="nodes" select="Amenity"/>

</xsl:call-template>

</xsl:for-each>


<xsl:param name="max" select="number(3)"/>


</table>




4. <table width="373" cellspacing="0" cellpadding="0" border="1" bordercolor="#BCBCBC">

<xsl:template match="Property">

<tr>

<xsl:for-each select="Amenity">

<td><xsl:apply-templates/></td>

<xsl:if test="position() mod $max = 0 and
position()!=last()">

<xsl:text
disable-output-escaping="yes"><![CDATA[</tr><tr>]]></xsl:text>

</xsl:if>

</xsl:for-each>

</tr>

</xsl:template>

</table>




5. <table width="373" cellspacing="0" cellpadding="0" border="1" bordercolor="#BCBCBC">

<xsl:template match="Property">

<xsl:for-each select="Amenity[position() mod $max = 1]" >

<tr>

<xsl:for-each select="self::Amenity |
following-sibling::Amenity[position() = $max]">

<td><xsl:apply-templates/></td>

</xsl:for-each>

</tr>

</xsl:for-each>

</xsl:template>
                                        </table>


</html> </xsl:template>




Please guide me regarding this.....!!


Also I want to know, what difference does it make to use either of the
following statements, on the execution of the rest of the code in XSL.
I could see the solution for grouping 3 items (as I want it) in FAQ section,
but that code does not work when I use the 1st sentence from the following
statements. Plzz
guide me regarding this too.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">

or

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


Thanx and Regards Ms. Kiran Bhide Seacom Solutions (India) Ltd. kiran@xxxxxxxxxxxxxxx kiranab@xxxxxxxxxxx


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.