tags:

views:

37

answers:

1

I have an XML file with company data in it, for 30 companies across 8 industries, on a portfolio page. The user has the option to sort this data by Industry, and this XML file will be added to constantly.

This sorting is done in my XSL file using <xsl:choose>. Example:

<xsl:when test="(invest[@investid='con'])">
    <xsl:for-each select="$invest-port/portfolio/company[@industry='Communications']">
                 <xsl:sort select="name" />
                 <div class="invest-port-thumb">
                     <a>
                        <xsl:attribute name="href">
                         <xsl:value-of select="link" />
                        </xsl:attribute>
                        </a>
                    </div>
                </xsl:for-each>
</xsl:when>

When navigating to an individual company's page, there are "previous" and "next" buttons at the bottom of the window. My issue is that I need these to dynamically link to the previous and next <link> elements from within the XML data that has been sorted.

Part of the master XML file:

<portfolio recact="1">

    <company industry="Industrial" status="Current" coid="1">
        <name>Horn Company</name>
        <hq>Owensboro, KY</hq>
        <link>horn.xml</link>
    </company>

    <company industry="Consumer" status="Current" coid="1">
        <name>Mike Waters Co</name>
        <hq>Orlando, FL</hq>
        <link>waters.xml</link>
    </company>

</portfolio>

Is this possible? Or is there an easier way to do this? (such as place each company in industry-divided XML files instead of one)

Any insight would be greatly appreciated!

A: 

use preceding-sibling and following-sibling

EDIT

 <xsl:variable name="sorted">
      <xsl:for-each select="$invest-port/portfolio/company[@industry='Communications']">
           <xsl:sort select="name"/>
           <xsl:copy-of select="."/>
      </xsl:for-each>
 </xsl:variable>

and after you can do

<xsl:for-each select="$sorted/*">
    <xsl:apply-templates />
</xsl:for-each>

So you can use preceding-sibling and following-sibling

Gregoire
Would this work after applying an <xsl:sort> ? or would it treat it as it hadn't been sorted?
Andrew Parisi
@Andrew Parisi http://www.biglist.com/lists/xsl-list/archives/200504/msg01384.html
Gregoire
Thanks for responding so quickly Gregoire. Unfortunately, I am pretty new to XSLT, and am still a bit confused. I may have asked the wrong question. What I am asking is, will these methods work on filtered data from the XML file? Shown in my example code, I am only showing nodes with @industry='Communications' (as an example of one of the industries), So i only want to navigate back and forth between nodes that match that particular attribute. Thanks for your help!
Andrew Parisi