Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2007, 04:20 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly, there's a missing </fact> end tag around line 1200 of your XML input. Your stylesheet will never work if the input isn't well-formed XML. (Also note, if you're asked for a complete working sample, it's best to cut it down to the minimum size that actually demonstrates the problem.)

With that fixed, the stylesheet doesn't output "nothing", it outputs a lot of empty table cells like this:

<td align="center"></td>

That immediately tells you that the problem lies in the code

                    <td align="center">
                       <xsl:value-of select="value"/>
                    </td>

- specifically it means that select="value" is selecting nothing. That's because your context node is a fact, and a fact element has no child called 'value'.

I could change it to

select="slot[name='rank']/value"

and you would then get some output. But it wouldn't be the output you are looking for. You're outputting a td element here that isn't part of any tr.

I think what you probably want is this:

        <xsl:template match="rules">
          <tr bgcolor="#aaccdd">
            <th><h2>SNP rs number</h2></th>
            <th><h2>Rank Score</h2></th>
            <th><h2>Ranking Determination</h2></th>
          </tr>
          <xsl:for-each select="fact[name='MAIN::SNPRank']">
                 <xsl:sort select="slot[name='rank']/value" data-type="number" order="descending"/>
                 <tr>
                    <td align="center">
                       <xsl:value-of select="slot[name='id']/value"/>
                    </td>
                    <td align="center">
                       <xsl:value-of select="slot[name='rank']/value"/>
                    </td>
                    <td align="center">
                       <xsl:value-of select="slot[name='category']/value"/>
                    </td>
                 </tr>
          </xsl:for-each>
        </xsl:template>

or alternatively:

        <xsl:template match="rules">
          <tr bgcolor="#aaccdd">
            <th><h2>SNP rs number</h2></th>
            <th><h2>Rank Score</h2></th>
            <th><h2>Ranking Determination</h2></th>
          </tr>
          <xsl:for-each select="fact[name='MAIN::SNPRank']">
                 <xsl:sort select="slot[name='rank']/value" data-type="number" order="descending"/>
                 <tr>
                    <xsl:for-each select="slot">
                    <td align="center">
                       <xsl:value-of select="value"/>
                    </td>
                    </xsl:for-each>
                 </tr>
          </xsl:for-each>
        </xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 2nd, 2007, 02:55 PM
Authorized User
 
Join Date: Mar 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

YAY!! Thank you so very much for your time and expertise. Your solution worked! Thank you again :) Did I mention thank you...

:D





Similar Threads
Thread Thread Starter Forum Replies Last Post
A simple Sorting question bonekrusher XSLT 2 November 25th, 2007 09:40 AM
Question regarding the display of <a> tags in xml tajjyarden XSLT 1 March 21st, 2007 11:54 AM
Data View Sorting Question jazzcatone ASP.NET 1.0 and 1.1 Basics 0 October 3rd, 2006 09:42 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
HELP! More complicate sorting nodes question kevin_in_black XSLT 2 April 13th, 2004 05:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.