[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Selecting node sets for page by page output - without us

Subject: Re: Selecting node sets for page by page output - without usingfor-each or mutiple ifs
From: Aaron Miller <amiller@xxxxxxxxx>
Date: Tue, 29 Aug 2000 15:10:12 -0700
aaron miller
replying to myself ...

I have managed to do this with the following xsl in my match="/" template:

<xsl:apply-templates select="descendant::story[position() &gt;= $start and
position() &lt;= $end]"/><br/>

then i use a variable and a single <xsl:if> to check for the presence of a
topic name:

      <xsl:variable name="pos"><xsl:number/></xsl:variable>
      <xsl:if test="number($pos)=1">
          <xsl:apply-templates select="../../topic"/>
      </xsl:if>

Maybe this is ugly, but it works without using xsl:for each and <xsl:choose>


> From: Aaron Miller <amiller@xxxxxxxxx>
> Reply-To: xsl-list@xxxxxxxxxxxxxxxx
> Date: Tue, 29 Aug 2000 12:09:28 -0700
> To: <xsl-list@xxxxxxxxxxxxxxxx>
> Subject: Selecting node sets for page by page output - without using for-each
> or mutiple ifs
> 
> Hello all,
> 
> I am stumped on this one. I have an XML Doc like this:
> 
> <?xml version="1.0" ?>
> <root>
> <user>
> <user_name>username</user_name>
> <greet_name>username</greet_name>
> <station id="1">
> <pseudonym>pseudonym</pseudonym>
> <id>5</id>
> </station>
> </user>
> <params>
> </params>
> 
> <clickCastProgram>
> <topicStoryContainerList>
> <topicStoryContainer>
> <topic>
> <name>Top Stories</name>
> <id>6</id>
> </topic>
> <storyList>
> <story>
> <id>999</id>
> <name>story 999 name</name>
> <description>story 999 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> <story>
> <id>998</id>
> <name>story 998 name</name>
> <description>story 998 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> <story>
> <id>997</id>
> <name>story 997 name</name>
> <description>story 997 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> <story>
> <id>996</id>
> <name>story 996 name</name>
> <description>story 996 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> </storyList>
> </topicStoryContainer>
> <topicStoryContainer>
> <topic>
> <name>topic name 2</name>
> <id>7</id>
> </topic>
> <storyList>
> <story>
> <id>889</id>
> <name>story 889 name</name>
> <description>story 889 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> <story>
> <id>888</id>
> <name>story 888 name</name>
> <description>story 888 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> <story>
> <id>887</id>
> <name>story 887 name</name>
> <description>story 887 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> <story>
> <id>886</id>
> <name>story 886 name</name>
> <description>story 886 description</description>
> <activation_date>08/10/2000</activation_date>
> <video>
> <activation_date>08/10/2000</activation_date>
> <graphic name="small">
> 
> <external_reference>http://www.zatso.com/image_url.gif</external_reference>
> </graphic>
> <length>100</length>
> <station>
> <pseudonym>Pseudonym</pseudonym>
> </station>
> </video>
> <enhancementList></enhancementList>
> </story>
> </storyList>
> </topicStoryContainer>
> </topicStoryContainerList>
> </clickCastProgram>
> </root>
> 
> As you can see, each topicStoryContainer has a topic and a storyList, and
> all the topicStoryContainers make up a topicStoryContainerList. I want to
> write an XSLT that grabs five nodes per page, based on startRange and
> endRange parameters, and creates appropriate navigation for previous and
> next pages. 
> 
> **So my question is this**: how do I grab five <story>s per page, in
> sequence, with topic headings inserted in the appropriate places, _without_
> using <xsl:for-each> or <xsl:if>?
> 
> I've tried using the position() function to determine ranges of things, but
> since this is contextual, the topic elements seem to reset it for each
> storyList.
> 
> Is this even possible? I am curious since I have been told it's much more
> efficient and desirable to use <xsl:apply-templates> and "modes" rather than
> using a lot of explicit logical branching for this sort of thing.
> 
> Thanks,
> aaron
> 
> 
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.