Solved

populating xml using xslt horizontally

Posted on 2006-07-18
3
319 Views
Last Modified: 2012-05-05
I'm trying to transform XML file sample below:

<ticket>
   <month name="June">
       <item id="one">45</item>
       <item id="two">65</item>
       <item id="three">94</item>
  </month>
   <month name="July">
       <item id="one">34</item>
       <item id="two">23</item>
       <item id="three">12</item>
  </month>
</ticket>

to HTML table below:

      June      July
one      34      44
two      12      23
three      45      76

using XSLT.   However I am not able to populate 'June' and 'July' in the HTML table.
0
Comment
Question by:kaushalshah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
owenli27 earned 500 total points
ID: 17135859
Try use this XSL to see if it work:

<?xml version="1.0" encoding="ISO-8859-1" ?>  
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="html" />
 <xsl:template match="/">
 <html><body>
 <table>
  <tr>
  <td> </td>
  <xsl:for-each select="ticket/month">
  <td> <xsl:value-of select="@name"/></td>
  </xsl:for-each>
  </tr>

 <tr><td>one</td>
  <xsl:for-each select="ticket/month">
  <xsl:for-each select="item">
   <xsl:if test="'one'=@id">
   <td> <xsl:value-of select="." /></td>
   </xsl:if>
 </xsl:for-each>
 </xsl:for-each>
</tr>

<tr><td>two</td>
  <xsl:for-each select="ticket/month">
  <xsl:for-each select="item">
   <xsl:if test="'two'=@id">
   <td> <xsl:value-of select="." /></td>
   </xsl:if>
 </xsl:for-each>
 </xsl:for-each>
</tr>

 <tr><td>three</td>
  <xsl:for-each select="ticket/month">
  <xsl:for-each select="item">
   <xsl:if test="'three'=@id">
   <td> <xsl:value-of select="." /></td>
   </xsl:if>
 </xsl:for-each>
 </xsl:for-each>
</tr>
 </table>
  </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>
0
 

Author Comment

by:kaushalshah
ID: 17168017
awesome.   just one question;  in '<td> <xsl:value-of select="." /></td>', what is select="."?
0
 
LVL 9

Expert Comment

by:owenli27
ID: 17168888
It is an expression to tell xsl to return and output the current element value
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question