Jump to content

terrypink

Members
  • Posts

    4
  • Joined

  • Last visited

About terrypink

  • Birthday 09/14/1979

Contact Methods

  • Website URL
    http://students.washington.edu/hyshen/
  • ICQ
    0

Profile Information

  • Gender
    Male
  • Location
    Seattle

terrypink's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Thank you so much for your suggestion! I had posted the question to the p2p.wrox.com forum as well, and an expert there also offered a solution. Here's the one that worked in case anyone else is interested. <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>
  2. Yikes! I spoke too soon, it didn't work. If I use the code -> <xsl:for-each select="fact"> <xsl:if test="name = 'MAIN::SNPRank'"> <tr width="80%" align="center"> <xsl:for-each select="slot"> <xsl:sort select="slot[name='rank']/@value" data-type="number"/> <td align="center"> <xsl:value-of select="value"/> </td> </xsl:for-each> </tr> </xsl:if> </xsl:for-each> With this code, I at first thought it was working, but then I realized that it was just returning the rows in the order that you entered the data. So if I use this XML -> <fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs4525</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.60</value> </slot> <slot> <name>category</name> <value type='STRING'>nonsynonymous</value> </slot></fact><fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs405509</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.20</value> </slot> <slot> <name>category</name> <value type='STRING'>locus-region</value> </slot></fact><fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs13266634</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.60</value> </slot> <slot> <name>category</name> <value type='STRING'>nonsynonymous</value> </slot></fact> I get back this result ->rs4525 0.60 nonsynonymousrs405509 0.20 locus-regionrs13266634 0.60 nonsynonymousI also tried adding on order="ascending" as well as order="descending", still it's not looking like it's sorting.Does anyone have any other possible thoughts? I'd really be very appreciative if someone could help me figure this out.
  3. Oops. Spoke too soon. I found the answer on another forum. In case anyone's interested, here's the code that worked -> <xsl:for-each select="fact"> <xsl:if test="name = 'MAIN::SNPRank'"> <tr width="80%" align="center"> <xsl:for-each select="slot"> <xsl:sort select="slot[name='rank']/@value" data-type="number"/> <td align="center"> <xsl:value-of select="value"/> </td> </xsl:for-each> </tr> </xsl:if> </xsl:for-each>
  4. Hi everyone,New to XSLT and was hoping someone would be nice enough to offer some concrete help.I have the following XML ->-------------------------------------------------------------------------------------------------------- <fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs3740878</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.30</value> </slot> <slot> <name>category</name> <value type='STRING'>intron</value> </slot></fact><fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs11037909</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.30</value> </slot> <slot> <name>category</name> <value type='STRING'>intron</value> </slot></fact><fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs13266634</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.60</value> </slot> <slot> <name>category</name> <value type='STRING'>nonsynonymous</value> </slot></fact><fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs7480010</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.30</value> </slot> <slot> <name>category</name> <value type='STRING'>intron</value> </slot></fact><fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs7903146</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.30</value> </slot> <slot> <name>category</name> <value type='STRING'>intron</value> </slot></fact><fact> <name>MAIN::SNPRank</name> <slot> <name>id</name> <value type='STRING'>rs1113132</value> </slot> <slot> <name>rank</name> <value type='STRING'>0.30</value> </slot> <slot> <name>category</name> <value type='STRING'>intron</value> </slot></fact> ---------------------------------------------------------------------------------------------------I'm using the following XSLT code -> <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <xsl:for-each select="fact"> <xsl:if test="name = 'MAIN::SNPRank'"> <tr width="80%" align="center"> <xsl:for-each select="slot"> <xsl:sort select="value" order="descending"/> <td align="center"> <xsl:value-of select="value"/> </td> </xsl:for-each> </tr> </xsl:if> </xsl:for-each> </xsl:template></xsl:stylesheet> ------------------------------------------------------------------------------------------------------------------------------------This is the result I'm getting ->rs3740878 intron 0.30rs11037909 intron 0.30rs13266634 nonsynonymous 0.60rs7480010 intron 0.30rs7903146 intron 0.30rs1113132 intron 0.30But what I'm trying to do is sort the rows by the number score, so rs1326634 with the score of 0.60 should be at the top of the list.If I should use another strategy like grouping, could someone tell me how?I'm stuck with the XML I have...Could somebody please help me?Thanks SO much for any responses,~Terry
×
×
  • Create New...