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 July 9th, 2011, 01:05 AM
Registered User
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML to HTML using XSL

Hi,
I am new to XSL. I don't know how to loop through XML and filter duplicates using XSL. I tried several ways but i could hot get it done. Here is my requirement.

My XML
---------
<?xml version="1.0" ?>
<X12Summary>
<Unit volume="10" Amount="100">
<Identifier Name="Customer ID" Value="12345" />
<Identifier Name="Customer Name" Value="Jones Thomas" />
<?xml version="1.0" ?>
<X12Summary>
<Unit volume="10" Amount="100">
<Identifier Name="Customer ID" Value="12345" />
<Identifier Name="Customer Name" Value="Jones Thomas" />
<Identifier Name="Address" Value="addr1" />
<Identifier Name="City" Value="Atlanta" />
<Identifier Name="Zipcode" Value="10231" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="EST" />
</Unit>
<Unit volume="10" Amount="1000">
<Identifier Name="Customer ID" Value="12345" />
<Identifier Name="Customer Name" Value="Jones Thomas" />
<Identifier Name="Address" Value="addr2" />
<Identifier Name="City" Value="Chicago" />
<Identifier Name="Zipcode" Value="10232" />
<Identifier Name="Brand" Value="old" />
<Identifier Name="TimeZone" Value="EST" />
</Unit>
<Unit volume="10" Amount="1500">
<Identifier Name="Customer ID" Value="12345" />
<Identifier Name="Customer Name" Value="Jones Thomas" />
<Identifier Name="Address" Value="addr3" />
<Identifier Name="City" Value="Dallas" />
<Identifier Name="Zipcode" Value="16232" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="CST" />
</Unit>
<Unit volume="10" Amount="1500">
<Identifier Name="Customer ID" Value="23451" />
<Identifier Name="Customer Name" Value="David Beckley" />
<Identifier Name="Address" Value="addr4" />
<Identifier Name="City" Value="mexico" />
<Identifier Name="Zipcode" Value="15732" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="CST" />
</Unit>
<Unit volume="10" Amount="1520">
<Identifier Name="Customer ID" Value="23451" />
<Identifier Name="Customer Name" Value="David Beckley" />
<Identifier Name="Address" Value="addr5" />
<Identifier Name="City" Value="UAE" />
<Identifier Name="Zipcode" Value="1245125" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="PST" />
</Unit>
</X12Summary> <Identifier Name="Address" Value="addr1" />
<Identifier Name="City" Value="Atlanta" />
<Identifier Name="Zipcode" Value="10231" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="EST" />
</Unit>
<Unit volume="10" Amount="1000">
<Identifier Name="Customer ID" Value="12345" />
<Identifier Name="Customer Name" Value="Jones Thomas" />
<Identifier Name="Address" Value="addr2" />
<Identifier Name="City" Value="Chicago" />
<Identifier Name="Zipcode" Value="10232" />
<Identifier Name="Brand" Value="old" />
<Identifier Name="TimeZone" Value="EST" />
</Unit>
<Unit volume="10" Amount="1500">
<Identifier Name="Customer ID" Value="12345" />
<Identifier Name="Customer Name" Value="Jones Thomas" />
<Identifier Name="Address" Value="addr3" />
<Identifier Name="City" Value="Dallas" />
<Identifier Name="Zipcode" Value="16232" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="CST" />
</Unit>
<Unit volume="10" Amount="1500">
<Identifier Name="Customer ID" Value="23451" />
<Identifier Name="Customer Name" Value="David Beckley" />
<Identifier Name="Address" Value="addr4" />
<Identifier Name="City" Value="mexico" />
<Identifier Name="Zipcode" Value="15732" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="CST" />
</Unit>
<Unit volume="10" Amount="1520">
<Identifier Name="Customer ID" Value="23451" />
<Identifier Name="Customer Name" Value="David Beckley" />
<Identifier Name="Address" Value="addr5" />
<Identifier Name="City" Value="UAE" />
<Identifier Name="Zipcode" Value="1245125" />
<Identifier Name="Brand" Value="new" />
<Identifier Name="TimeZone" Value="PST" />
</Unit>
</X12Summary>

Output should be in HTML table like this
------------------------------------
12345 - Jones Thomas

Address City Zipcode Brand TimeZone Amount
addr1 Atlanta 10231 new EST 100
addr2 Chicago 10232 old EST 1000
addr3 Dallas 16232 new CST 1500


23451 - David Beckley

Address City Zipcode Brand TimeZone Amount
addr4 mexico 15732 new CST 1500
addr5 UAE 1245125 old PST 1520

Can anyone please help me to get XSL for this. Thanks in advance.
 
Old July 9th, 2011, 06:18 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Decide whether you want to use XSLT 2.0 or 1.0. With 2.0 you can use for-each-group http://www.w3.org/TR/xslt20/#grouping-examples to group your input XML, with XSLT 1.0 you can use Muenchian grouping: http://www.jenitennison.com/xslt/grouping/index.xml
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML + XSL = HTML 4 EMAIL ?? Bill_Thompson XSLT 3 December 16th, 2008 09:48 AM
HTML code from XML to display using XSL koenige XSLT 6 October 27th, 2008 08:11 AM
Rendering HTML inside XML through XSL - HELP !!! jilly XSLT 6 May 23rd, 2007 10:36 AM
xml to html with xsl boblavinsky XSLT 4 January 5th, 2007 05:30 AM
XML/XSL to actual HTML tcstom XML 3 December 9th, 2005 01:36 PM





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