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 November 22nd, 2005, 11:36 AM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying a number of results

Hello,

I was wondering if anyone knew if you can use xslt to control how man records are printed from an xml page to a html page. For example, I have a xml page with 50 news stories, and I only want to pull 5 headlines or so and list them as HTML in an ASP page.

Is this possible to do?

THanks folks

John

 
Old November 22nd, 2005, 12:01 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, you want something like

<xsl:apply-templates select="story[position() &lt; 6]"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 22nd, 2005, 12:18 PM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for getting back Michael. I really appreciate it.

I was just wondering about the positioning of the code. is this right:

Code:
<?xml version="1.0" encoding="windows-1252" standalone="yes" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" omit-xml-declaration="no"/> 

<xsl:apply-templates select="story[position() &lt; 6]"/>

<xsl:template match="InfoStreamResults">
<xsl:apply-templates select="Article"/>
</xsl:template>
<xsl:template match="Article">
<A><xsl:attribute name="HREF">ItemPage.asp?ItemID=<xsl:value-of select="@ID"/></xsl:attribute>
<B><xsl:value-of select="Heading"/></B></A>
<br/> 
</xsl:template>
</xsl:stylesheet>

Do I have to change the Story to a relevant tag? And does the 6 stand for the abount of headlines?

Thanks again

John






Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation For Phone Number and Mobile Number dhruthi.ram99 Javascript How-To 12 October 30th, 2011 07:24 AM
Edit Query Results in Results Grid druid2112 SQL Server 2005 1 June 28th, 2007 08:49 AM
display results carswelljr ASP.NET 2.0 Basics 1 April 19th, 2007 09:46 AM
Ch 2 Try It Out Example 2-4. Different results. VictorVictor BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 5 March 27th, 2006 12:12 PM
Displaying Multiple Results webasp1 Classic ASP Databases 2 July 24th, 2003 12:41 PM





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