Solved

populating xml using xslt horizontally

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSLT XML 4 40
MS Access XML Export Query Setup Multiple Tag Values 15 54
C# Formatting DateTime String Value 5 68
XML and version of MS XML Dom Document versions 5 45
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 …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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