Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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 March 14th, 2012, 09:42 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML to XML: transforming a "linear group" to a "hierarchical clustering"

Hi,

I'm really newby about xslt. I use xsltproc.
I need to transform the following xml data:

<?xml version="1.0" encoding="utf-8"?>
<data>
<row>
<city>Abbadia San Salvatore</city>
<reg>Toscana</reg>
<prov>Siena</prov>
<sigla_prov>SI</sigla_prov>
<lat>42.88</lat>
<lon>11.67</lon>
<alt>822</alt>
<day>2012-03-12</day>
<pday>1218</pday>
</row>
<row>
<city>Abetone</city>
<reg>Toscana</reg>
<prov>Pistoia</prov>
<sigla_prov>PT</sigla_prov>
<lat>44.15</lat>
<lon>10.66</lon>
<alt>1388</alt>
<day>2012-03-12</day>
<pday>1218</pday>
</row>
</data>

into this:
<?xml version="1.0" encoding="utf-8"?>
<data>
<row>
<city value="Abbadia San Salvatore">
<day value="2012-03-12">
<pday value="1218">
<reg>Toscana</reg>
<prov>Siena</prov>
<sigla_prov>SI</sigla_prov>
<lat>42.88</lat>
<lon>11.67</lon>
<alt>822</alt>
</pday>
</day>
</city>
</row>
<row>
<city value="Abetone">
<day value="2012-03-12">
<pday value="1218">
<reg>Toscana</reg>
<prov>Pistoia</prov>
<sigla_prov>PT</sigla_prov>
<lat>44.15</lat>
<lon>10.66</lon>
<alt>1388</alt>
</pday>
</day>
</city>
</row>
</data>

in order to group the data by city, then by date, then time.
Can you help me?

Thank you very much!
 
Old March 14th, 2012, 10:25 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

That's a standard grouping question. Grouping is a lot easier using XSLT 2.0, but if you're stuck with xsltproc (which only supports 1.0) you need to learn about Muenchian grouping. You'll find it described in any good XSLT textbook and there are plenty of tutorials on the web.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference




Similar Threads
Thread Thread Starter Forum Replies Last Post
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
Difficulties with "web.config" and "ASPNETDB" CFRham BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 July 3rd, 2010 10:19 AM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM





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