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 June 3rd, 2014, 05:17 AM
Registered User
Join Date: Jun 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Post XSLT Position Function

Hi all,

Please can someone help me with this problem.

I am trying to use the position() function to filter the records of a given record set. I basically want to split the records into groups of 14,990

It appears to always return the first 14990 no matter what values are in the xslt.

Here's my xslt:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" />
<xsl:template match="DATA">
<xsl:for-each select="ROW">
<xsl:if test="(position() &gt; 14990 and position() &lt; 29980) and SiteID = '00020' ">
<xsl:value-of select="VehicleID" />
<xsl:value-of select="Manufacturer" />
<xsl:value-of select="Range" />
<xsl:value-of select="CAP_ID" />
<xsl:value-of select="Description" />
<xsl:value-of select="DeepLink" />
<xsl:value-of select="FinanceType" />
<xsl:value-of select="DepositType" />
<xsl:value-of select="DepositValue" />
<xsl:value-of select="Term" />
<xsl:value-of select="MonthlyPayment" />
<xsl:value-of select="AnnualMileage" />
<xsl:value-of select="MaintenanceType" />
<xsl:value-of select="MaintenanceValue" />
<xsl:value-of select="InStock" />
<xsl:value-of select="DocumentFee" />
<xsl:value-of select="AutoRenew" />
<CO2 />
Old June 3rd, 2014, 06:21 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

Can't see anything obviously wrong. Please try to reduce it to a simpler example (fewer rows, less data in each row) that illustrates the problem, and then post complete XML and XSLT code so we can run it ourselves.
Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Old June 3rd, 2014, 07:21 AM
samjudson's Avatar
Friend of Wrox
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

Are there any records with a SiteID of '00020' in that range of records?

Try perhaps adding that clause separately to the xsl:for-each (you could actually add both to this instruction):

<xsl:for-each select="ROW[SiteID='00020'][position() &gt; 14990 and position() &lt; 29980]">
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code To Use the Position Function ritagr XSLT 7 April 14th, 2010 01:30 PM
Using the position() function... vb89 XSLT 9 October 15th, 2009 05:47 PM
GETTING COUNT AND POSITION using XSLT udaybob XSLT 16 August 19th, 2009 01:34 PM
contains function in XSLT 1.0 NEO1976 XSLT 4 February 7th, 2007 06:01 AM
Passing nodeset into position() function EstherMStrom XSLT 1 May 18th, 2005 04:04 PM

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