Struggles with relationships, any help appreciated!

Here should go questions about transforming XML with XSLT and FOP.
slaterino
Posts: 11
Joined: Sat Jan 09, 2010 8:13 pm

Struggles with relationships, any help appreciated!

Post by slaterino »

Hi,
I am trying to create a simple bit of navigation to put on the right of my page so there will be a link to the next article. I have got this bit right but am having trouble with the final article, where I want it to point to the first article rather than the last one. The problem is arising because I have three 'section's in my document. Therefore chapter 1 could refer to chapter 1 in either three of these sections. Each section has a title which is how I am trying to differentiate it in this code. Therefore, I am trying to find chapter 1 of the section with title 'Features'.

Code: Select all

    <xsl:template name="article_nav">
<p>
<xsl:choose>
<xsl:when test="position() = last()">
<xsl:if test="../title='Features'">
<xsl:value-of select="//chapter[position()=1]/title"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="following-sibling::chapter[1]/title"/>
</xsl:otherwise>
</xsl:choose>
</p>
</xsl:template>


At the moment this code produces the title for all chapter 1's in the document. I think for it to work I need to include both '//chapter[position()=1]/title' and '../title='Features'' in the same value-of. How would I go about doing this?

Thanks
Russ