hi,
I found in webapp/stylesheets/system/profiler.xsl following xsl-code 
snippet which might
help you:
        <table noshade="noshade" border="0" cellspacing="1" 
cellpadding="0" width="100%">
          <xsl:choose>
            <xsl:when test="$sort = 'uri'">
              <xsl:apply-templates>
                 <xsl:sort select="@profile:uri"/>
              </xsl:apply-templates>
            </xsl:when>
            <xsl:when test="$sort = 'time'">
              <xsl:apply-templates>
                 <xsl:sort select="@profile:time" data-type="number"/>
              </xsl:apply-templates>
            </xsl:when>
            <xsl:when test="$sort = 'count'">
              <xsl:apply-templates>
                 <xsl:sort select="@profile:count" data-type="number"/>
              </xsl:apply-templates>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates/>
            </xsl:otherwise>
          </xsl:choose>
        </table>

It seems the trick is to map the $sort directly to a xsl:sort.
Hope it helps.
profiler.xsl is part of the Cocoon2 CVS distribution.
bye bernhard



Steve Philp wrote:

>I've spent most of the day today trudging through various search engines, FAQs, 
>mailing list archives and the Cocoon-2 site, but I still seem to be missing something 
>critical in getting something that seems simple working.
>
>The problem revolves around how to efficiently use request parameters to choose a SQL 
>resultset column to sort by in my stylesheet.
>
>I've got the following in sitemap.xmap:
>
>       <map:match pattern="sql/*">
>               <map:generate src="docs/samples/sql/{1}.xml"/>
>               <map:transform type="sql">
>                       <map:parameter name="use-connection" value="testdb"/>
>               </map:transform>
>               <map:transform src="stylesheets/employees.xsl">
>                       <map:parameter name="use-request-parameters" value="true"/>
>               </map:transform>
>               <map:serialize/>
>       </map:match>
>
>I should mention that the XSLT transformer is also modified to turn on request 
>parameters.
>
>The SQL xml document looks like:
>
>       <?xml version="1.0"?>
>
>       <page xmlns:sql="http://apache.org/cocoon/SQL/2.0";>
>               <title>Employees</title>
>               <content>
>                       <execute-query xmlns="http://apache.org/cocoon/SQL/2.0";> 
>                               <query>
>                                       select emid, emfname, emlname from employee
>                               </query>
>                       </execute-query>
>               </content>
>       </page>
>
>Both are nearly stock from the Cocoon distribution and seem to work just fine (that 
>is, the output is what I would expect to see).  
>
>My problem comes in attempting to take that resultset and process it in the 
>stylesheet.  Ideally, I'd like to create a single stylesheet that would use the HTTP 
>request parameter order_by as the sort-by column.  My XSL looks like this (including 
>just the relevant template):
>
>       <xsl:template match="sql:rowset">
>               <xsl:param name="order_by"/>
>               <table border="0" width="100%">
>                       <tr bgcolor="aaccee" align="left">
>                               <th><a href="?order_by=sql:emid">Employee ID</a></th>
>                               <th><a href="?order_by=sql:emfname">First Name</a></th>
>                               <th><a href="?order_by=sql:emlname">Last Name</a></th>
>                       </tr>
>                       <xsl:for-each select="sql:row">
>                               <xsl:sort select="$order_by"/>
>                               <tr>
>                                       <xsl:attribute name="bgcolor">
>                                               <xsl:choose>
>                                                       <xsl:when test="position() mod 
>2 = 0">
>                                                               
><xsl:text>white</xsl:text>
>                                                       </xsl:when>
>                                               </xsl:choose>
>                                       </xsl:attribute>
>                                       <xsl:apply-templates/>
>                               </tr>
>                       </xsl:for-each>
>               </table>
>       </xsl:template>
>
>It appears to me that $order_by DOES hold the value that I'm interested in, since I 
>can include: 
>
>       <td><xsl:value-of select="$order_by"/></td>
>
>just after the <xsl:apply-templates/> and get the expected value in that column.
>
>
>
>The mailing list archives mentioned something similar to "*[name()=$order_by]" as 
>being a working answer, but it doesn't seem to have any affect upon the output in 
>this situation.
>
>With my limited knowledge of Cocoon and XSL, I'm not sure where to go from here.  I 
>have tested using URI path extensions (e.g. /sql/sql-page/ByID) and choosing the 
>stylesheet in sitemap.xmap based on that, and that seems to work, but it would work 
>out to be a maintenance nightmare holding onto stylesheets for each possible sortable 
>column in each page.
>
>If I want to use request parameters, are XSPs my only option?
>
>What (obvious, I'm quite sure) options do I have at this point?
>
>Thank you for any help or pointers anyone can offer,
>
>--
>Steve Philp
>Advance Packaging Corporation
>[EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <[EMAIL PROTECTED]>
>For additional commands, e-mail: <[EMAIL PROTECTED]>
>
>



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to