Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2006, 12:29 PM
Registered User
 
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generate a summary from an XML file.

I have an XML file with this detail:

<sales>

<sale P_ID="12" L_ID="02" T_ID="02-06-2003">
<quantity>46</quantity>
</sale>
<sale P_ID="11" L_ID="03" T_ID="22-07-2003">
<quantity>31</quantity>
</sale>
<sale P_ID="12" L_ID="03" T_ID="02-07-2004">
<quantity>59</quantity>
</sale>
<sale P_ID="11" L_ID="04" T_ID="22-06-2003">
<quantity>27</quantity>
</sale>
<sale P_ID="12" L_ID="04" T_ID="13-06-2004">
<quantity>19</quantity>
</sale>
<products>
<product>
<p_id>11</p_id>
<p_name>Glasses</p_name>
</product>
<product>
<p_id>12</p_id>
<p_name>Clothes</p_name>
</product>
<product>
<p_id>13</p_id>
<p_name>Shoes</p_name>
</product>
</products>

<locations>
<state>
<s_name>New South Wales</s_name>
<city>
<c_name>Sydney</c_name>
<l_id>01</l_id>
</city>
<city>
<c_name>New England</c_name>
<l_id>02</l_id>
</city>
</state>
<state>
<s_name>Victoria</s_name>
<city>
<c_name>Melbourne</c_name>
<l_id>03</l_id>
</city>
</state>
<state>
<s_name>Queensland</s_name>
<city>
<c_name>Brisbane</c_name>
<l_id>04</l_id>
</city>
</state>
</locations>
<time>
<year>
<y_name>2003</y_name>
<month>
<m_name>06</m_name>
<date>
<d_name>02</d_name>
<t_id>02-06-2003</t_id>
</date>
<date>
<d_name>22</d_name>
<t_id>22-06-2003</t_id>
</date>
</month>
<month>
<m_name>07</m_name>
<date>
<d_name>22</d_name>
<t_id>22-07-2003</t_id>
</date>
</month>
</year>
<year>
<y_name>2004</y_name>
<month>
<m_name>06</m_name>
<date>
<d_name>13</d_name>
<t_id>13-06-2004</t_id>
</date>
</month>
<month>
<m_name>07</m_name>
<date>
<d_name>02</d_name>
<t_id>02-07-2004</t_id>
</date>
</month>
</year>
</time>
</sales>

And I want to generate XSL code that summarize the data into the format like this:

Year=...
---------------------------------------------------------------------------------
States(rows)/Products(columns) | Glasses | Clothes | Shoes | TOTAL
---------------------------------------------------------------------------------
New South Wales | xxxx | xxxxx | xxxxx | xxxx
---------------------------------------------------------------------------------
Victoria | xxxx | xxxx | xxxx | xxxx
---------------------------------------------------------------------------------
Queensland | xxxx | xxxx | xxxx | xxxx
---------------------------------------------------------------------------------
TOTAL | xxxx | xxxx | xxxx | xxxx
---------------------------------------------------------------------------------

Year=...
---------------------------------------------------------------------------------
States(rows)/Products(columns) | Glasses | Clothes | Shoes | TOTAL
---------------------------------------------------------------------------------
New South Wales | xxxx | xxxxx | xxxxx | xxxx
---------------------------------------------------------------------------------
Victoria | xxxx | xxxx | xxxx | xxxx
---------------------------------------------------------------------------------
Queensland | xxxx | xxxx | xxxx | xxxx
---------------------------------------------------------------------------------
TOTAL | xxxx | xxxx | xxxx | xxxx
---------------------------------------------------------------------------------


I've tried for a number of codes I can think, but all ended up with the error "VariableReference given for variable out of context or without definition!"

I've no idea what should I do. Can you help me to find a way to map the data from this XML file into a summarized detail?
Thank you for any suggestion.

PS. I'm fairly new to XSLT. The solution of this problem might be easier than I think.

 
Old May 2nd, 2006, 04:58 AM
Authorized User
 
Join Date: Apr 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vakorde
Default

Hi Missing_Piece,

give the code that you have done RnD on... so that we can give some suggestions.....






Similar Threads
Thread Thread Starter Forum Replies Last Post
generate xml from db in asp.net imjigu ASP.NET 1.0 and 1.1 Professional 1 July 4th, 2006 12:27 AM
generate xml from db in asp.net imjigu ASP.NET 1.0 and 1.1 Basics 0 June 30th, 2006 02:04 AM
Generate Xml from DataSet monuindia2002 XML 0 March 22nd, 2006 01:06 AM
generate XML from SQL server 2000 table sasidhar79 XML 2 August 3rd, 2005 11:05 AM
How to generate WORD doc. from XML files??? iapraiz XML 1 March 11th, 2004 05:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.