Jump to content

2 Column Output

Recommended Posts

Looking for a little bit of help and refresher. I have a list of data that I would like to have output into 2 column sets. Right now, the data comes out like this... Column1 Column 2data1 count1data2 count2data3 count3etc..... What I am looking for is something like this... Column1 Column2 Column1 Column2data1 count1 data2 count2data3 count3 etc... I recall that this might be accomplished with using the MOD and POSITION...but I can not remember or figure it out. I have attached myXML file and below is my XSL...any help would be great. Jack <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.butternutskipatrol.com"> <xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <html> <body> <table border="0"> <tr><td colspan="2" align="center"> <h3>2012-2013 Service Day Report</h3> </td></tr> <tr><td colspan="2" align="center"> <h4>as of <xsl:value-of select="a:Data/@ServiceDayRecord"/> </h4> </td></tr> <tr bgcolor="#999999"> <th>Person</th> <th>Service Days</th> </tr> <xsl:for-each select="a:Data/a:Roster/a:Person"> <tr> <td> <xsl:value-of select="@LastName"/>, <xsl:value-of select="@FirstName"/> </td> <td align="center"> <xsl:value-of select="count(a:ServiceDay)"/> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template></xsl:stylesheet>


Link to post
Share on other sites
  • 4 weeks later...

There may be a better way, but this one seems to work. If xml is:

<mydata>  <datacount>	<data>data1</data>	<count>count1</count>  </datacount>  <datacount>	<data>data2</data>	<count>count2</count>  </datacount>  <datacount>	<data>data3</data>	<count>count3</count>  <datacount>	<data>data4</data>	<count>count4</count>  </datacount><mydata>

use this xsl:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"><html><body><table border="1"><tr>  <th>Column1</th>  <th>Column2</th>  <th>Column1</th>  <th>Column2</th></tr><xsl:for-each select="mydata/datacount"><xsl:if test="position() mod 2 = 1"><tr>  <td><xsl:value-of select="data"/></td>  <td><xsl:value-of select="count"/></td>  <td><xsl:value-of select="following::data"/></td>  <td><xsl:value-of select="following::count"/></td></tr></xsl:if></xsl:for-each></table></body></html></xsl:template></xsl:stylesheet>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...