JCBrinegar Posted February 1, 2013 Share Posted February 1, 2013 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> DataFile.xml Link to comment Share on other sites More sharing options...
senderj Posted February 27, 2013 Share Posted February 27, 2013 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 comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now