Solved

populating xml using xslt horizontally

Posted on 2006-07-18
3
308 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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