Solved

populating xml using xslt horizontally

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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, …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now