Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 11th, 2009, 02:49 AM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Placing Pictures From Xml File In Table In Row Wise Fashion.

hi guys I have created something in xslt. but my problem is same pic is selected in different column of the row.
what i want is a row with 2 columns which has the images which are there in xml document and after the 2nd column the third image should be in second row 1st column and so on..... here is what i have created... plzzzz someone help me do this.....

-------------------------XSL---------------------------------------------


<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="assrec.xml" --><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "Â¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Untitled Document</title>
</head>

<body>
<table cellspacing="0px" cellpadding="1px" style="width:192px; border:0px; color:#999999;">
<tr>
<th align='center' colspan="2" style=" background-image:url(images/menutop.gif); background-repeat:repeat; height:30px; color: #CCCCCC; font:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold;">Employee</th>
</tr>
<xsl:for-each select="ListItems/ListItem">
<tr style="background-image: url(images/menumiddle.gif); background-repeat:repeat; width:192px; height:80px;">
<td ><img src="{image/@href}" width="75" height="70" align="right" style="border: solid; border-color:#999999; border-width:2px; "/><br /> <xsl:value-of select="name"/></td>
<td>
<img src="{image/@href}" width="75" height="70" align="right" style="border: solid; border-color:#999999; border-width:2px; "/>
<br /> <xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
<tr>
<td colspan="2" style=" background-image:url(images/menubottom.gif); color:#000000">.
</td>
</tr>
</table>
</body>
</html>

</xsl:template>
</xsl:stylesheet>




------------------------------------------------------XML------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<?xml:stylesheet type="text/xsl" href="assrec.xsl"?>
<ListItems>
<ListItem>

<image href="C:\wampserver 2\www\aafes test\my\by vickey\cdtest\images\member1.jpg">
</image>
<name>anuj</name>
</ListItem>
<ListItem>

<image href="C:\wampserver 2\www\aafes test\my\by vickey\cdtest\images\member2.jpg">
</image>
<name>bb</name>
</ListItem>
<ListItem>

<image href="C:\wampserver 2\www\aafes test\my\by vickey\cdtest\images\member3.jpg">
</image>
<name>anuj</name>
</ListItem>
<ListItem>

<image href="C:\wampserver 2\www\aafes test\my\by vickey\cdtest\images\member4.jpg">
</image>
<name>bb</name>
</ListItem>
</ListItems>






right now I am getting the out as

1 1
2 2
3 3

but I want it to b like..

1 2
3 4
5 6


or even this sound good


1 6
2 7
3 8
4 9
5 10

and so on.........
 
Old August 11th, 2009, 03:27 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Your best bet is to use something like the following:

Code:
<xsl:choose>
  <xsl:when test="position() mod 2 = 0">
    .. column 1 ..
  </xsl:when>
  <xsl:otherwise>
    .. column 2 ..
  </xsl:otherwise>
</xsl:choose>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare two excel sheets row wise vaishnaviitm Java Basics 4 July 7th, 2009 10:11 AM
Placing Table in a Header or Footer sunny227 XSLT 13 March 12th, 2008 02:41 AM
datagrid header row to appear in vertical fashion justshahid General .NET 1 February 7th, 2005 03:25 PM
Urgent. Placing table on top of drop down tanusree_ghosh CSS Cascading Style Sheets 2 January 4th, 2005 02:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.