the actual method of sorting I used was the following:
my xml basically provided a sort value for each entry

<datal>
  <entry>
    <field>
      <name>Amount</name>
      <value>$10.00</value>
      <sort>1000</sort>
    </field>
    <field>
      <name>Date</name>
      <value>19/4/08</value>
      <sort>20080419</sort>
    </field>
  </entry>
  <entry>
    <field>
      <name>Amount</name>
      <value>$25.45</value>
      <sort>2545</sort>
    </field>
    <field>
      <name>Date</name>
      <value>18/4/08</value>
      <sort>20080418</sort>
    </field>
  </entry>
</data>

that should give you the idea - for string values I just replicated the string in lowercase.
then I had my sort value be the 'column' number, with a desc flag
then in the xsl that displayed it, something like this (not sure if it meshes with my example xml )

				<xsl:choose>
					<xsl:when test='$sort_desc'>
						<xsl:apply-templates select='Result'>
							<xsl:sort order='descending' select='Field[$sort_by]/Sort' data-type='number' />
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select='Result'>
							<xsl:sort order='ascending' select='field[$sort_by]/sort' data-type='number' />
						</xsl:apply-templates>
					</xsl:otherwise>
				</xsl:choose>

not sure if that's enough to give you a grasp of it, if not I can probably post a full example, just it's a pain to redact it 😛

    perhaps providing my code can help you help me a little further

    here is the block of xsl that dumps one of my three tables:

    <h2>Current Collections</h2>
    <table cellspacing="0" cellpadding="2">
    	<thead><xsl:call-template name="table_header"/></thead>
    	<tbody>
    		<xsl:for-each select="channel/item[collectionStatus='Active']">
    			<xsl:call-template name="table_row"/>			
    		</xsl:for-each>
    	</tbody>
    </table>
    

    i was attempting to set the sort right under the foreach

    currently have 8 header values that i would like to sort by

      KK, I'm at home now, so no code of my own to look at, but from memory I think you need to set up the template table_row to have a parameter, and pass the search parameter to it.

        well my parameters are declared at the top of my xsl so they should be considered global

          it's also "crashing" when i add an xsl:sort element within my table_row template... presumable i need to have that sort element right after that for-each... any other way seems to make it die

            dan when you get a moment... i tried putzing around with your when/choose implementation a bit last night and I couldnt seem to make it work

            perhaps you could review your code at the office and give me a little more insight (my apologies for the annoying redactions)

              ok. I just went over a chunk of the code.
              I chopped out a lot of crap that wasn't needed, and redacted teh rest, it's missing most of it's css, all of it's images, etc, etc.

              as a brief overview: it's a reporting system that is customised to the user - the menu on the left is custom generated based on the user's "inventory" so to speak.
              they select items on the left menu, then get teh report, which is usually generated by a php script that generates the xml, meaning the eventual report has a varying amount of columns, that can potentially hold different types of data, thus the xsl is bigger than usual so it can deal with dynamic incoming data structures.
              I pulled an xml result from the generator and provided it as sample xml, so the menu selections won't actually modify the data (but u have to select something to start the report)
              it'll be a lil difficult to navigate as the images are all broken, etc, but you should be able to get a working example out of it, functionality-wise.
              if you have any more questions, just ask.

              Oh, also - this is an unfinished project, and is being written under a time restriction, so I know it's probably not the cleanest code out there.

                forgot a file, and can't edit my post for some reason, so here it is again with the missing html

                  holy crow I got it to work

                  I had to do this:

                  <xsl:sort select="*[name() = $sort]" />

                  NOW! the only thing thats left... since this will sort all three tables and I only want to sort one I tried this:

                  <xsl:if test="$table = 'active'">
                  <xsl:sort select="*[name() = $sort]" />
                  </xsl:if>

                  and that blew up on me...

                  SOB! 🙂

                    hmm, without looking into it too far, you can try moving your if statement further out, and probably changing it to a choose - I know xsl has a lot of issues with what an if or choose check can be inside of.

                    if you post the xsl and surrounding section I can take a better look if that much doesn't help.

                    btw - did the crap i uploaded help you any?

                      CoderDan;10917422 wrote:

                      btw - did the crap i uploaded help you any?

                      it certainly did.. gave me some good insight on how to do some other things i had in mind... especially the nav stuff... pretty slick... thanks for that 🙂

                        Write a Reply...