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 July 11th, 2003, 06:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default help with XPath

Below is a snippet of XSL that I'm working on. I am getting a list of files from an SQL database, and I'd like to display them in a table 4 columns wide. Trouble is, I can't predict how many items I will get, so I'm trying to use the position() function to insert a new row tag after every 4 files.


<TABLE Class="Files">
<xsl:variable name="columns" select="4"/>
<xsl:if test="position() mod $columns = 0">
<xsl:for-each select="TABLE/COLUMN">
 <xsl:value-of select="position() mod $columns"/>
  <TR>
    CODE TO START NEW ROW AND DISPLAY FILE
  </TR>
</xsl:if>
<xsl:if test="position() mod $columns > 0">
    CODE TO DISPLAY FILE WITHOUT NEW ROW
</xsl:if>
</TABLE>

I have added a line to display the value of "position() mod $columns = 0" within the for-each, so I can see that I am getting correct values (1, 2, 3, 0, 1, 2, 3, 0). The problem is, even when the calculation =zero, the xsl:if (bold above) NEVER evaluates to true. Is this a bug with MSXML3?

Any help is appreciated.

Ken
 
Old July 12th, 2003, 03:25 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

But where you test position is not the same as where you display it, after the for-each loop.

--

Joe
 
Old July 15th, 2003, 01:14 PM
Authorized User
 
Join Date: Jun 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Joe,

Guess I was a little blind to that.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XPATH pallone XSLT 4 March 3rd, 2008 10:58 AM
Xpath help please rishid XML 1 February 28th, 2007 03:23 AM
XPath help migake XSLT 2 April 21st, 2006 10:49 AM
Xpath Ma7T XSLT 2 August 16th, 2005 07:54 AM
XPath rupen XML 2 April 19th, 2005 09:43 AM





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