Advertisement

09.04.2008 at 08:46AM PDT, ID: 23703101
[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.3

XSL

Asked by smithdale87 in Extensible Markup Language (XML), Extensible Stylesheet Language Transformation (XSLT)

Consider the XML snipped below.

I'm trying to transform that format into a table as follows, where I have one single row for each unique Name in my XML. Then, have separate columns for each date, along with the corresponding text in <Whatever> for that date.

Note: The XML file will have all same-name records grouped together, rather than scattered throughout the file

Name   6/1/08     6/2/08
...
Joe       Foo         Bar
Jim        FFF         FFF
...


The problem lies in the xsl code ( see below ) that I'm trying to do this with.
The <tr></tr> elements have to come in pairs in the xsl:when statement. But I don't want that.
If I start a new row, it means I found a new Name, but I only process the first <Whatever> that the person did, then I'm forced to add a </tr>.


Does that make sense? Hope so :-)

Thanks in advance!

Oh and by the way, the xsl code my have syntactical errors, but I hope you can see what I'm trying to do.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
//XML
 
...
<record>
  <Name>Joe</Name>
  <Date>6/1/08</Date>
  <Whatever>Foo</Whatever>
</record>
<record>
  <Name>Joe</Name>
  <Date>6/2/08</Date>
  <Whatever>Bar</Whatever>
</record>
...
 
 
 
//XSL
=========================================================
 
<xsl:for-each select="/record">
   <xsl:choose>
      <xsl:when test="Name[.=preceding::Name]">
           <td>
             <xsl:value-of select="Whatever">
           </td>
      </xsl:when>
      <xsl:when test = "Name[not(.=preceding::Name)]">
           <tr>
             <td>
                  <xsl:value-of select="Name"/>
             </td>
             <td>
                  <xsl:value-of select="Whatever">
             </td>
           </tr>
      </xsl:when>
   </xsl:choose>
</xsl:for-each>
[+][-]09.04.2008 at 08:57AM PDT, ID: 22389090

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 09:00AM PDT, ID: 22389152

View this solution now by starting your 30-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

Zones: Extensible Markup Language (XML), Extensible Stylesheet Language Transformation (XSLT)
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.04.2008 at 09:33AM PDT, ID: 22389566

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628