Advertisement

06.25.2006 at 07:53AM PDT, ID: 21898424
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Problem with two separate but sortable tables (urgent!)

Asked by JGMann in Extensible Markup Language (XML)

I am having problems taking an xml report (in the format described below) and, using xsl, transform it into separately sortable tables that appear on the same page.  

The stylesheet should transform the xml so that each project is its own table (and containing the project's rows), each attribute becomes a column of that table, and each table should be sortable by any attribute (column).

I had no problem getting the transform to output the data as desired, but I cannot figure out how to sort each table separately.  All my efforts, produce the same outcome: if I click the column of one table, all tables are sorted.

Everything I am using that's relevant is listed below.  I am sure everything except the XML will need to change.  My experience with XSL is very limited, and I have been searching forever for this solution and am running out of time.

Thanks!

----------------------------------------

XML Format:

<Report>
  <Project Name="Project 1">
    <Row AttributeA="1" AttributeB="2"/>
    <Row AttributeA="3" AttributeB="4"/>
    <Row AttributeA="5" AttributeB="6"/>
    <Row AttributeA="7" AttributeB="8"/>
  </Project>
  <Project Name="Project 2">
    <Row AttributeA="9" AttributeB="10"/>
    <Row AttributeA="11" AttributeB="12"/>
    <Row AttributeA="13" AttributeB="14"/>
    <Row AttributeA="15" AttributeB="16"/>
  </Project>
  <Project Name="Project 3">
    <Row AttributeA="17" AttributeB="18"/>
    <Row AttributeA="19" AttributeB="20"/>
    <Row AttributeA="21" AttributeB="22"/>
    <Row AttributeA="23" AttributeB="24"/>
  </Project>
</Report>

----------------------------------------

XSL Format:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>      
<xsl:template match="/">
  <xsl:apply-templates select="//Project"/>
</xsl:template>
<xsl:template match="//Project">
  <P>
      <H2><xsl:value-of select="./@Name"/></H2>
      <TABLE>
        <TR>
          <TH onClick="sort('./@AttributeA','text');">AttributeA</TH>
          <TH onClick="sort('./@AttributeB','text');">AtributeB</TH>
        </TR>                        
        <xsl:for-each select="./row">
          <xsl:sort select="./@AttributeA" order="ascending" datatype="text"/>
          <TR>
            <TD><xsl:value-of select="./@AttributeA"/></TD>
            <TD><xsl:value-of select="./@AttributeB"/></TD>
          </TR>                              
        </xsl:for-each>
      </TABLE>
    </P>
</xsl:template>
</xsl:stylesheet>

----------------------------------------

Javascript:

function sort(sortBy,dataType)
{
  // XSLObject is the stylesheet as a data island
  // and is already loaded

  var sortSelection = XSLObject.selectSingleNode("//xsl:sort/@select");

  sortSelection.nodeValue = sortBy;

  var sortOrder = XSLObject.selectSingleNode("//xsl:sort/@order");

  if (currentSortBy == sortBy)
  {
    if (sortOrder.nodeValue == "ascending")
    {
      sortOrder.nodeValue = "descending";
    }
    else
    {
      sortOrder.nodeValue = "ascending";
    }
  }
  else
  {
    sortOrder.nodeValue = "ascending";
  }

  currentSortBy = sortBy;
 
  var sortDateType = XSLObject.selectSingleNode("//xsl:sort/@datatype");
  sortDateType.nodeValue = dataType;

  //Existing function that does the transform
  DoTransform();
}

----------------------------------------
Start Free Trial
[+][-]06.26.2006 at 12:22PM PDT, ID: 16986986

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.26.2006 at 12:26PM PDT, ID: 16987012

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.27.2006 at 12:40AM PDT, ID: 16990460

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Extensible Markup Language (XML)
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.28.2006 at 07:10AM PDT, ID: 17001273

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.28.2006 at 10:37AM PDT, ID: 17003229

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.28.2006 at 11:41AM PDT, ID: 17003761

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32