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

RE: Need Help with XSL Multicolumn Table

Subject: RE: Need Help with XSL Multicolumn Table
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Thu, 14 Oct 2004 13:22:35 -0500
dwlayouttable
Hi Alex,

Try this stylesheet, it should get you on your way:

********************************************
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="currentRecord" />
<xsl:param name="pageSize" />

<xsl:variable name="maxRecords" select="count(items)" />

<xsl:template match="/">
	<xsl:apply-templates select="items/item">
	</xsl:apply-templates>
</xsl:template>

<xsl:template match="item">
<table width="115" border="1" cellpadding="0" cellspacing="0">
   <!--DWLayoutTable-->
   <tr>

   <xsl:choose>
    <xsl:when test="position() mod 2 = 1">
     <xsl:attribute name="class">clsOdd</xsl:attribute>
    </xsl:when>
    <xsl:otherwise>
     <xsl:attribute name="class">clsEven</xsl:attribute>
    </xsl:otherwise>
   </xsl:choose>

    <td width="115" height="99" valign="top"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
       <td width="12" height="90"></td>
       <td width="90" valign="top">
       	<a href="{link}" target="_blank"><img align="middle" alt="{title}"
style="border: 1px solid #666666" border="0" width="90" height="90"
src="{image_url}"/></a>
       </td>
       <td width="13"></td>
      </tr>
      <tr>
       <td height="9"></td>
       <td></td>
       <td></td>
      </tr>
     </table>
    </td>
   </tr>
   <tr>
    <td height="82" valign="top"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
       <td width="115" height="63" valign="top">
        <xsl:value-of select="title"/>
        <a href="{link}" target="_blank"><br>mas informacisn<img
align="middle" src="tree/lens.gif" border="0"/></br></a>
       </td>
      </tr>
      <tr>
        <xsl:if test="mpago = 'Y'">
         <td height="13" valign="top"><img alt="Pagalo en mensualidades..."
align="middle" style="border: 1px solid #666666" border="0"
src="images/amexvisamc.gif"/></td>
        </xsl:if>
        <xsl:if test="mpago = 'N'">
         <td height="13" valign="top"><img align="middle" border="0"
src="images/nomark.gif"/></td>
        </xsl:if>
      </tr>
    </table></td>
   </tr>
   <tr>
     <td height="19" valign="bottom" bgcolor="#FFFF00" class="precio">
      <font style="color:#FF0000; font-weight:100"><b>
      <xsl:value-of select="currency"/><xsl:value-of select="price"/>
      </b></font>
     </td>
   </tr>
</table>
</xsl:template>

</xsl:stylesheet>
********************************************

Cheers,
<prs/>

-----Original Message-----
From: soporte@xxxxxxxxxxxx [mailto:soporte@xxxxxxxxxxxx]
Sent: Thursday, October 14, 2004 10:43 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Need Help with XSL Multicolumn Table

Hello,

I have an XML with data like the following and I need to display this info
in a multicolumn table. Suppose I have 20 items, I want to display in each
row 4 items with the respective title, price, currency, etc.

Hope anyone can help me with this.. I will appreciate so much the help.

<items>
<item id="2545">
<title>Something a</title>
<price>1,500</price>
<image_url>pic1.jpg</image_url>
<currency>$</currency>
<mpago>N</mpago>
<listing_features>
<highlight>Y</highlight>
</listing_features>

</item>

<item id="2546">
<title>Something b</title>
<price>1,583</price>
<image_url>pic2.jpg</image_url>
<currency>US$</currency>
<mpago>Y</mpago>
<listing_features>
<highlight>Y</highlight>
</listing_features>

</item>
<item id="2580">
<title>Something c</title>
<price>700</price>
<image_url>pic3.jpg</image_url>
<currency>$</currency>
<mpago>N</mpago>
<listing_features>
<highlight>N</highlight>
</listing_features>

</item>
......
</items>



I want to show 4 tables like this one in each row.
Im also pasting here the code of the table in html:

Here is the html code of the table I would like each item to have.

***************************

<table width="115" border="0" cellpadding="0" cellspacing="0">
   <!--DWLayoutTable-->
   <tr>
    <td width="115" height="99" valign="top"><table width="100%"
border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
       <td width="12" height="90"></td>
       <td width="90" valign="top">** Here the image **</td>
       <td width="13"></td>
      </tr>
      <tr>
       <td height="9"></td>
       <td></td>
       <td></td>
      </tr>
     </table>
    </td>
   </tr>
   <tr>
    <td height="82" valign="top"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
       <td width="115" height="63" valign="top">
        ** here the title ** </td>
      </tr>
      <tr>
        <td height="13" valign="top">** here mpago **</td>
      </tr>
    </table></td>
   </tr>
   <tr>
     <td height="19" valign="bottom" bgcolor="#FFFF00" class="precio">
      ** here price ** <font style="color:#FF0000;
font-weight:100"><b></b></font></td>
   </tr>
</table>

***************************************

And here is the current XSL that displays the info each item in a row, but I
dont want that way I need in the format of the table above.


<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:param name="currentRecord" />
	<xsl:param name="pageSize" />

	<xsl:variable name="maxRecords" select="count(items)" />

	<xsl:template match="/response/listing/items/item">

 <table border="0" class="row" width="550" cellspacing="0" cellpadding="1"
bordercolor="gainsboro">
        <tr class="row">

         <xsl:choose>
        <xsl:when test="position() mod 2 = 1">
							<xsl:attribute
name="class">clsOdd</xsl:attribute>
						</xsl:when>
						<xsl:otherwise>
							<xsl:attribute
name="class">clsEven</xsl:attribute>
						</xsl:otherwise>
					</xsl:choose>

				 <td class="image" width="17%"><a
href="{link}" target="_blank"><img align="middle" alt="{title}"
style="border: 1px solid #666666"
border="0" width="90" height="90" src="{image_url}"/></a></td>
				  <td class="value"
width="45%"><xsl:value-of select="title"/><a href="{link}"
target="_blank"><br>mas informacisn<img align="middle"
src="tree/lens.gif" border="0"/></br></a></td>
                <td class="precio" width="16%"><xsl:value-of
select="currency"/><xsl:value-of select="price"/></td>

      <xsl:if test="mpago = 'Y'">
        <td class="image" width="14%"><img alt="Pagalo en mensualidades..."
align="middle" style="border: 1px solid #666666"
border="0" src="images/amexvisamc.gif"/></td>
      </xsl:if>
      <xsl:if test="mpago = 'N'">
<td class="image" width="14%"><img align="middle" border="0"
src="images/nomark.gif"/></td>
      </xsl:if>
                <td class="value" width="5%"> <xsl:for-each
select="listing_features">
      <xsl:if test="highlight = 'Y'">
      <xsl:attribute name='style'>
                        <xsl:text>color:red</xsl:text>
                        </xsl:attribute> <xsl:value-of select="photo"/>
      </xsl:if>
      </xsl:for-each>
      </td>
       </tr>
   <tr><td class="row"></td></tr>
		</table>
	</xsl:template>
</xsl:stylesheet>


I appreciate so much your help and hope you can help me.

Best Regards and thanks a lot,

Alex. V.

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.