This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Selecting node sets for page by page output - without usingfor-each or mutiple ifs


Aaron,

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

xsl:number without any attributes will give you the number of the node
within the list of it's similar siblings - in your case the number of the
story amongst the other story elements within the storyList.  So generating
that number and checking whether it's '1' or not is equivalent to asking
the question 'is this the first story element under its storyList' or 'are
there any preceding story elements to this one in the source?'.

So, you could change your test to the slightly less ugly:

<xsl:if test="not(preceding-sibling::story)">
  <xsl:apply-templates select="../../topic" />
</xsl:if>

Cheers,

Jeni



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]