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">
<STOCK>
<xsl:for-each select="ROW">
<xsl:if test="(position() &gt; 14990 and position() &lt; 29980) and SiteID = '00020' ">
<VEHICLE>
<ADVREF>
<xsl:value-of select="VehicleID" />
</ADVREF>
<CAPTYPE />
<MANUFACTURER>
<xsl:value-of select="Manufacturer" />
</MANUFACTURER>
<MODEL>
<xsl:value-of select="Range" />
</MODEL>
<CAPID>
<xsl:value-of select="CAP_ID" />
</CAPID>
<DERIVATIVE />
<BODYTYPE />
<FUELTYPE />
<DOORS />
<TRANSMISSION />
<DESCRIPTION>
<xsl:value-of select="Description" />
</DESCRIPTION>
<DEEPLINK>
<xsl:value-of select="DeepLink" />
</DEEPLINK>
<FINANCETYPE>
<xsl:value-of select="FinanceType" />
</FINANCETYPE>
<DEPOSITTYPE>
<xsl:value-of select="DepositType" />
</DEPOSITTYPE>
<DEPOSITVALUE>
<xsl:value-of select="DepositValue" />
</DEPOSITVALUE>
<TERM>
<xsl:value-of select="Term" />
</TERM>
<PAYMENTS />
<MONTHLYPAYMENT>
<xsl:value-of select="MonthlyPayment" />
</MONTHLYPAYMENT>
<ANNUALMILEAGE>
<xsl:value-of select="AnnualMileage" />
</ANNUALMILEAGE>
<MAINTENANCETYPE>
<xsl:value-of select="MaintenanceType" />
</MAINTENANCETYPE>
<MAINTENANCEVALUE>
<xsl:value-of select="MaintenanceValue" />
</MAINTENANCEVALUE>
<INSTOCK>
<xsl:value-of select="InStock" />
</INSTOCK>
<DOCUMENTFEE>
<xsl:value-of select="DocumentFee" />
</DOCUMENTFEE>
<CAPCODE />
<AUTORENEW>
<xsl:value-of select="AutoRenew" />
</AUTORENEW>
<CO2 />
</VEHICLE>
</xsl:if>
</xsl:for-each>
</STOCK>
</xsl:template>
</xsl:stylesheet>
 
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
Default

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
http://www.saxonica.com/
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
Default

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):

Code:
<xsl:for-each select="ROW[SiteID='00020'][position() &gt; 14990 and position() &lt; 29980]">
Sam
__________________
/- 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.